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.*; |
21 | |
|
22 | |
import java.util.ArrayList; |
23 | |
import java.util.List; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class SplitTransitionEngine extends TransitionEngine { |
34 | |
|
35 | |
public ProcessResult isComplete(RouteContext context) throws Exception { |
36 | 0 | SplitNode node = (SplitNode)getNode(context.getNodeInstance().getRouteNode(), SplitNode.class); |
37 | 0 | return node.process(context, getRouteHelper()); |
38 | |
} |
39 | |
|
40 | |
public Transition transitionFrom(RouteContext context, ProcessResult processResult) |
41 | |
throws Exception { |
42 | 0 | RouteNodeInstance splitInstance = context.getNodeInstance(); |
43 | 0 | List<RouteNodeInstance> nextNodeInstances = new ArrayList<RouteNodeInstance>(); |
44 | 0 | SplitResult result = (SplitResult)processResult; |
45 | 0 | for (String branchName : result.getBranchNames()) |
46 | |
{ |
47 | 0 | for (RouteNode routeNode : splitInstance.getRouteNode().getNextNodes()) |
48 | |
{ |
49 | 0 | if (routeNode.getBranch() != null && routeNode.getBranch().getName().equals(branchName)) |
50 | |
{ |
51 | 0 | nextNodeInstances.add(createSplitChild(branchName, routeNode, splitInstance)); |
52 | |
} |
53 | |
} |
54 | |
} |
55 | 0 | return new Transition(nextNodeInstances); |
56 | |
} |
57 | |
|
58 | |
public static RouteNodeInstance createSplitChild(String branchName, RouteNode routeNode, RouteNodeInstance splitInstance) { |
59 | 0 | RouteHelper routeHelper = new RouteHelper(); |
60 | 0 | RouteNodeInstance nextNodeInstance = routeHelper.getNodeFactory().createRouteNodeInstance(splitInstance.getDocumentId(), routeNode); |
61 | 0 | Branch branch = routeHelper.getNodeFactory().createBranch(branchName, splitInstance.getBranch(), nextNodeInstance); |
62 | 0 | branch.setSplitNode(splitInstance); |
63 | 0 | nextNodeInstance.setBranch(branch); |
64 | 0 | nextNodeInstance.setProcess(splitInstance.getProcess()); |
65 | 0 | return nextNodeInstance; |
66 | |
} |
67 | |
|
68 | |
} |