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.edl.impl.bo.EDocLiteAssociation; |
25 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
26 | |
import org.kuali.rice.kew.help.HelpEntry; |
27 | |
import org.kuali.rice.kew.rule.RuleBaseValues; |
28 | |
import org.kuali.rice.kew.rule.RuleDelegation; |
29 | |
import org.kuali.rice.kew.rule.bo.RuleAttribute; |
30 | |
import org.kuali.rice.kew.rule.bo.RuleTemplate; |
31 | |
import org.kuali.rice.kim.bo.Group; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class KewExportDataSet { |
40 | |
|
41 | 0 | public static final QName DOCUMENT_TYPES = new QName("KEW", "documentTypes"); |
42 | 0 | public static final QName GROUPS = new QName("KEW", "groups"); |
43 | 0 | public static final QName RULE_ATTRIBUTES = new QName("KEW", "ruleAttributes"); |
44 | 0 | public static final QName RULE_TEMPLATES = new QName("KEW", "ruleTemplates"); |
45 | 0 | public static final QName RULES = new QName("KEW", "rules"); |
46 | 0 | public static final QName RULE_DELEGATIONS = new QName("KEW", "ruleDelegations"); |
47 | 0 | public static final QName HELP = new QName("KEW", "help"); |
48 | 0 | public static final QName EDOCLITES = new QName("KEW", "eDocLites"); |
49 | |
|
50 | 0 | private List<DocumentType> documentTypes = new ArrayList<DocumentType>(); |
51 | 0 | private List<Group> groups = new ArrayList<Group>(); |
52 | 0 | private List<RuleAttribute> ruleAttributes = new ArrayList<RuleAttribute>(); |
53 | 0 | private List<RuleTemplate> ruleTemplates = new ArrayList<RuleTemplate>(); |
54 | 0 | private List<RuleBaseValues> rules = new ArrayList<RuleBaseValues>(); |
55 | 0 | private List<RuleDelegation> ruleDelegations = new ArrayList<RuleDelegation>(); |
56 | 0 | private List<HelpEntry> help = new ArrayList<HelpEntry>(); |
57 | 0 | private List<EDocLiteAssociation> edocLites = new ArrayList<EDocLiteAssociation>(); |
58 | |
|
59 | |
public List<DocumentType> getDocumentTypes() { |
60 | 0 | return documentTypes; |
61 | |
} |
62 | |
|
63 | |
public List<HelpEntry> getHelp() { |
64 | 0 | return help; |
65 | |
} |
66 | |
|
67 | |
public List<RuleAttribute> getRuleAttributes() { |
68 | 0 | return ruleAttributes; |
69 | |
} |
70 | |
|
71 | |
public List<RuleBaseValues> getRules() { |
72 | 0 | return rules; |
73 | |
} |
74 | |
|
75 | |
public List<RuleTemplate> getRuleTemplates() { |
76 | 0 | return ruleTemplates; |
77 | |
} |
78 | |
|
79 | |
public List<EDocLiteAssociation> getEdocLites() { |
80 | 0 | return edocLites; |
81 | |
} |
82 | |
|
83 | |
public List<Group> getGroups() { |
84 | 0 | return this.groups; |
85 | |
} |
86 | |
|
87 | |
public void setGroups(List<Group> groups) { |
88 | 0 | this.groups = groups; |
89 | 0 | } |
90 | |
|
91 | |
public List<RuleDelegation> getRuleDelegations() { |
92 | 0 | return this.ruleDelegations; |
93 | |
} |
94 | |
|
95 | |
public void populateExportDataSet(ExportDataSet exportDataSet) { |
96 | 0 | if (documentTypes != null && !documentTypes.isEmpty()) { |
97 | 0 | exportDataSet.addDataSet(DOCUMENT_TYPES, documentTypes); |
98 | |
} |
99 | 0 | if (groups != null && !groups.isEmpty()) { |
100 | 0 | exportDataSet.addDataSet(GROUPS, groups); |
101 | |
} |
102 | 0 | if (ruleAttributes != null && !ruleAttributes.isEmpty()) { |
103 | 0 | exportDataSet.addDataSet(RULE_ATTRIBUTES, ruleAttributes); |
104 | |
} |
105 | 0 | if (ruleTemplates != null && !ruleTemplates.isEmpty()) { |
106 | 0 | exportDataSet.addDataSet(RULE_TEMPLATES, ruleTemplates); |
107 | |
} |
108 | 0 | if (rules != null && !rules.isEmpty()) { |
109 | 0 | exportDataSet.addDataSet(RULES, rules); |
110 | |
} |
111 | 0 | if (ruleDelegations != null && !ruleDelegations.isEmpty()) { |
112 | 0 | exportDataSet.addDataSet(RULE_DELEGATIONS, ruleDelegations); |
113 | |
} |
114 | 0 | if (help != null && !help.isEmpty()) { |
115 | 0 | exportDataSet.addDataSet(HELP, help); |
116 | |
} |
117 | 0 | if (edocLites != null && !edocLites.isEmpty()) { |
118 | 0 | exportDataSet.addDataSet(EDOCLITES, edocLites); |
119 | |
} |
120 | 0 | } |
121 | |
|
122 | |
public ExportDataSet createExportDataSet() { |
123 | 0 | ExportDataSet exportDataSet = new ExportDataSet(); |
124 | 0 | populateExportDataSet(exportDataSet); |
125 | 0 | return exportDataSet; |
126 | |
} |
127 | |
|
128 | |
public static KewExportDataSet fromExportDataSet(ExportDataSet exportDataSet) { |
129 | 0 | KewExportDataSet kewExportDataSet = new KewExportDataSet(); |
130 | |
|
131 | 0 | List<DocumentType> documentTypes = (List<DocumentType>)exportDataSet.getDataSets().get(DOCUMENT_TYPES); |
132 | 0 | if (documentTypes != null) { |
133 | 0 | kewExportDataSet.getDocumentTypes().addAll(documentTypes); |
134 | |
} |
135 | 0 | List<Group> groups = (List<Group>)exportDataSet.getDataSets().get(GROUPS); |
136 | 0 | if (groups != null) { |
137 | 0 | kewExportDataSet.getGroups().addAll(groups); |
138 | |
} |
139 | 0 | List<RuleAttribute> ruleAttributes = (List<RuleAttribute>)exportDataSet.getDataSets().get(RULE_ATTRIBUTES); |
140 | 0 | if (ruleAttributes != null) { |
141 | 0 | kewExportDataSet.getRuleAttributes().addAll(ruleAttributes); |
142 | |
} |
143 | 0 | List<RuleTemplate> ruleTemplates = (List<RuleTemplate>)exportDataSet.getDataSets().get(RULE_TEMPLATES); |
144 | 0 | if (ruleTemplates != null) { |
145 | 0 | kewExportDataSet.getRuleTemplates().addAll(ruleTemplates); |
146 | |
} |
147 | 0 | List<RuleBaseValues> rules = (List<RuleBaseValues>)exportDataSet.getDataSets().get(RULES); |
148 | 0 | if (rules != null) { |
149 | 0 | kewExportDataSet.getRules().addAll(rules); |
150 | |
} |
151 | 0 | List<RuleDelegation> ruleDelegations = (List<RuleDelegation>)exportDataSet.getDataSets().get(RULE_DELEGATIONS); |
152 | 0 | if (ruleDelegations != null) { |
153 | 0 | kewExportDataSet.getRuleDelegations().addAll(ruleDelegations); |
154 | |
} |
155 | 0 | List<HelpEntry> help = (List<HelpEntry>)exportDataSet.getDataSets().get(HELP); |
156 | 0 | if (help != null) { |
157 | 0 | kewExportDataSet.getHelp().addAll(help); |
158 | |
} |
159 | 0 | List<EDocLiteAssociation> edocLites = (List<EDocLiteAssociation>)exportDataSet.getDataSets().get(EDOCLITES); |
160 | 0 | if (edocLites != null) { |
161 | 0 | kewExportDataSet.getEdocLites().addAll(edocLites); |
162 | |
} |
163 | |
|
164 | 0 | return kewExportDataSet; |
165 | |
} |
166 | |
|
167 | |
} |