1 | |
package org.kuali.rice.kew.api.doctype; |
2 | |
|
3 | |
import org.apache.commons.lang.StringUtils; |
4 | |
import org.kuali.rice.core.api.CoreConstants; |
5 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
6 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
7 | |
import org.kuali.rice.core.api.util.CollectionUtils; |
8 | |
import org.w3c.dom.Element; |
9 | |
|
10 | |
import javax.xml.bind.annotation.XmlAccessType; |
11 | |
import javax.xml.bind.annotation.XmlAccessorType; |
12 | |
import javax.xml.bind.annotation.XmlAnyElement; |
13 | |
import javax.xml.bind.annotation.XmlElement; |
14 | |
import javax.xml.bind.annotation.XmlElementWrapper; |
15 | |
import javax.xml.bind.annotation.XmlRootElement; |
16 | |
import javax.xml.bind.annotation.XmlType; |
17 | |
import java.io.Serializable; |
18 | |
import java.util.ArrayList; |
19 | |
import java.util.Collection; |
20 | |
import java.util.List; |
21 | |
|
22 | |
@XmlRootElement(name = RouteNode.Constants.ROOT_ELEMENT_NAME) |
23 | |
@XmlAccessorType(XmlAccessType.NONE) |
24 | |
@XmlType(name = RouteNode.Constants.TYPE_NAME, propOrder = { |
25 | |
RouteNode.Elements.ID, |
26 | |
RouteNode.Elements.DOCUMENT_TYPE_ID, |
27 | |
RouteNode.Elements.NAME, |
28 | |
RouteNode.Elements.ROUTE_METHOD_NAME, |
29 | |
RouteNode.Elements.ROUTE_METHOD_CODE, |
30 | |
RouteNode.Elements.FINAL_APPROVAL, |
31 | |
RouteNode.Elements.MANDATORY, |
32 | |
RouteNode.Elements.ACTIVATION_TYPE, |
33 | |
RouteNode.Elements.EXCEPTION_GROUP_ID, |
34 | |
RouteNode.Elements.TYPE, |
35 | |
RouteNode.Elements.BRANCH_NAME, |
36 | |
RouteNode.Elements.NEXT_DOCUMENT_STATUS, |
37 | |
RouteNode.Elements.CONFIGURATION_PARAMETERS, |
38 | |
RouteNode.Elements.PREVIOUS_NODE_IDS, |
39 | |
RouteNode.Elements.NEXT_NODE_IDS, |
40 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
41 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
42 | |
}) |
43 | 0 | public final class RouteNode extends AbstractDataTransferObject implements RouteNodeContract { |
44 | |
|
45 | |
private static final long serialVersionUID = -1756380702013287285L; |
46 | |
|
47 | |
@XmlElement(name = Elements.ID, required = false) |
48 | |
private final String id; |
49 | |
|
50 | |
@XmlElement(name = Elements.DOCUMENT_TYPE_ID, required = false) |
51 | |
private final String documentTypeId; |
52 | |
|
53 | |
@XmlElement(name = Elements.NAME, required = true) |
54 | |
private final String name; |
55 | |
|
56 | |
@XmlElement(name = Elements.ROUTE_METHOD_NAME, required = false) |
57 | |
private final String routeMethodName; |
58 | |
|
59 | |
@XmlElement(name = Elements.ROUTE_METHOD_CODE, required = false) |
60 | |
private final String routeMethodCode; |
61 | |
|
62 | |
@XmlElement(name = Elements.FINAL_APPROVAL, required = false) |
63 | |
private final boolean finalApproval; |
64 | |
|
65 | |
@XmlElement(name = Elements.MANDATORY, required = false) |
66 | |
private final boolean mandatory; |
67 | |
|
68 | |
@XmlElement(name = Elements.ACTIVATION_TYPE, required = false) |
69 | |
private final String activationType; |
70 | |
|
71 | |
@XmlElement(name = Elements.EXCEPTION_GROUP_ID, required = false) |
72 | |
private final String exceptionGroupId; |
73 | |
|
74 | |
@XmlElement(name = Elements.TYPE, required = true) |
75 | |
private final String type; |
76 | |
|
77 | |
@XmlElement(name = Elements.BRANCH_NAME, required = false) |
78 | |
private final String branchName; |
79 | |
|
80 | |
@XmlElement(name = Elements.NEXT_DOCUMENT_STATUS, required = false) |
81 | |
private final String nextDocumentStatus; |
82 | |
|
83 | |
@XmlElementWrapper(name = Elements.CONFIGURATION_PARAMETERS, required = false) |
84 | |
@XmlElement(name = Elements.CONFIGURATION_PARAMETER, required = false) |
85 | |
private final List<RouteNodeConfigurationParameter> configurationParameters; |
86 | |
|
87 | |
@XmlElementWrapper(name = Elements.PREVIOUS_NODE_IDS, required = false) |
88 | |
@XmlElement(name = Elements.PREVIOUS_NODE_ID, required = false) |
89 | |
private final List<String> previousNodeIds; |
90 | |
|
91 | |
@XmlElementWrapper(name = Elements.NEXT_NODE_IDS, required = false) |
92 | |
@XmlElement(name = Elements.NEXT_NODE_ID, required = false) |
93 | |
private final List<String> nextNodeIds; |
94 | |
|
95 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
96 | |
private final Long versionNumber; |
97 | |
|
98 | 0 | @SuppressWarnings("unused") |
99 | |
@XmlAnyElement |
100 | |
private final Collection<Element> _futureElements = null; |
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | 0 | private RouteNode() { |
106 | 0 | this.id = null; |
107 | 0 | this.documentTypeId = null; |
108 | 0 | this.name = null; |
109 | 0 | this.routeMethodName = null; |
110 | 0 | this.routeMethodCode = null; |
111 | 0 | this.finalApproval = false; |
112 | 0 | this.mandatory = false; |
113 | 0 | this.activationType = null; |
114 | 0 | this.exceptionGroupId = null; |
115 | 0 | this.type = null; |
116 | 0 | this.branchName = null; |
117 | 0 | this.nextDocumentStatus = null; |
118 | 0 | this.configurationParameters = null; |
119 | 0 | this.previousNodeIds = null; |
120 | 0 | this.nextNodeIds = null; |
121 | 0 | this.versionNumber = null; |
122 | 0 | } |
123 | |
|
124 | 0 | private RouteNode(Builder builder) { |
125 | 0 | this.id = builder.getId(); |
126 | 0 | this.documentTypeId = builder.getDocumentTypeId(); |
127 | 0 | this.name = builder.getName(); |
128 | 0 | this.routeMethodName = builder.getRouteMethodName(); |
129 | 0 | this.routeMethodCode = builder.getRouteMethodCode(); |
130 | 0 | this.finalApproval = builder.isFinalApproval(); |
131 | 0 | this.mandatory = builder.isMandatory(); |
132 | 0 | this.activationType = builder.getActivationType(); |
133 | 0 | this.exceptionGroupId = builder.getExceptionGroupId(); |
134 | 0 | this.type = builder.getType(); |
135 | 0 | this.branchName = builder.getBranchName(); |
136 | 0 | this.nextDocumentStatus = builder.getNextDocumentStatus(); |
137 | 0 | this.configurationParameters = new ArrayList<RouteNodeConfigurationParameter>(); |
138 | 0 | if (builder.getConfigurationParameters() != null) { |
139 | 0 | for (RouteNodeConfigurationParameter.Builder configurationParameter : builder.getConfigurationParameters()) { |
140 | 0 | this.configurationParameters.add(configurationParameter.build()); |
141 | |
} |
142 | |
} |
143 | 0 | this.previousNodeIds = new ArrayList<String>(builder.getPreviousNodeIds()); |
144 | 0 | this.nextNodeIds = new ArrayList<String>(builder.getNextNodeIds()); |
145 | 0 | this.versionNumber = builder.getVersionNumber(); |
146 | 0 | } |
147 | |
|
148 | |
@Override |
149 | |
public String getId() { |
150 | 0 | return this.id; |
151 | |
} |
152 | |
|
153 | |
@Override |
154 | |
public String getName() { |
155 | 0 | return this.name; |
156 | |
} |
157 | |
|
158 | |
@Override |
159 | |
public String getDocumentTypeId() { |
160 | 0 | return this.documentTypeId; |
161 | |
} |
162 | |
|
163 | |
@Override |
164 | |
public String getRouteMethodName() { |
165 | 0 | return this.routeMethodName; |
166 | |
} |
167 | |
|
168 | |
@Override |
169 | |
public String getRouteMethodCode() { |
170 | 0 | return this.routeMethodCode; |
171 | |
} |
172 | |
|
173 | |
@Override |
174 | |
public boolean isFinalApproval() { |
175 | 0 | return this.finalApproval; |
176 | |
} |
177 | |
|
178 | |
@Override |
179 | |
public boolean isMandatory() { |
180 | 0 | return this.mandatory; |
181 | |
} |
182 | |
|
183 | |
@Override |
184 | |
public String getActivationType() { |
185 | 0 | return this.activationType; |
186 | |
} |
187 | |
|
188 | |
@Override |
189 | |
public String getExceptionGroupId() { |
190 | 0 | return this.exceptionGroupId; |
191 | |
} |
192 | |
|
193 | |
@Override |
194 | |
public String getType() { |
195 | 0 | return this.type; |
196 | |
} |
197 | |
|
198 | |
@Override |
199 | |
public String getBranchName() { |
200 | 0 | return this.branchName; |
201 | |
} |
202 | |
|
203 | |
@Override |
204 | |
public String getNextDocumentStatus() { |
205 | 0 | return this.nextDocumentStatus; |
206 | |
} |
207 | |
|
208 | |
@Override |
209 | |
public List<RouteNodeConfigurationParameter> getConfigurationParameters() { |
210 | 0 | return CollectionUtils.unmodifiableListNullSafe(this.configurationParameters); |
211 | |
} |
212 | |
|
213 | |
@Override |
214 | |
public List<String> getPreviousNodeIds() { |
215 | 0 | return CollectionUtils.unmodifiableListNullSafe(this.previousNodeIds); |
216 | |
} |
217 | |
|
218 | |
@Override |
219 | |
public List<String> getNextNodeIds() { |
220 | 0 | return CollectionUtils.unmodifiableListNullSafe(this.nextNodeIds); |
221 | |
} |
222 | |
|
223 | |
@Override |
224 | |
public Long getVersionNumber() { |
225 | 0 | return this.versionNumber; |
226 | |
} |
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | 0 | public final static class Builder implements Serializable, ModelBuilder, RouteNodeContract { |
233 | |
|
234 | |
private static final long serialVersionUID = 7076065049417371344L; |
235 | |
private String id; |
236 | |
private String documentTypeId; |
237 | |
private String name; |
238 | |
private String routeMethodName; |
239 | |
private String routeMethodCode; |
240 | |
private boolean finalApproval; |
241 | |
private boolean mandatory; |
242 | |
private String activationType; |
243 | |
private String exceptionGroupId; |
244 | |
private String type; |
245 | |
private String branchName; |
246 | |
private String nextDocumentStatus; |
247 | |
private List<RouteNodeConfigurationParameter.Builder> configurationParameters; |
248 | |
private List<String> previousNodeIds; |
249 | |
private List<String> nextNodeIds; |
250 | |
private Long versionNumber; |
251 | |
|
252 | 0 | private Builder(String name, String type) { |
253 | 0 | setName(name); |
254 | 0 | setType(type); |
255 | 0 | setConfigurationParameters(new ArrayList<RouteNodeConfigurationParameter.Builder>()); |
256 | 0 | setPreviousNodeIds(new ArrayList<String>()); |
257 | 0 | setNextNodeIds(new ArrayList<String>()); |
258 | 0 | } |
259 | |
|
260 | |
public static Builder create(String name, String type) { |
261 | 0 | return new Builder(name, type); |
262 | |
} |
263 | |
|
264 | |
public static Builder create(RouteNodeContract contract) { |
265 | 0 | if (contract == null) { |
266 | 0 | throw new IllegalArgumentException("contract was null"); |
267 | |
} |
268 | 0 | Builder builder = create(contract.getName(), contract.getType()); |
269 | 0 | builder.setId(contract.getId()); |
270 | 0 | builder.setDocumentTypeId(contract.getDocumentTypeId()); |
271 | 0 | builder.setName(contract.getName()); |
272 | 0 | builder.setRouteMethodName(contract.getRouteMethodName()); |
273 | 0 | builder.setRouteMethodCode(contract.getRouteMethodCode()); |
274 | 0 | builder.setFinalApproval(contract.isFinalApproval()); |
275 | 0 | builder.setMandatory(contract.isMandatory()); |
276 | 0 | builder.setActivationType(contract.getActivationType()); |
277 | 0 | builder.setExceptionGroupId(contract.getExceptionGroupId()); |
278 | 0 | builder.setType(contract.getType()); |
279 | 0 | builder.setBranchName(contract.getBranchName()); |
280 | 0 | builder.setNextDocumentStatus(contract.getNextDocumentStatus()); |
281 | 0 | List<RouteNodeConfigurationParameter.Builder> parameterBuilders = new ArrayList<RouteNodeConfigurationParameter.Builder>(); |
282 | 0 | for (RouteNodeConfigurationParameterContract configurationParameter : contract.getConfigurationParameters()) { |
283 | 0 | parameterBuilders.add(RouteNodeConfigurationParameter.Builder.create(configurationParameter)); |
284 | |
} |
285 | 0 | builder.setConfigurationParameters(parameterBuilders); |
286 | 0 | builder.setPreviousNodeIds(contract.getPreviousNodeIds()); |
287 | 0 | builder.setNextNodeIds(contract.getNextNodeIds()); |
288 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
289 | |
|
290 | 0 | return builder; |
291 | |
} |
292 | |
|
293 | |
public RouteNode build() { |
294 | 0 | return new RouteNode(this); |
295 | |
} |
296 | |
|
297 | |
@Override |
298 | |
public String getId() { |
299 | 0 | return this.id; |
300 | |
} |
301 | |
|
302 | |
@Override |
303 | |
public String getDocumentTypeId() { |
304 | 0 | return this.documentTypeId; |
305 | |
} |
306 | |
|
307 | |
@Override |
308 | |
public String getName() { |
309 | 0 | return this.name; |
310 | |
} |
311 | |
|
312 | |
@Override |
313 | |
public String getRouteMethodName() { |
314 | 0 | return this.routeMethodName; |
315 | |
} |
316 | |
|
317 | |
@Override |
318 | |
public String getRouteMethodCode() { |
319 | 0 | return this.routeMethodCode; |
320 | |
} |
321 | |
|
322 | |
@Override |
323 | |
public boolean isFinalApproval() { |
324 | 0 | return this.finalApproval; |
325 | |
} |
326 | |
|
327 | |
@Override |
328 | |
public boolean isMandatory() { |
329 | 0 | return this.mandatory; |
330 | |
} |
331 | |
|
332 | |
@Override |
333 | |
public String getActivationType() { |
334 | 0 | return this.activationType; |
335 | |
} |
336 | |
|
337 | |
@Override |
338 | |
public String getExceptionGroupId() { |
339 | 0 | return this.exceptionGroupId; |
340 | |
} |
341 | |
|
342 | |
@Override |
343 | |
public String getType() { |
344 | 0 | return this.type; |
345 | |
} |
346 | |
|
347 | |
@Override |
348 | |
public String getBranchName() { |
349 | 0 | return this.branchName; |
350 | |
} |
351 | |
|
352 | |
@Override |
353 | |
public String getNextDocumentStatus() { |
354 | 0 | return this.nextDocumentStatus; |
355 | |
} |
356 | |
|
357 | |
@Override |
358 | |
public List<RouteNodeConfigurationParameter.Builder> getConfigurationParameters() { |
359 | 0 | return this.configurationParameters; |
360 | |
} |
361 | |
|
362 | |
@Override |
363 | |
public List<String> getPreviousNodeIds() { |
364 | 0 | return this.previousNodeIds; |
365 | |
} |
366 | |
|
367 | |
@Override |
368 | |
public List<String> getNextNodeIds() { |
369 | 0 | return this.nextNodeIds; |
370 | |
} |
371 | |
|
372 | |
@Override |
373 | |
public Long getVersionNumber() { |
374 | 0 | return this.versionNumber; |
375 | |
} |
376 | |
|
377 | |
public void setId(String id) { |
378 | 0 | this.id = id; |
379 | 0 | } |
380 | |
|
381 | |
public void setDocumentTypeId(String documentTypeId) { |
382 | 0 | this.documentTypeId = documentTypeId; |
383 | 0 | } |
384 | |
|
385 | |
public void setName(String name) { |
386 | 0 | if (StringUtils.isBlank(name)) { |
387 | 0 | throw new IllegalArgumentException("name was null or blank"); |
388 | |
} |
389 | 0 | this.name = name; |
390 | 0 | } |
391 | |
|
392 | |
public void setRouteMethodName(String routeMethodName) { |
393 | 0 | this.routeMethodName = routeMethodName; |
394 | 0 | } |
395 | |
|
396 | |
public void setRouteMethodCode(String routeMethodCode) { |
397 | 0 | this.routeMethodCode = routeMethodCode; |
398 | 0 | } |
399 | |
|
400 | |
public void setFinalApproval(boolean finalApproval) { |
401 | 0 | this.finalApproval = finalApproval; |
402 | 0 | } |
403 | |
|
404 | |
public void setMandatory(boolean mandatory) { |
405 | 0 | this.mandatory = mandatory; |
406 | 0 | } |
407 | |
|
408 | |
public void setActivationType(String activationType) { |
409 | 0 | this.activationType = activationType; |
410 | 0 | } |
411 | |
|
412 | |
public void setExceptionGroupId(String exceptionGroupId) { |
413 | 0 | this.exceptionGroupId = exceptionGroupId; |
414 | 0 | } |
415 | |
|
416 | |
public void setType(String type) { |
417 | 0 | if (StringUtils.isBlank(type)) { |
418 | 0 | throw new IllegalArgumentException("type was null or blank"); |
419 | |
} |
420 | 0 | this.type = type; |
421 | 0 | } |
422 | |
|
423 | |
public void setBranchName(String branchName) { |
424 | 0 | this.branchName = branchName; |
425 | 0 | } |
426 | |
|
427 | |
public void setNextDocumentStatus(String nextDocumentStatus) { |
428 | 0 | this.nextDocumentStatus = nextDocumentStatus; |
429 | 0 | } |
430 | |
|
431 | |
public void setConfigurationParameters(List<RouteNodeConfigurationParameter.Builder> configurationParameters) { |
432 | 0 | if (configurationParameters == null) { |
433 | 0 | throw new IllegalArgumentException("configurationParameters was null"); |
434 | |
} |
435 | 0 | this.configurationParameters = configurationParameters; |
436 | 0 | } |
437 | |
|
438 | |
public void setPreviousNodeIds(List<String> previousNodeIds) { |
439 | 0 | if (previousNodeIds == null) { |
440 | 0 | throw new IllegalArgumentException("previousNodeIds was null"); |
441 | |
} |
442 | 0 | this.previousNodeIds = previousNodeIds; |
443 | 0 | } |
444 | |
|
445 | |
public void setNextNodeIds(List<String> nextNodeIds) { |
446 | 0 | if (nextNodeIds == null) { |
447 | 0 | throw new IllegalArgumentException("nextNodeIds was null"); |
448 | |
} |
449 | 0 | this.nextNodeIds = nextNodeIds; |
450 | 0 | } |
451 | |
|
452 | |
public void setVersionNumber(Long versionNumber) { |
453 | 0 | this.versionNumber = versionNumber; |
454 | 0 | } |
455 | |
|
456 | |
} |
457 | |
|
458 | |
|
459 | |
|
460 | |
|
461 | 0 | static class Constants { |
462 | |
final static String ROOT_ELEMENT_NAME = "routeNode"; |
463 | |
final static String TYPE_NAME = "RouteNodeType"; |
464 | |
} |
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | 0 | static class Elements { |
471 | |
final static String ID = "id"; |
472 | |
final static String DOCUMENT_TYPE_ID = "documentTypeId"; |
473 | |
final static String NAME = "name"; |
474 | |
final static String ROUTE_METHOD_NAME = "routeMethodName"; |
475 | |
final static String ROUTE_METHOD_CODE = "routeMethodCode"; |
476 | |
final static String FINAL_APPROVAL = "finalApproval"; |
477 | |
final static String MANDATORY = "mandatory"; |
478 | |
final static String ACTIVATION_TYPE = "activationType"; |
479 | |
final static String EXCEPTION_GROUP_ID = "exceptionGroupId"; |
480 | |
final static String TYPE = "type"; |
481 | |
final static String BRANCH_NAME = "branchName"; |
482 | |
final static String NEXT_DOCUMENT_STATUS = "nextDocumentStatus"; |
483 | |
final static String CONFIGURATION_PARAMETERS = "configurationParameters"; |
484 | |
final static String CONFIGURATION_PARAMETER = "configurationParameter"; |
485 | |
final static String PREVIOUS_NODE_IDS = "previousNodeIds"; |
486 | |
final static String PREVIOUS_NODE_ID = "previousNodeId"; |
487 | |
final static String NEXT_NODE_IDS = "nextNodeIds"; |
488 | |
final static String NEXT_NODE_ID = "nextNodeId"; |
489 | |
} |
490 | |
|
491 | |
} |