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