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