1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.kuali.rice.kew.xml.export; |
18 |
|
|
19 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.CLASS_NAME; |
20 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.DESCRIPTION; |
21 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.LABEL; |
22 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.NAME; |
23 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.RULE_ATTRIBUTE; |
24 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.RULE_ATTRIBUTES; |
25 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.RULE_ATTRIBUTE_NAMESPACE; |
26 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.RULE_ATTRIBUTE_SCHEMA_LOCATION; |
27 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.SCHEMA_LOCATION_ATTR; |
28 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.SCHEMA_NAMESPACE; |
29 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.SERVICE_NAMESPACE; |
30 |
|
import static org.kuali.rice.core.api.impex.xml.XmlConstants.TYPE; |
31 |
|
|
32 |
|
import java.io.StringReader; |
33 |
|
import java.util.Iterator; |
34 |
|
|
35 |
|
import org.jdom.Document; |
36 |
|
import org.jdom.Element; |
37 |
|
import org.jdom.input.SAXBuilder; |
38 |
|
import org.kuali.rice.core.api.impex.ExportDataSet; |
39 |
|
import org.kuali.rice.core.framework.impex.xml.XmlExporter; |
40 |
|
import org.kuali.rice.core.util.XmlHelper; |
41 |
|
import org.kuali.rice.core.util.XmlRenderer; |
42 |
|
import org.kuali.rice.kew.exception.WorkflowRuntimeException; |
43 |
|
import org.kuali.rice.kew.export.KewExportDataSet; |
44 |
|
import org.kuali.rice.kew.rule.bo.RuleAttribute; |
45 |
|
|
46 |
|
|
47 |
|
@link |
48 |
|
|
49 |
|
@see |
50 |
|
|
51 |
|
@author |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 7 |
Complexity Density: 0.29 |
|
53 |
|
public class RuleAttributeXmlExporter implements XmlExporter { |
54 |
|
|
55 |
|
protected final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(getClass()); |
56 |
|
|
57 |
|
private XmlRenderer renderer = new XmlRenderer(RULE_ATTRIBUTE_NAMESPACE); |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0
|
@Override... |
60 |
|
public boolean supportPrettyPrint() { |
61 |
0
|
return true; |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
64 |
0
|
public Element export(ExportDataSet exportDataSet) {... |
65 |
0
|
KewExportDataSet dataSet = KewExportDataSet.fromExportDataSet(exportDataSet); |
66 |
0
|
if (!dataSet.getRuleAttributes().isEmpty()) { |
67 |
0
|
Element rootElement = renderer.renderElement(null, RULE_ATTRIBUTES); |
68 |
0
|
rootElement.setAttribute(SCHEMA_LOCATION_ATTR, RULE_ATTRIBUTE_SCHEMA_LOCATION, SCHEMA_NAMESPACE); |
69 |
0
|
for (Iterator iterator = dataSet.getRuleAttributes().iterator(); iterator.hasNext();) { |
70 |
0
|
RuleAttribute template = (RuleAttribute)iterator.next(); |
71 |
0
|
exportRuleAttribute(rootElement, template); |
72 |
|
} |
73 |
0
|
return rootElement; |
74 |
|
} |
75 |
0
|
return null; |
76 |
|
} |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.21 |
|
78 |
0
|
private void exportRuleAttribute(Element parent, RuleAttribute ruleAttribute) {... |
79 |
0
|
Element attributeElement = renderer.renderElement(parent, RULE_ATTRIBUTE); |
80 |
0
|
renderer.renderTextElement(attributeElement, NAME, ruleAttribute.getName()); |
81 |
0
|
renderer.renderTextElement(attributeElement, CLASS_NAME, ruleAttribute.getClassName()); |
82 |
0
|
renderer.renderTextElement(attributeElement, LABEL, ruleAttribute.getLabel()); |
83 |
0
|
renderer.renderTextElement(attributeElement, DESCRIPTION, ruleAttribute.getDescription()); |
84 |
0
|
renderer.renderTextElement(attributeElement, TYPE, ruleAttribute.getType()); |
85 |
0
|
renderer.renderTextElement(attributeElement, SERVICE_NAMESPACE, ruleAttribute.getServiceNamespace()); |
86 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(ruleAttribute.getXmlConfigData())) { |
87 |
0
|
try { |
88 |
0
|
Document configDoc = new SAXBuilder().build(new StringReader(ruleAttribute.getXmlConfigData())); |
89 |
0
|
XmlHelper.propagateNamespace(configDoc.getRootElement(), RULE_ATTRIBUTE_NAMESPACE); |
90 |
0
|
attributeElement.addContent(configDoc.getRootElement().detach()); |
91 |
|
} catch (Exception e) { |
92 |
0
|
LOG.error("Error parsing attribute XML configuration.", e); |
93 |
0
|
throw new WorkflowRuntimeException("Error parsing attribute XML configuration."); |
94 |
|
} |
95 |
|
} |
96 |
|
} |
97 |
|
|
98 |
|
} |