1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.api.document.node;
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
24 import javax.xml.bind.annotation.XmlAccessType;
25 import javax.xml.bind.annotation.XmlAccessorType;
26 import javax.xml.bind.annotation.XmlAnyElement;
27 import javax.xml.bind.annotation.XmlElement;
28 import javax.xml.bind.annotation.XmlElementWrapper;
29 import javax.xml.bind.annotation.XmlRootElement;
30 import javax.xml.bind.annotation.XmlType;
31
32 import org.kuali.rice.core.api.CoreConstants;
33 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
34 import org.kuali.rice.core.api.mo.ModelBuilder;
35 import org.w3c.dom.Element;
36
37 @XmlRootElement(name = RouteNodeInstance.Constants.ROOT_ELEMENT_NAME)
38 @XmlAccessorType(XmlAccessType.NONE)
39 @XmlType(name = RouteNodeInstance.Constants.TYPE_NAME, propOrder = {
40 RouteNodeInstance.Elements.ID,
41 RouteNodeInstance.Elements.NAME,
42 RouteNodeInstance.Elements.STATE,
43 RouteNodeInstance.Elements.DOCUMENT_ID,
44 RouteNodeInstance.Elements.BRANCH_ID,
45 RouteNodeInstance.Elements.ROUTE_NODE_ID,
46 RouteNodeInstance.Elements.PROCESS_ID,
47 RouteNodeInstance.Elements.ACTIVE,
48 RouteNodeInstance.Elements.COMPLETE,
49 RouteNodeInstance.Elements.INITIAL,
50 RouteNodeInstance.Elements.NEXT_NODE_INSTANCES,
51 CoreConstants.CommonElements.FUTURE_ELEMENTS
52 })
53 public final class RouteNodeInstance extends AbstractDataTransferObject
54 implements RouteNodeInstanceContract
55 {
56
57 @XmlElement(name = Elements.NAME, required = false)
58 private final String name;
59
60 @XmlElementWrapper(name = Elements.STATE, required = false)
61 @XmlElement(name = Elements.ROUTE_NODE_INSTANCE_STATE, required = false)
62 private final List<RouteNodeInstanceState> state;
63
64 @XmlElement(name = Elements.DOCUMENT_ID, required = false)
65 private final String documentId;
66
67 @XmlElement(name = Elements.BRANCH_ID, required = false)
68 private final String branchId;
69
70 @XmlElement(name = Elements.ROUTE_NODE_ID, required = false)
71 private final String routeNodeId;
72
73 @XmlElement(name = Elements.PROCESS_ID, required = false)
74 private final String processId;
75
76 @XmlElement(name = Elements.ACTIVE, required = false)
77 private final boolean active;
78
79 @XmlElement(name = Elements.COMPLETE, required = false)
80 private final boolean complete;
81
82 @XmlElement(name = Elements.INITIAL, required = false)
83 private final boolean initial;
84
85 @XmlElement(name = Elements.ID, required = false)
86 private final String id;
87
88 @XmlElementWrapper(name = Elements.NEXT_NODE_INSTANCES, required = false)
89 @XmlElement(name = Elements.NEXT_NODE_INSTANCE, required = false)
90 private final List<RouteNodeInstance> nextNodeInstances;
91
92 @SuppressWarnings("unused")
93 @XmlAnyElement
94 private final Collection<Element> _futureElements = null;
95
96
97
98
99
100 private RouteNodeInstance() {
101 this.name = null;
102 this.state = null;
103 this.documentId = null;
104 this.branchId = null;
105 this.routeNodeId = null;
106 this.processId = null;
107 this.active = false;
108 this.complete = false;
109 this.initial = false;
110 this.id = null;
111 this.nextNodeInstances = null;
112 }
113
114 private RouteNodeInstance(Builder builder) {
115 this.name = builder.getName();
116 if (builder.getState() != null) {
117 List<RouteNodeInstanceState> states = new ArrayList<RouteNodeInstanceState>();
118 for(RouteNodeInstanceState.Builder stateBuilder : builder.getState()) {
119 states.add(stateBuilder.build());
120 }
121 this.state = states;
122 } else {
123 this.state = Collections.emptyList();
124 }
125
126 if (builder.getNextNodeInstances() != null) {
127 List<RouteNodeInstance> nextInstances = new ArrayList<RouteNodeInstance>();
128 for (RouteNodeInstance.Builder instance : builder.getNextNodeInstances()) {
129 nextInstances.add(instance.build());
130 }
131 this.nextNodeInstances = nextInstances;
132 } else {
133 this.nextNodeInstances = Collections.emptyList();
134 }
135
136
137 this.documentId = builder.getDocumentId();
138 this.branchId = builder.getBranchId();
139 this.routeNodeId = builder.getRouteNodeId();
140 this.processId = builder.getProcessId();
141 this.active = builder.isActive();
142 this.complete = builder.isComplete();
143 this.initial = builder.isInitial();
144 this.id = builder.getId();
145 }
146
147 @Override
148 public String getName() {
149 return this.name;
150 }
151
152 @Override
153 public List<RouteNodeInstanceState> getState() {
154 return this.state;
155 }
156
157 @Override
158 public String getDocumentId() {
159 return this.documentId;
160 }
161
162 @Override
163 public String getBranchId() {
164 return this.branchId;
165 }
166
167 @Override
168 public String getRouteNodeId() {
169 return this.routeNodeId;
170 }
171
172 @Override
173 public String getProcessId() {
174 return this.processId;
175 }
176
177 @Override
178 public boolean isActive() {
179 return this.active;
180 }
181
182 @Override
183 public boolean isComplete() {
184 return this.complete;
185 }
186
187 @Override
188 public boolean isInitial() {
189 return this.initial;
190 }
191
192 @Override
193 public String getId() {
194 return this.id;
195 }
196
197 @Override
198 public List<RouteNodeInstance> getNextNodeInstances() {
199 return this.nextNodeInstances;
200 }
201
202
203
204
205
206
207 public final static class Builder
208 implements Serializable, ModelBuilder, RouteNodeInstanceContract
209 {
210
211 private String name;
212 private List<RouteNodeInstanceState.Builder> state;
213 private String documentId;
214 private String branchId;
215 private String routeNodeId;
216 private String processId;
217 private boolean active;
218 private boolean complete;
219 private boolean initial;
220 private String id;
221 private List<RouteNodeInstance.Builder> nextNodeInstances;
222
223 private Builder() {
224
225 }
226
227 public static Builder create() {
228
229 return new Builder();
230 }
231
232 public static Builder create(RouteNodeInstanceContract contract) {
233 if (contract == null) {
234 throw new IllegalArgumentException("contract was null");
235 }
236
237 Builder builder = create();
238 builder.setName(contract.getName());
239 if (contract.getState() != null) {
240 List<RouteNodeInstanceState.Builder> stateBuilders = new ArrayList<RouteNodeInstanceState.Builder>();
241 for (RouteNodeInstanceStateContract stateContract : contract.getState()) {
242 stateBuilders.add(RouteNodeInstanceState.Builder.create(stateContract));
243 }
244 builder.setState(stateBuilders);
245 }
246
247 builder.setDocumentId(contract.getDocumentId());
248 builder.setBranchId(contract.getBranchId());
249 builder.setRouteNodeId(contract.getRouteNodeId());
250 builder.setProcessId(contract.getProcessId());
251 builder.setActive(contract.isActive());
252 builder.setComplete(contract.isComplete());
253 builder.setInitial(contract.isInitial());
254 builder.setId(contract.getId());
255 if (contract.getNextNodeInstances() != null) {
256 List<RouteNodeInstance.Builder> instanceBuilders = new ArrayList<RouteNodeInstance.Builder>();
257 for(RouteNodeInstanceContract instanceContract : contract.getNextNodeInstances()) {
258 instanceBuilders.add(RouteNodeInstance.Builder.create(instanceContract));
259 }
260 builder.setNextNodeInstances(instanceBuilders);
261 }
262 return builder;
263 }
264
265 public RouteNodeInstance build() {
266 return new RouteNodeInstance(this);
267 }
268
269 @Override
270 public String getName() {
271 return this.name;
272 }
273
274 @Override
275 public List<RouteNodeInstanceState.Builder> getState() {
276 return this.state;
277 }
278
279 @Override
280 public String getDocumentId() {
281 return this.documentId;
282 }
283
284 @Override
285 public String getBranchId() {
286 return this.branchId;
287 }
288
289 @Override
290 public String getRouteNodeId() {
291 return this.routeNodeId;
292 }
293
294 @Override
295 public String getProcessId() {
296 return this.processId;
297 }
298
299 @Override
300 public boolean isActive() {
301 return this.active;
302 }
303
304 @Override
305 public boolean isComplete() {
306 return this.complete;
307 }
308
309 @Override
310 public boolean isInitial() {
311 return this.initial;
312 }
313
314 @Override
315 public String getId() {
316 return this.id;
317 }
318
319 @Override
320 public List<RouteNodeInstance.Builder> getNextNodeInstances() {
321 return this.nextNodeInstances;
322 }
323
324 public void setNextNodeInstances(List<RouteNodeInstance.Builder> nextNodeInstances) {
325
326 this.nextNodeInstances = Collections.unmodifiableList(nextNodeInstances);
327 }
328
329 public void setName(String name) {
330
331 this.name = name;
332 }
333
334 public void setState(List<RouteNodeInstanceState.Builder> state) {
335
336 this.state = state;
337 }
338
339 public void setDocumentId(String documentId) {
340
341 this.documentId = documentId;
342 }
343
344 public void setBranchId(String branchId) {
345
346 this.branchId = branchId;
347 }
348
349 public void setRouteNodeId(String routeNodeId) {
350
351 this.routeNodeId = routeNodeId;
352 }
353
354 public void setProcessId(String processId) {
355
356 this.processId = processId;
357 }
358
359 public void setActive(boolean active) {
360
361 this.active = active;
362 }
363
364 public void setComplete(boolean complete) {
365
366 this.complete = complete;
367 }
368
369 public void setInitial(boolean initial) {
370
371 this.initial = initial;
372 }
373
374 public void setId(String id) {
375
376 this.id = id;
377 }
378
379 }
380
381
382
383
384
385
386 static class Constants {
387
388 final static String ROOT_ELEMENT_NAME = "routeNodeInstance";
389 final static String TYPE_NAME = "RouteNodeInstanceType";
390 }
391
392
393
394
395
396
397 static class Elements {
398
399 final static String NAME = "name";
400 final static String STATE = "state";
401 final static String ROUTE_NODE_INSTANCE_STATE = "routeNodeInstanceState";
402 final static String DOCUMENT_ID = "documentId";
403 final static String BRANCH_ID = "branchId";
404 final static String ROUTE_NODE_ID = "routeNodeId";
405 final static String PROCESS_ID = "processId";
406 final static String ACTIVE = "active";
407 final static String COMPLETE = "complete";
408 final static String INITIAL = "initial";
409 final static String ID = "id";
410 final static String NEXT_NODE_INSTANCES = "nextNodeInstances";
411 final static String NEXT_NODE_INSTANCE = "nextNodeInstance";
412 }
413
414 }