1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.export; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.List; |
20 | |
|
21 | |
import javax.xml.namespace.QName; |
22 | |
|
23 | |
import org.kuali.rice.core.api.impex.ExportDataSet; |
24 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
25 | |
import org.kuali.rice.kew.rule.RuleBaseValues; |
26 | |
import org.kuali.rice.kew.rule.RuleDelegationBo; |
27 | |
import org.kuali.rice.kew.rule.bo.RuleAttribute; |
28 | |
import org.kuali.rice.kew.rule.bo.RuleTemplateBo; |
29 | |
import org.kuali.rice.kim.api.group.Group; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public class KewExportDataSet { |
38 | |
|
39 | 0 | public static final QName DOCUMENT_TYPES = new QName("KEW", "documentTypes"); |
40 | 0 | public static final QName GROUPS = new QName("KEW", "groups"); |
41 | 0 | public static final QName RULE_ATTRIBUTES = new QName("KEW", "ruleAttributes"); |
42 | 0 | public static final QName RULE_TEMPLATES = new QName("KEW", "ruleTemplates"); |
43 | 0 | public static final QName RULES = new QName("KEW", "rules"); |
44 | 0 | public static final QName RULE_DELEGATIONS = new QName("KEW", "ruleDelegations"); |
45 | 0 | public static final QName HELP = new QName("KEW", "help"); |
46 | 0 | public static final QName EDOCLITES = new QName("KEW", "eDocLites"); |
47 | |
|
48 | 0 | private List<DocumentType> documentTypes = new ArrayList<DocumentType>(); |
49 | 0 | private List<Group> groups = new ArrayList<Group>(); |
50 | 0 | private List<RuleAttribute> ruleAttributes = new ArrayList<RuleAttribute>(); |
51 | 0 | private List<RuleTemplateBo> ruleTemplates = new ArrayList<RuleTemplateBo>(); |
52 | 0 | private List<RuleBaseValues> rules = new ArrayList<RuleBaseValues>(); |
53 | 0 | private List<RuleDelegationBo> ruleDelegations = new ArrayList<RuleDelegationBo>(); |
54 | |
|
55 | |
public List<DocumentType> getDocumentTypes() { |
56 | 0 | return documentTypes; |
57 | |
} |
58 | |
|
59 | |
public List<RuleAttribute> getRuleAttributes() { |
60 | 0 | return ruleAttributes; |
61 | |
} |
62 | |
|
63 | |
public List<RuleBaseValues> getRules() { |
64 | 0 | return rules; |
65 | |
} |
66 | |
|
67 | |
public List<RuleTemplateBo> getRuleTemplates() { |
68 | 0 | return ruleTemplates; |
69 | |
} |
70 | |
|
71 | |
public List<Group> getGroups() { |
72 | 0 | return this.groups; |
73 | |
} |
74 | |
|
75 | |
public void setGroups(List<Group> groups) { |
76 | 0 | this.groups = groups; |
77 | 0 | } |
78 | |
|
79 | |
public List<RuleDelegationBo> getRuleDelegations() { |
80 | 0 | return this.ruleDelegations; |
81 | |
} |
82 | |
|
83 | |
public void populateExportDataSet(ExportDataSet exportDataSet) { |
84 | 0 | if (documentTypes != null && !documentTypes.isEmpty()) { |
85 | 0 | exportDataSet.addDataSet(DOCUMENT_TYPES, documentTypes); |
86 | |
} |
87 | 0 | if (groups != null && !groups.isEmpty()) { |
88 | 0 | exportDataSet.addDataSet(GROUPS, groups); |
89 | |
} |
90 | 0 | if (ruleAttributes != null && !ruleAttributes.isEmpty()) { |
91 | 0 | exportDataSet.addDataSet(RULE_ATTRIBUTES, ruleAttributes); |
92 | |
} |
93 | 0 | if (ruleTemplates != null && !ruleTemplates.isEmpty()) { |
94 | 0 | exportDataSet.addDataSet(RULE_TEMPLATES, ruleTemplates); |
95 | |
} |
96 | 0 | if (rules != null && !rules.isEmpty()) { |
97 | 0 | exportDataSet.addDataSet(RULES, rules); |
98 | |
} |
99 | 0 | if (ruleDelegations != null && !ruleDelegations.isEmpty()) { |
100 | 0 | exportDataSet.addDataSet(RULE_DELEGATIONS, ruleDelegations); |
101 | |
} |
102 | 0 | } |
103 | |
|
104 | |
public ExportDataSet createExportDataSet() { |
105 | 0 | ExportDataSet exportDataSet = new ExportDataSet(); |
106 | 0 | populateExportDataSet(exportDataSet); |
107 | 0 | return exportDataSet; |
108 | |
} |
109 | |
|
110 | |
public static KewExportDataSet fromExportDataSet(ExportDataSet exportDataSet) { |
111 | 0 | KewExportDataSet kewExportDataSet = new KewExportDataSet(); |
112 | |
|
113 | 0 | List<DocumentType> documentTypes = (List<DocumentType>)exportDataSet.getDataSets().get(DOCUMENT_TYPES); |
114 | 0 | if (documentTypes != null) { |
115 | 0 | kewExportDataSet.getDocumentTypes().addAll(documentTypes); |
116 | |
} |
117 | 0 | List<Group> groups = (List<Group>)exportDataSet.getDataSets().get(GROUPS); |
118 | 0 | if (groups != null) { |
119 | 0 | kewExportDataSet.getGroups().addAll(groups); |
120 | |
} |
121 | 0 | List<RuleAttribute> ruleAttributes = (List<RuleAttribute>)exportDataSet.getDataSets().get(RULE_ATTRIBUTES); |
122 | 0 | if (ruleAttributes != null) { |
123 | 0 | kewExportDataSet.getRuleAttributes().addAll(ruleAttributes); |
124 | |
} |
125 | 0 | List<RuleTemplateBo> ruleTemplates = (List<RuleTemplateBo>)exportDataSet.getDataSets().get(RULE_TEMPLATES); |
126 | 0 | if (ruleTemplates != null) { |
127 | 0 | kewExportDataSet.getRuleTemplates().addAll(ruleTemplates); |
128 | |
} |
129 | 0 | List<RuleBaseValues> rules = (List<RuleBaseValues>)exportDataSet.getDataSets().get(RULES); |
130 | 0 | if (rules != null) { |
131 | 0 | kewExportDataSet.getRules().addAll(rules); |
132 | |
} |
133 | 0 | List<RuleDelegationBo> ruleDelegations = (List<RuleDelegationBo>)exportDataSet.getDataSets().get(RULE_DELEGATIONS); |
134 | 0 | if (ruleDelegations != null) { |
135 | 0 | kewExportDataSet.getRuleDelegations().addAll(ruleDelegations); |
136 | |
} |
137 | |
|
138 | 0 | return kewExportDataSet; |
139 | |
} |
140 | |
|
141 | |
} |