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