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