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