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