1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.engine.node.hierarchyrouting; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.apache.log4j.Logger; |
20 | |
import org.kuali.rice.core.api.reflect.ObjectDefinition; |
21 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
22 | |
import org.kuali.rice.kew.api.WorkflowRuntimeException; |
23 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
24 | |
import org.kuali.rice.kew.engine.RouteContext; |
25 | |
import org.kuali.rice.kew.engine.RouteHelper; |
26 | |
import org.kuali.rice.kew.engine.node.DynamicNode; |
27 | |
import org.kuali.rice.kew.engine.node.DynamicResult; |
28 | |
import org.kuali.rice.kew.engine.node.NoOpNode; |
29 | |
import org.kuali.rice.kew.engine.node.NodeState; |
30 | |
import org.kuali.rice.kew.engine.node.ProcessDefinitionBo; |
31 | |
import org.kuali.rice.kew.engine.node.RequestsNode; |
32 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
33 | |
import org.kuali.rice.kew.engine.node.RouteNodeInstance; |
34 | |
import org.kuali.rice.kew.engine.node.SimpleJoinNode; |
35 | |
import org.kuali.rice.kew.engine.node.SimpleSplitNode; |
36 | |
import org.kuali.rice.kew.engine.node.hierarchyrouting.HierarchyProvider.Stop; |
37 | |
import org.kuali.rice.kew.engine.transition.SplitTransitionEngine; |
38 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
39 | |
import org.kuali.rice.kew.util.Utilities; |
40 | |
|
41 | |
import javax.xml.XMLConstants; |
42 | |
import javax.xml.namespace.QName; |
43 | |
import java.util.ArrayList; |
44 | |
import java.util.Arrays; |
45 | |
import java.util.Collection; |
46 | |
import java.util.HashMap; |
47 | |
import java.util.Iterator; |
48 | |
import java.util.List; |
49 | |
import java.util.Map; |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | 0 | public class HierarchyRoutingNode implements DynamicNode { |
57 | 0 | protected final Logger LOG = Logger.getLogger(getClass()); |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
public static final String HIERARCHY_PROVIDER = "hierarchyProvider"; |
63 | |
|
64 | |
|
65 | |
|
66 | |
public static final String STOP_ID = "stop_id"; |
67 | |
|
68 | |
protected static final String SPLIT_PROCESS_NAME = "Hierarchy Split"; |
69 | |
protected static final String JOIN_PROCESS_NAME = "Hierarchy Join"; |
70 | |
protected static final String REQUEST_PROCESS_NAME = "Hierarchy Request"; |
71 | |
protected static final String NO_STOP_NAME = "No stop"; |
72 | |
|
73 | |
|
74 | |
private static final String VISITED_STOPS = "visited_stops"; |
75 | |
private static final String V_STOPS_DEL = ","; |
76 | |
|
77 | |
private static final String INITIAL_SPLIT_NODE_MARKER = "InitialSplitNode"; |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
protected HierarchyProvider getHierarchyProvider(RouteNodeInstance nodeInstance, RouteContext context) { |
86 | 0 | Map<String, String> cfgMap = Utilities.getKeyValueCollectionAsMap(nodeInstance.getRouteNode().getConfigParams()); |
87 | 0 | String hierarchyProviderClass = cfgMap.get(HIERARCHY_PROVIDER); |
88 | 0 | if (StringUtils.isEmpty(hierarchyProviderClass)) { |
89 | 0 | throw new WorkflowRuntimeException("hierarchyProvider configuration parameter not set for HierarchyRoutingNode: " + nodeInstance.getName()); |
90 | |
} |
91 | 0 | QName qn = QName.valueOf(hierarchyProviderClass); |
92 | |
ObjectDefinition od; |
93 | 0 | if (XMLConstants.NULL_NS_URI.equals(qn.getNamespaceURI())) { |
94 | 0 | od = new ObjectDefinition(qn.getLocalPart()); |
95 | |
} else { |
96 | 0 | od = new ObjectDefinition(qn.getLocalPart(), qn.getNamespaceURI()); |
97 | |
} |
98 | 0 | HierarchyProvider hp = (HierarchyProvider) GlobalResourceLoader.getObject(od); |
99 | 0 | hp.init(nodeInstance, context); |
100 | 0 | return hp; |
101 | |
} |
102 | |
|
103 | |
public DynamicResult transitioningInto(RouteContext context, RouteNodeInstance dynamicNodeInstance, RouteHelper helper) throws Exception { |
104 | |
|
105 | 0 | HierarchyProvider provider = getHierarchyProvider(dynamicNodeInstance, context); |
106 | 0 | DocumentType documentType = setUpDocumentType(provider, context.getDocument().getDocumentType(), dynamicNodeInstance); |
107 | 0 | RouteNode splitNode = documentType.getNamedProcess(SPLIT_PROCESS_NAME).getInitialRouteNode(); |
108 | |
|
109 | |
|
110 | 0 | RouteNodeInstance splitNodeInstance = helper.getNodeFactory().createRouteNodeInstance(context.getDocument().getDocumentId(), splitNode); |
111 | 0 | splitNodeInstance.setBranch(dynamicNodeInstance.getBranch()); |
112 | 0 | markAsInitialSplitNode(splitNodeInstance); |
113 | |
|
114 | 0 | int i = 0; |
115 | 0 | List<Stop> stops = provider.getLeafStops(context); |
116 | 0 | if (stops.isEmpty()) { |
117 | |
|
118 | 0 | RouteNode noStopNode = documentType.getNamedProcess(NO_STOP_NAME).getInitialRouteNode(); |
119 | 0 | RouteNodeInstance noChartOrgInstance = helper.getNodeFactory().createRouteNodeInstance(context.getDocument().getDocumentId(), noStopNode); |
120 | 0 | noChartOrgInstance.setBranch(dynamicNodeInstance.getBranch()); |
121 | |
|
122 | 0 | provider.setStop(noChartOrgInstance, null); |
123 | |
|
124 | 0 | return new DynamicResult(true, noChartOrgInstance); |
125 | |
} |
126 | 0 | for (Stop stop: stops) { |
127 | 0 | RouteNode requestNode = getStopRequestNode(stop, documentType); |
128 | 0 | createInitialRequestNodeInstance(provider, stop, splitNodeInstance, dynamicNodeInstance, requestNode); |
129 | 0 | } |
130 | |
|
131 | 0 | return new DynamicResult(false, splitNodeInstance); |
132 | |
} |
133 | |
|
134 | |
public DynamicResult transitioningOutOf(RouteContext context, RouteHelper helper) throws Exception { |
135 | |
|
136 | |
|
137 | 0 | HierarchyProvider provider = getHierarchyProvider(context.getNodeInstance().getProcess(), context); |
138 | |
|
139 | 0 | RouteNodeInstance processInstance = context.getNodeInstance().getProcess(); |
140 | 0 | RouteNodeInstance curStopNode = context.getNodeInstance(); |
141 | 0 | Map<String, RouteNodeInstance> stopRequestNodeMap = new HashMap<String, RouteNodeInstance>(); |
142 | 0 | findStopRequestNodes(provider, context, stopRequestNodeMap); |
143 | |
|
144 | 0 | Stop stop = provider.getStop(curStopNode); |
145 | |
|
146 | 0 | if (provider.isRoot(stop)) { |
147 | 0 | return new DynamicResult(true, null); |
148 | |
} |
149 | |
|
150 | |
|
151 | |
|
152 | 0 | InnerTransitionResult transition = canTransitionFrom(provider, stop, stopRequestNodeMap.values(), helper); |
153 | 0 | DynamicResult result = null; |
154 | 0 | if (transition.isCanTransition()) { |
155 | 0 | DocumentType documentType = context.getDocument().getDocumentType(); |
156 | |
|
157 | 0 | RouteNodeInstance requestNode = createNextStopRequestNodeInstance(provider, context, stop, processInstance, helper); |
158 | |
|
159 | 0 | if (transition.getSiblings().isEmpty()) { |
160 | 0 | result = new DynamicResult(false, requestNode); |
161 | |
} else { |
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
} |
187 | |
|
188 | 0 | } else { |
189 | 0 | result = new DynamicResult(false, null); |
190 | |
} |
191 | 0 | result.getNextNodeInstances().addAll(getNewlyAddedOrgRouteInstances(provider, context, helper)); |
192 | 0 | return result; |
193 | |
} |
194 | |
|
195 | |
private void findStopRequestNodes(HierarchyProvider provider, RouteContext context, Map<String, RouteNodeInstance> stopRequestNodes) { |
196 | 0 | List<RouteNodeInstance> nodeInstances = KEWServiceLocator.getRouteNodeService().getFlattenedNodeInstances(context.getDocument(), true); |
197 | 0 | for (RouteNodeInstance nodeInstance: nodeInstances) { |
198 | 0 | if (provider.hasStop(nodeInstance)) { |
199 | 0 | LOG.debug("Stop node instance: " + nodeInstance); |
200 | 0 | stopRequestNodes.put(nodeInstance.getRouteNodeInstanceId(), nodeInstance); |
201 | |
} |
202 | |
} |
203 | |
|
204 | 0 | } |
205 | |
|
206 | |
private RouteNodeInstance createNextStopRequestNodeInstance(HierarchyProvider provider, RouteContext context, Stop stop, RouteNodeInstance processInstance, RouteHelper helper) { |
207 | 0 | Stop futureStop = provider.getParent(stop); |
208 | 0 | LOG.debug("Creating next stop request node instance " + provider.getStopIdentifier(futureStop) + " as parent of " + provider.getStopIdentifier(stop)); |
209 | 0 | RouteNode requestsPrototype = getStopRequestNode(futureStop, context.getDocument().getDocumentType()); |
210 | 0 | RouteNodeInstance requestNode = helper.getNodeFactory().createRouteNodeInstance(context.getDocument().getDocumentId(), requestsPrototype); |
211 | 0 | requestNode.setBranch(processInstance.getBranch()); |
212 | 0 | NodeState ns = new NodeState(); |
213 | 0 | ns.setKey(STOP_ID); |
214 | 0 | ns.setValue(provider.getStopIdentifier(futureStop)); |
215 | 0 | requestNode.addNodeState(ns); |
216 | 0 | provider.setStop(requestNode, futureStop); |
217 | 0 | LOG.debug("Stop set on request node: " + provider.getStop(requestNode)); |
218 | 0 | addStopToProcessState(provider, processInstance, futureStop); |
219 | 0 | return requestNode; |
220 | |
} |
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
private InnerTransitionResult canTransitionFrom(HierarchyProvider provider, Stop currentStop, Collection<RouteNodeInstance> requestNodes, RouteHelper helper) { |
230 | 0 | LOG.debug("Testing whether we can transition from stop: " + currentStop); |
231 | 0 | Stop parent = provider.getParent(currentStop); |
232 | 0 | InnerTransitionResult result = new InnerTransitionResult(); |
233 | 0 | result.setCanTransition(false); |
234 | |
|
235 | 0 | for (RouteNodeInstance requestNode: requestNodes) { |
236 | 0 | if (!provider.hasStop(requestNode)) { |
237 | 0 | LOG.debug("request node " + requestNode.getName() + " does not have a stop associated with it"); |
238 | 0 | continue; |
239 | |
} |
240 | |
|
241 | 0 | Stop requestNodeStop = provider.getStop(requestNode); |
242 | 0 | LOG.debug("Request node: " + requestNode.getRouteNodeInstanceId() + " has stop " + requestNodeStop.toString()); |
243 | 0 | if (requestNodeStop != null && provider.equals(currentStop, requestNodeStop)) { |
244 | 0 | LOG.debug("Skipping node " + requestNode.getName() + " because it is associated with the current stop"); |
245 | 0 | continue; |
246 | |
} |
247 | |
|
248 | |
|
249 | 0 | Stop stop = provider.getStop(requestNode); |
250 | |
|
251 | 0 | LOG.debug("Found an outstanding stop: " + stop); |
252 | |
|
253 | 0 | boolean isChildOfMyParent = isDescendent(provider, parent, stop); |
254 | |
|
255 | 0 | if (isChildOfMyParent) { |
256 | 0 | LOG.debug("Found stop node whose parent is my parent:"); |
257 | 0 | LOG.debug("Stop: " + stop); |
258 | 0 | LOG.debug("Node: " + requestNode); |
259 | |
|
260 | |
|
261 | 0 | if (requestNode.isActive()) { |
262 | |
|
263 | 0 | result.getSiblings().clear(); |
264 | 0 | return result; |
265 | |
} |
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
} |
275 | 0 | } |
276 | 0 | result.setCanTransition(true); |
277 | 0 | return result; |
278 | |
} |
279 | |
|
280 | |
protected boolean isDescendent(HierarchyProvider provider, Stop parent, Stop otherStop) { |
281 | 0 | return provider.isRoot(parent) || hasAsParent(provider, parent, otherStop); |
282 | |
} |
283 | |
|
284 | 0 | private static class InnerTransitionResult { |
285 | |
private boolean canTransition; |
286 | 0 | private List<RouteNodeInstance> siblings = new ArrayList<RouteNodeInstance>(); |
287 | |
|
288 | |
public boolean isCanTransition() { |
289 | 0 | return canTransition; |
290 | |
} |
291 | |
|
292 | |
public void setCanTransition(boolean canTransition) { |
293 | 0 | this.canTransition = canTransition; |
294 | 0 | } |
295 | |
|
296 | |
public List<RouteNodeInstance> getSiblings() { |
297 | 0 | return siblings; |
298 | |
} |
299 | |
|
300 | |
public void setSiblings(List<RouteNodeInstance> siblings) { |
301 | 0 | this.siblings = siblings; |
302 | 0 | } |
303 | |
} |
304 | |
|
305 | |
private static void markAsInitialSplitNode(RouteNodeInstance splitNode) { |
306 | 0 | NodeState ns = new NodeState(); |
307 | 0 | ns.setKey(INITIAL_SPLIT_NODE_MARKER); |
308 | 0 | ns.setValue(INITIAL_SPLIT_NODE_MARKER); |
309 | |
|
310 | 0 | splitNode.addNodeState(ns); |
311 | 0 | } |
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
private static boolean isInitialSplitNode(RouteNodeInstance routeNodeInstance) { |
318 | 0 | return routeNodeInstance.getNodeState(INITIAL_SPLIT_NODE_MARKER) != null; |
319 | |
} |
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
private void addStopToProcessState(HierarchyProvider provider, RouteNodeInstance processInstance, Stop stop) { |
327 | 0 | String stopStateName = provider.getStopIdentifier(stop); |
328 | 0 | NodeState visitedStopsState = processInstance.getNodeState(VISITED_STOPS); |
329 | 0 | if (visitedStopsState == null) { |
330 | 0 | NodeState ns = new NodeState(); |
331 | 0 | ns.setKey(VISITED_STOPS); |
332 | 0 | ns.setValue(stopStateName + V_STOPS_DEL); |
333 | |
|
334 | 0 | processInstance.addNodeState(ns); |
335 | 0 | } else if (! getVisitedStopsList(processInstance).contains(stopStateName)) { |
336 | 0 | visitedStopsState.setValue(visitedStopsState.getValue() + stopStateName + V_STOPS_DEL); |
337 | |
} |
338 | 0 | } |
339 | |
|
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
private static List<String> getVisitedStopsList(RouteNodeInstance process) { |
345 | 0 | return Arrays.asList(process.getNodeState(VISITED_STOPS).getValue().split(V_STOPS_DEL)); |
346 | |
} |
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
|
352 | |
|
353 | |
|
354 | |
private boolean isNewStop(HierarchyProvider provider, Stop stop, RouteNodeInstance process) { |
355 | |
|
356 | 0 | String orgStateName = provider.getStopIdentifier(stop); |
357 | 0 | List<String> visitedOrgs = getVisitedStopsList(process); |
358 | 0 | boolean isInVisitedList = visitedOrgs.contains(orgStateName); |
359 | 0 | if (isInVisitedList) { |
360 | 0 | return false; |
361 | |
} |
362 | 0 | boolean willEventualRouteThere = false; |
363 | |
|
364 | 0 | for (Iterator<String> iter = visitedOrgs.iterator(); iter.hasNext() && willEventualRouteThere == false; ) { |
365 | 0 | String visitedStopStateName = iter.next(); |
366 | 0 | Stop visitedStop = provider.getStopByIdentifier(visitedStopStateName); |
367 | 0 | willEventualRouteThere = hasAsParent(provider, stop, visitedStop) || willEventualRouteThere; |
368 | 0 | } |
369 | 0 | return ! willEventualRouteThere; |
370 | |
} |
371 | |
|
372 | |
|
373 | |
|
374 | |
|
375 | |
|
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
private RouteNodeInstance createInitialRequestNodeInstance(HierarchyProvider provider, Stop stop, RouteNodeInstance splitNodeInstance, RouteNodeInstance processInstance, RouteNode requestsNode) { |
382 | 0 | String branchName = "Branch " + provider.getStopIdentifier(stop); |
383 | 0 | RouteNodeInstance orgRequestInstance = SplitTransitionEngine.createSplitChild(branchName, requestsNode, splitNodeInstance); |
384 | 0 | splitNodeInstance.addNextNodeInstance(orgRequestInstance); |
385 | 0 | NodeState ns = new NodeState(); |
386 | 0 | ns.setKey(STOP_ID); |
387 | 0 | ns.setValue(provider.getStopIdentifier(stop)); |
388 | |
|
389 | 0 | orgRequestInstance.addNodeState(ns); |
390 | 0 | provider.setStop(orgRequestInstance, stop); |
391 | 0 | addStopToProcessState(provider, processInstance, stop); |
392 | 0 | return orgRequestInstance; |
393 | |
} |
394 | |
|
395 | |
|
396 | |
|
397 | |
|
398 | |
|
399 | |
|
400 | |
|
401 | |
|
402 | |
private List<RouteNodeInstance> getNewlyAddedOrgRouteInstances(HierarchyProvider provider, RouteContext context, RouteHelper helper) throws Exception { |
403 | 0 | RouteNodeInstance processInstance = context.getNodeInstance().getProcess(); |
404 | 0 | RouteNodeInstance chartOrgNode = context.getNodeInstance(); |
405 | |
|
406 | 0 | List<Stop> stops = provider.getLeafStops(context); |
407 | 0 | List<RouteNodeInstance> newStopsRoutingTo = new ArrayList<RouteNodeInstance>(); |
408 | 0 | for (Stop stop: stops) { |
409 | 0 | if (isNewStop(provider, stop, processInstance)) { |
410 | |
|
411 | 0 | List<RouteNodeInstance> processNodes = chartOrgNode.getPreviousNodeInstances(); |
412 | 0 | for (RouteNodeInstance splitNodeInstance: processNodes) { |
413 | 0 | if (isInitialSplitNode(splitNodeInstance)) { |
414 | 0 | RouteNode requestsNode = getStopRequestNode(stop, context.getDocument().getDocumentType()); |
415 | 0 | RouteNodeInstance newOrgRequestNode = createInitialRequestNodeInstance(provider, stop, splitNodeInstance, processInstance, requestsNode); |
416 | 0 | newStopsRoutingTo.add(newOrgRequestNode); |
417 | 0 | } |
418 | |
} |
419 | 0 | } |
420 | |
} |
421 | 0 | return newStopsRoutingTo; |
422 | |
} |
423 | |
|
424 | |
|
425 | |
|
426 | |
|
427 | |
|
428 | |
|
429 | |
private boolean hasAsParent(HierarchyProvider provider, Stop parent, Stop child) { |
430 | 0 | if (provider.isRoot(child)) { |
431 | 0 | return false; |
432 | 0 | } else if (provider.equals(parent, child)) { |
433 | 0 | return true; |
434 | |
} else { |
435 | 0 | child = provider.getParent(child); |
436 | 0 | return hasAsParent(provider, parent, child); |
437 | |
} |
438 | |
} |
439 | |
|
440 | |
|
441 | |
|
442 | |
|
443 | |
|
444 | |
|
445 | |
|
446 | |
|
447 | |
private DocumentType setUpDocumentType(HierarchyProvider provider, DocumentType documentType, RouteNodeInstance dynamicNodeInstance) { |
448 | 0 | boolean altered = false; |
449 | 0 | if (documentType.getNamedProcess(SPLIT_PROCESS_NAME) == null) { |
450 | 0 | RouteNode splitNode = getSplitNode(dynamicNodeInstance); |
451 | 0 | documentType.addProcess(getPrototypeProcess(splitNode, documentType)); |
452 | 0 | altered = true; |
453 | |
} |
454 | 0 | if (documentType.getNamedProcess(JOIN_PROCESS_NAME) == null) { |
455 | 0 | RouteNode joinNode = getJoinNode(dynamicNodeInstance); |
456 | 0 | documentType.addProcess(getPrototypeProcess(joinNode, documentType)); |
457 | 0 | altered = true; |
458 | |
} |
459 | 0 | if (documentType.getNamedProcess(REQUEST_PROCESS_NAME) == null) { |
460 | 0 | RouteNode requestsNode = getRequestNode(provider, dynamicNodeInstance); |
461 | 0 | documentType.addProcess(getPrototypeProcess(requestsNode, documentType)); |
462 | 0 | altered = true; |
463 | |
} |
464 | 0 | if (documentType.getNamedProcess(NO_STOP_NAME) == null) { |
465 | 0 | RouteNode noChartOrgNode = getNoChartOrgNode(dynamicNodeInstance); |
466 | 0 | documentType.addProcess(getPrototypeProcess(noChartOrgNode, documentType)); |
467 | 0 | altered = true; |
468 | |
} |
469 | 0 | if (altered) { |
470 | |
|
471 | 0 | KEWServiceLocator.getDocumentTypeService().save(documentType); |
472 | |
} |
473 | 0 | return KEWServiceLocator.getDocumentTypeService().findByName(documentType.getName()); |
474 | |
} |
475 | |
|
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
protected ProcessDefinitionBo getPrototypeProcess(RouteNode node, DocumentType documentType) { |
484 | 0 | ProcessDefinitionBo process = new ProcessDefinitionBo(); |
485 | 0 | process.setDocumentType(documentType); |
486 | 0 | process.setInitial(false); |
487 | 0 | process.setInitialRouteNode(node); |
488 | 0 | process.setName(node.getRouteNodeName()); |
489 | 0 | return process; |
490 | |
} |
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
private static RouteNode getSplitNode(RouteNodeInstance process) { |
497 | 0 | RouteNode dynamicNode = process.getRouteNode(); |
498 | 0 | RouteNode splitNode = new RouteNode(); |
499 | 0 | splitNode.setActivationType(dynamicNode.getActivationType()); |
500 | 0 | splitNode.setDocumentType(dynamicNode.getDocumentType()); |
501 | 0 | splitNode.setFinalApprovalInd(dynamicNode.getFinalApprovalInd()); |
502 | 0 | splitNode.setExceptionWorkgroupId(dynamicNode.getExceptionWorkgroupId()); |
503 | 0 | splitNode.setMandatoryRouteInd(dynamicNode.getMandatoryRouteInd()); |
504 | 0 | splitNode.setNodeType(SimpleSplitNode.class.getName()); |
505 | 0 | splitNode.setRouteMethodCode("FR"); |
506 | 0 | splitNode.setRouteMethodName(null); |
507 | 0 | splitNode.setRouteNodeName(SPLIT_PROCESS_NAME); |
508 | 0 | return splitNode; |
509 | |
|
510 | |
} |
511 | |
|
512 | |
|
513 | |
|
514 | |
|
515 | |
|
516 | |
private static RouteNode getJoinNode(RouteNodeInstance process) { |
517 | 0 | RouteNode dynamicNode = process.getRouteNode(); |
518 | 0 | RouteNode joinNode = new RouteNode(); |
519 | 0 | joinNode.setActivationType(dynamicNode.getActivationType()); |
520 | 0 | joinNode.setDocumentType(dynamicNode.getDocumentType()); |
521 | 0 | joinNode.setFinalApprovalInd(dynamicNode.getFinalApprovalInd()); |
522 | 0 | joinNode.setExceptionWorkgroupId(dynamicNode.getExceptionWorkgroupId()); |
523 | 0 | joinNode.setMandatoryRouteInd(dynamicNode.getMandatoryRouteInd()); |
524 | 0 | joinNode.setNodeType(SimpleJoinNode.class.getName()); |
525 | 0 | joinNode.setRouteMethodCode("FR"); |
526 | 0 | joinNode.setRouteMethodName(null); |
527 | 0 | joinNode.setRouteNodeName(JOIN_PROCESS_NAME); |
528 | 0 | return joinNode; |
529 | |
} |
530 | |
|
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
private RouteNode getRequestNode(HierarchyProvider provider, RouteNodeInstance process) { |
536 | 0 | RouteNode dynamicNode = process.getRouteNode(); |
537 | 0 | RouteNode requestsNode = new RouteNode(); |
538 | 0 | requestsNode.setActivationType(dynamicNode.getActivationType()); |
539 | 0 | requestsNode.setDocumentType(dynamicNode.getDocumentType()); |
540 | 0 | requestsNode.setFinalApprovalInd(dynamicNode.getFinalApprovalInd()); |
541 | 0 | requestsNode.setExceptionWorkgroupId(dynamicNode.getExceptionWorkgroupId()); |
542 | 0 | requestsNode.setMandatoryRouteInd(dynamicNode.getMandatoryRouteInd()); |
543 | 0 | requestsNode.setNodeType(RequestsNode.class.getName()); |
544 | 0 | requestsNode.setRouteMethodCode("FR"); |
545 | 0 | requestsNode.setRouteMethodName(process.getRouteNode().getRouteMethodName()); |
546 | 0 | requestsNode.setRouteNodeName(REQUEST_PROCESS_NAME); |
547 | 0 | provider.configureRequestNode(process, requestsNode); |
548 | 0 | return requestsNode; |
549 | |
} |
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
private static RouteNode getNoChartOrgNode(RouteNodeInstance process) { |
556 | 0 | RouteNode dynamicNode = process.getRouteNode(); |
557 | 0 | RouteNode noChartOrgNOde = new RouteNode(); |
558 | 0 | noChartOrgNOde.setActivationType(dynamicNode.getActivationType()); |
559 | 0 | noChartOrgNOde.setDocumentType(dynamicNode.getDocumentType()); |
560 | 0 | noChartOrgNOde.setFinalApprovalInd(dynamicNode.getFinalApprovalInd()); |
561 | 0 | noChartOrgNOde.setExceptionWorkgroupId(dynamicNode.getExceptionWorkgroupId()); |
562 | 0 | noChartOrgNOde.setMandatoryRouteInd(dynamicNode.getMandatoryRouteInd()); |
563 | 0 | noChartOrgNOde.setNodeType(NoOpNode.class.getName()); |
564 | 0 | noChartOrgNOde.setRouteMethodCode("FR"); |
565 | 0 | noChartOrgNOde.setRouteMethodName(null); |
566 | 0 | noChartOrgNOde.setRouteNodeName(NO_STOP_NAME); |
567 | 0 | return noChartOrgNOde; |
568 | |
} |
569 | |
|
570 | |
|
571 | |
|
572 | |
|
573 | |
|
574 | |
protected RouteNode getStopRequestNode(Stop stop, DocumentType documentType) { |
575 | 0 | return documentType.getNamedProcess(REQUEST_PROCESS_NAME).getInitialRouteNode(); |
576 | |
} |
577 | |
|
578 | |
} |