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