1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.api.action;
17
18 import java.io.Serializable;
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.Collections;
22 import java.util.List;
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlAnyElement;
26 import javax.xml.bind.annotation.XmlElement;
27 import javax.xml.bind.annotation.XmlRootElement;
28 import javax.xml.bind.annotation.XmlType;
29
30 import org.kuali.rice.core.api.CoreConstants;
31 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
32 import org.kuali.rice.core.api.mo.ModelBuilder;
33 import org.w3c.dom.Element;
34
35 @XmlRootElement(name = RoutingReportCriteria.Constants.ROOT_ELEMENT_NAME)
36 @XmlAccessorType(XmlAccessType.NONE)
37 @XmlType(name = RoutingReportCriteria.Constants.TYPE_NAME, propOrder = {
38 RoutingReportCriteria.Elements.DOCUMENT_ID,
39 RoutingReportCriteria.Elements.TARGET_NODE_NAME,
40 RoutingReportCriteria.Elements.TARGET_PRINCIPAL_IDS,
41 RoutingReportCriteria.Elements.ROUTING_PRINCIPAL_ID,
42 RoutingReportCriteria.Elements.DOCUMENT_TYPE_NAME,
43 RoutingReportCriteria.Elements.XML_CONTENT,
44 RoutingReportCriteria.Elements.RULE_TEMPLATE_NAMES,
45 RoutingReportCriteria.Elements.NODE_NAMES,
46 RoutingReportCriteria.Elements.ACTIONS_TO_TAKE,
47 RoutingReportCriteria.Elements.ACTIVATE_REQUESTS,
48 RoutingReportCriteria.Elements.FLATTEN_NODES,
49 CoreConstants.CommonElements.FUTURE_ELEMENTS})
50 public final class RoutingReportCriteria extends AbstractDataTransferObject implements RoutingReportCriteriaContract {
51
52 @XmlElement(name = Elements.DOCUMENT_ID, required = false)
53 private final String documentId;
54 @XmlElement(name = Elements.TARGET_NODE_NAME, required = false)
55 private final String targetNodeName;
56 @XmlElement(name = Elements.TARGET_PRINCIPAL_IDS, required = false)
57 private final List<String> targetPrincipalIds;
58 @XmlElement(name = Elements.ROUTING_PRINCIPAL_ID, required = false)
59 private final String routingPrincipalId;
60 @XmlElement(name = Elements.DOCUMENT_TYPE_NAME, required = false)
61 private final String documentTypeName;
62 @XmlElement(name = Elements.XML_CONTENT, required = false)
63 private final String xmlContent;
64 @XmlElement(name = Elements.RULE_TEMPLATE_NAMES, required = false)
65 private final List<String> ruleTemplateNames;
66 @XmlElement(name = Elements.NODE_NAMES, required = false)
67 private final List<String> nodeNames;
68 @XmlElement(name = Elements.ACTIONS_TO_TAKE, required = false)
69 private final List<RoutingReportActionToTake> actionsToTake;
70 @XmlElement(name = Elements.ACTIVATE_REQUESTS, required = false)
71 private final boolean activateRequests;
72 @XmlElement(name = Elements.FLATTEN_NODES, required = false)
73 private final boolean flattenNodes;
74 @SuppressWarnings("unused")
75 @XmlAnyElement
76 private final Collection<Element> _futureElements = null;
77
78
79
80
81 private RoutingReportCriteria() {
82 this.documentId = null;
83 this.targetNodeName = null;
84 this.targetPrincipalIds = null;
85 this.routingPrincipalId = null;
86 this.documentTypeName = null;
87 this.xmlContent = null;
88 this.ruleTemplateNames = null;
89 this.nodeNames = null;
90 this.actionsToTake = null;
91 this.flattenNodes = false;
92 this.activateRequests = false;
93 }
94
95 private RoutingReportCriteria(Builder builder) {
96 this.documentId = builder.getDocumentId();
97 this.targetNodeName = builder.getTargetNodeName();
98 this.targetPrincipalIds = builder.getTargetPrincipalIds();
99 this.routingPrincipalId = builder.getRoutingPrincipalId();
100 this.documentTypeName = builder.getDocumentTypeName();
101 this.xmlContent = builder.getXmlContent();
102 this.ruleTemplateNames = builder.getRuleTemplateNames();
103 this.nodeNames = builder.getNodeNames();
104 if (builder.getActionsToTake() != null) {
105 List<RoutingReportActionToTake> actions = new ArrayList<RoutingReportActionToTake>();
106 for (RoutingReportActionToTake.Builder actionBuilder : builder.getActionsToTake()) {
107 actions.add(actionBuilder.build());
108 }
109 this.actionsToTake = actions;
110 } else {
111 this.actionsToTake = Collections.emptyList();
112 }
113 this.flattenNodes = builder.isFlattenNodes();
114 this.activateRequests = builder.isActivateRequests();
115 }
116
117 @Override
118 public String getDocumentId() {
119 return this.documentId;
120 }
121
122 @Override
123 public String getTargetNodeName() {
124 return this.targetNodeName;
125 }
126
127 @Override
128 public List<String> getTargetPrincipalIds() {
129 return this.targetPrincipalIds;
130 }
131
132 @Override
133 public String getRoutingPrincipalId() {
134 return this.routingPrincipalId;
135 }
136
137 @Override
138 public String getDocumentTypeName() {
139 return this.documentTypeName;
140 }
141
142 @Override
143 public String getXmlContent() {
144 return this.xmlContent;
145 }
146
147 @Override
148 public List<String> getRuleTemplateNames() {
149 return this.ruleTemplateNames;
150 }
151
152 @Override
153 public List<String> getNodeNames() {
154 return this.nodeNames;
155 }
156
157 @Override
158 public List<RoutingReportActionToTake> getActionsToTake() {
159 return this.actionsToTake;
160 }
161
162 @Override
163 public boolean isActivateRequests() {
164 return this.activateRequests;
165 }
166
167 @Override
168 public boolean isFlattenNodes() {
169 return this.flattenNodes;
170 }
171
172
173
174
175
176 public final static class Builder implements Serializable, ModelBuilder, RoutingReportCriteriaContract {
177
178 private String documentId;
179 private String targetNodeName;
180 private List<String> targetPrincipalIds;
181 private String routingPrincipalId;
182 private String documentTypeName;
183 private String xmlContent;
184 private List<String> ruleTemplateNames;
185 private List<String> nodeNames;
186 private List<RoutingReportActionToTake.Builder> actionsToTake;
187 private boolean activateRequests;
188 private boolean flattenNodes;
189
190 private Builder(String documentId, String targetNodeName) {
191 this.setDocumentId(documentId);
192 this.setTargetNodeName(targetNodeName);
193 }
194
195 private Builder(String documentTypeName) {
196 this.setDocumentTypeName(documentTypeName);
197 }
198
199 public static Builder createByDocumentTypeName(String documentTypeName) {
200 return new Builder(documentTypeName);
201 }
202
203 public static Builder createByDocumentId(String documentId) {
204 return new Builder(documentId, null);
205 }
206
207 public static Builder createByDocumentIdAndTargetNodeName(String documentId, String targetNodeName) {
208 return new Builder(documentId, targetNodeName);
209 }
210
211 public static Builder create(RoutingReportCriteriaContract contract) {
212 if (contract == null) {
213 throw new IllegalArgumentException("contract was null");
214 }
215 Builder builder =
216 createByDocumentIdAndTargetNodeName(contract.getDocumentId(), contract.getTargetNodeName());
217 builder.setDocumentId(contract.getDocumentId());
218 builder.setTargetNodeName(contract.getTargetNodeName());
219 builder.setTargetPrincipalIds(contract.getTargetPrincipalIds());
220 builder.setRoutingPrincipalId(contract.getRoutingPrincipalId());
221 builder.setDocumentTypeName(contract.getDocumentTypeName());
222 builder.setXmlContent(contract.getXmlContent());
223 builder.setRuleTemplateNames(contract.getRuleTemplateNames());
224 builder.setNodeNames(contract.getNodeNames());
225 if (contract.getActionsToTake() != null) {
226 List<RoutingReportActionToTake.Builder> actionsToTake = new ArrayList<RoutingReportActionToTake.Builder>();
227 for (RoutingReportActionToTakeContract action : contract.getActionsToTake()) {
228 actionsToTake.add(RoutingReportActionToTake.Builder.create(action));
229 }
230 builder.setActionsToTake(actionsToTake);
231 }
232 builder.setActivateRequests(contract.isActivateRequests());
233 builder.setFlattenNodes(contract.isFlattenNodes());
234
235 return builder;
236 }
237
238 public RoutingReportCriteria build() {
239 return new RoutingReportCriteria(this);
240 }
241
242 @Override
243 public String getDocumentId() {
244 return this.documentId;
245 }
246
247 @Override
248 public String getTargetNodeName() {
249 return this.targetNodeName;
250 }
251
252 @Override
253 public List<String> getTargetPrincipalIds() {
254 return this.targetPrincipalIds;
255 }
256
257 @Override
258 public String getRoutingPrincipalId() {
259 return this.routingPrincipalId;
260 }
261
262 @Override
263 public String getDocumentTypeName() {
264 return this.documentTypeName;
265 }
266
267 @Override
268 public String getXmlContent() {
269 return this.xmlContent;
270 }
271
272 @Override
273 public List<String> getRuleTemplateNames() {
274 return this.ruleTemplateNames;
275 }
276
277 @Override
278 public List<String> getNodeNames() {
279 return this.nodeNames;
280 }
281
282 @Override
283 public List<RoutingReportActionToTake.Builder> getActionsToTake() {
284 return this.actionsToTake;
285 }
286
287 @Override
288 public boolean isActivateRequests() {
289 return this.activateRequests;
290 }
291
292 @Override
293 public boolean isFlattenNodes() {
294 return this.flattenNodes;
295 }
296
297 public void setDocumentId(String documentId) {
298
299 this.documentId = documentId;
300 }
301
302 public void setTargetNodeName(String targetNodeName) {
303
304 this.targetNodeName = targetNodeName;
305 }
306
307 public void setTargetPrincipalIds(List<String> targetPrincipalIds) {
308
309 this.targetPrincipalIds = Collections.unmodifiableList(targetPrincipalIds);
310 }
311
312 public void setRoutingPrincipalId(String routingPrincipalId) {
313
314 this.routingPrincipalId = routingPrincipalId;
315 }
316
317 public void setDocumentTypeName(String documentTypeName) {
318
319 this.documentTypeName = documentTypeName;
320 }
321
322 public void setXmlContent(String xmlContent) {
323
324 this.xmlContent = xmlContent;
325 }
326
327 public void setRuleTemplateNames(List<String> ruleTemplateNames) {
328
329 this.ruleTemplateNames = Collections.unmodifiableList(ruleTemplateNames);
330 }
331
332 public void setNodeNames(List<String> nodeNames) {
333
334 this.nodeNames = Collections.unmodifiableList(nodeNames);
335 }
336
337 public void setActionsToTake(List<RoutingReportActionToTake.Builder> actionsToTake) {
338
339 this.actionsToTake = Collections.unmodifiableList(actionsToTake);
340 }
341
342 public void setActivateRequests(boolean activateRequests) {
343
344 this.activateRequests = activateRequests;
345 }
346
347 public void setFlattenNodes(boolean flattenNodes) {
348
349 this.flattenNodes = flattenNodes;
350 }
351 }
352
353
354
355
356 static class Constants {
357
358 final static String ROOT_ELEMENT_NAME = "routingReportCriteria";
359 final static String TYPE_NAME = "RoutingReportCriteriaType";
360 }
361
362
363
364
365
366 static class Elements {
367
368 final static String DOCUMENT_ID = "documentId";
369 final static String TARGET_NODE_NAME = "targetNodeName";
370 final static String TARGET_PRINCIPAL_IDS = "targetPrincipalIds";
371 final static String ROUTING_PRINCIPAL_ID = "routingPrincipalId";
372 final static String DOCUMENT_TYPE_NAME = "documentTypeName";
373 final static String XML_CONTENT = "xmlContent";
374 final static String RULE_TEMPLATE_NAMES = "ruleTemplateNames";
375 final static String NODE_NAMES = "nodeNames";
376 final static String ACTIONS_TO_TAKE = "actionsToTake";
377 final static String ACTIVATE_REQUESTS = "activateRequests";
378 final static String FLATTEN_NODES = "flattenNodes";
379 }
380 }