1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.engine.transition; |
17 | |
|
18 | |
import org.kuali.rice.kew.engine.RouteContext; |
19 | |
import org.kuali.rice.kew.engine.RouteHelper; |
20 | |
import org.kuali.rice.kew.engine.node.Node; |
21 | |
import org.kuali.rice.kew.engine.node.ProcessResult; |
22 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
23 | |
import org.kuali.rice.kew.engine.node.RouteNodeInstance; |
24 | |
|
25 | |
import java.util.ArrayList; |
26 | |
import java.util.List; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public abstract class TransitionEngine { |
36 | |
|
37 | |
private RouteHelper helper; |
38 | |
|
39 | |
public RouteNodeInstance transitionTo(RouteNodeInstance nextNodeInstance, RouteContext context) throws Exception { |
40 | 0 | return nextNodeInstance; |
41 | |
} |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
public abstract ProcessResult isComplete(RouteContext context) throws Exception; |
52 | |
|
53 | |
public Transition transitionFrom(RouteContext context, ProcessResult processResult) throws Exception { |
54 | 0 | return new Transition(resolveNextNodeInstances(context.getNodeInstance())); |
55 | |
} |
56 | |
|
57 | |
protected void setRouteHelper(RouteHelper helper) { |
58 | 0 | this.helper = helper; |
59 | 0 | } |
60 | |
|
61 | |
protected RouteHelper getRouteHelper() { |
62 | 0 | return helper; |
63 | |
} |
64 | |
|
65 | |
protected Node getNode(RouteNode routeNode, Class nodeClass) throws Exception { |
66 | 0 | return helper.getNode(routeNode); |
67 | |
} |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
protected List<RouteNodeInstance> resolveNextNodeInstances(RouteNodeInstance nodeInstance, List<RouteNode> nextRouteNodes) { |
78 | 0 | List<RouteNodeInstance> nextNodeInstances = new ArrayList<RouteNodeInstance>(); |
79 | 0 | for (RouteNode nextRouteNode : nextRouteNodes) |
80 | |
{ |
81 | 0 | RouteNode nextNode = (RouteNode) nextRouteNode; |
82 | 0 | RouteNodeInstance nextNodeInstance = getRouteHelper().getNodeFactory().createRouteNodeInstance(nodeInstance.getDocumentId(), nextNode); |
83 | 0 | nextNodeInstance.setBranch(nodeInstance.getBranch()); |
84 | 0 | nextNodeInstance.setProcess(nodeInstance.getProcess()); |
85 | 0 | nextNodeInstances.add(nextNodeInstance); |
86 | 0 | } |
87 | 0 | return nextNodeInstances; |
88 | |
} |
89 | |
|
90 | |
protected List<RouteNodeInstance> resolveNextNodeInstances(RouteNodeInstance nodeInstance) { |
91 | 0 | return resolveNextNodeInstances(nodeInstance, nodeInstance.getRouteNode().getNextNodes()); |
92 | |
} |
93 | |
|
94 | |
} |