private void exportRuleTemplate(Element parent, RuleTemplateBo ruleTemplate) { Element templateElement = renderer.renderElement(parent, RULE_TEMPLATE); renderer.renderTextElement(templateElement, NAME, ruleTemplate.getName()); renderer.renderTextElement(templateElement, DESCRIPTION, ruleTemplate.getDescription()); if (ruleTemplate.getDelegationTemplate() != null) { renderer.renderTextElement( templateElement, DELEGATION_TEMPLATE, ruleTemplate.getDelegationTemplate().getName()); } exportAttributes(templateElement, ruleTemplate.getActiveRuleTemplateAttributes()); exportDefaults(templateElement, ruleTemplate); }
private void exportAttributes(Element parent, List ruleTemplateAttributes) { if (!ruleTemplateAttributes.isEmpty()) { Element attributesElement = renderer.renderElement(parent, ATTRIBUTES); for (Iterator iterator = ruleTemplateAttributes.iterator(); iterator.hasNext(); ) { RuleTemplateAttributeBo attribute = (RuleTemplateAttributeBo) iterator.next(); Element attributeElement = renderer.renderElement(attributesElement, ATTRIBUTE); renderer.renderTextElement(attributeElement, NAME, attribute.getRuleAttribute().getName()); renderer.renderBooleanElement(attributeElement, REQUIRED, attribute.getRequired(), false); } } }
public Element export(ExportDataSet exportDataSet) { KewExportDataSet dataSet = KewExportDataSet.fromExportDataSet(exportDataSet); if (!dataSet.getRuleTemplates().isEmpty()) { Element rootElement = renderer.renderElement(null, RULE_TEMPLATES); rootElement.setAttribute( SCHEMA_LOCATION_ATTR, RULE_TEMPLATE_SCHEMA_LOCATION, SCHEMA_NAMESPACE); for (Iterator iterator = dataSet.getRuleTemplates().iterator(); iterator.hasNext(); ) { RuleTemplateBo template = (RuleTemplateBo) iterator.next(); exportRuleTemplate(rootElement, template); } return rootElement; } return null; }
private void exportDefaults(Element parent, RuleTemplateBo ruleTemplate) { RuleBaseValues defaultRuleValues = KEWServiceLocator.getRuleService().findDefaultRuleByRuleTemplateId(ruleTemplate.getId()); if (defaultRuleValues != null) { RuleDelegationBo defaultDelegationValues = getDefaultDelegationValues(defaultRuleValues); Element defaultsElement = renderer.renderElement(parent, RULE_DEFAULTS); if (defaultDelegationValues != null) { renderer.renderTextElement( defaultsElement, DELEGATION_TYPE, defaultDelegationValues.getDelegationType().getCode()); } renderer.renderTextElement(defaultsElement, DESCRIPTION, defaultRuleValues.getDescription()); if (defaultRuleValues.getFromDateValue() != null) { renderer.renderDateElement( defaultsElement, FROM_DATE, defaultRuleValues.getFromDateValue()); } if (defaultRuleValues.getToDateValue() != null) { renderer.renderDateElement(defaultsElement, TO_DATE, defaultRuleValues.getToDateValue()); } renderer.renderBooleanElement( defaultsElement, FORCE_ACTION, defaultRuleValues.isForceAction(), false); renderer.renderBooleanElement(defaultsElement, ACTIVE, defaultRuleValues.isActive(), true); if (defaultDelegationValues == null) { RuleTemplateOptionBo defaultActionOption = ruleTemplate.getDefaultActionRequestValue(); RuleTemplateOptionBo supportsComplete = ruleTemplate.getComplete(); RuleTemplateOptionBo supportsApprove = ruleTemplate.getApprove(); RuleTemplateOptionBo supportsAck = ruleTemplate.getAcknowledge(); RuleTemplateOptionBo supportsFYI = ruleTemplate.getFyi(); if (defaultActionOption != null) { String defaultActionValue = (defaultActionOption == null ? null : defaultActionOption.getValue()); renderer.renderTextElement(defaultsElement, DEFAULT_ACTION_REQUESTED, defaultActionValue); } if (supportsComplete != null) { String supportsCompleteValue = supportsComplete.getValue(); renderer.renderTextElement(defaultsElement, SUPPORTS_COMPLETE, supportsCompleteValue); } if (supportsApprove != null) { String supportsApproveValue = supportsApprove.getValue(); renderer.renderTextElement(defaultsElement, SUPPORTS_APPROVE, supportsApproveValue); } if (supportsAck != null) { String supportsAckValue = supportsAck.getValue(); renderer.renderTextElement(defaultsElement, SUPPORTS_ACKNOWLEDGE, supportsAckValue); } if (supportsFYI != null) { String supportsFYIValue = supportsFYI.getValue(); renderer.renderTextElement(defaultsElement, SUPPORTS_FYI, supportsFYIValue); } } } }