1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.rice.kew.engine;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.rice.kew.engine.node.Branch;
22  import org.kuali.rice.kew.engine.node.BranchState;
23  import org.kuali.rice.kew.engine.node.DynamicNode;
24  import org.kuali.rice.kew.engine.node.DynamicResult;
25  import org.kuali.rice.kew.engine.node.RouteNode;
26  import org.kuali.rice.kew.engine.node.RouteNodeInstance;
27  import org.kuali.rice.kew.api.exception.WorkflowException;
28  
29  
30  public class DynamicSplitTestNode implements DynamicNode {
31  
32      private static final String NEXT_NODE_NAME = "SubRequests";
33      private static final String[] ROLES = new String[] { "Sub1", "Sub2", "Sub3" };
34      
35      public DynamicResult transitioningInto(RouteContext context, RouteNodeInstance process, RouteHelper helper) throws Exception {
36          List<RouteNodeInstance> nextNodeInstances = new ArrayList<RouteNodeInstance>();
37          for (int index = 0; index < ROLES.length; index++) {
38              String roleName = ROLES[index];
39              RouteNode node = helper.getNodeFactory().getRouteNode(context, NEXT_NODE_NAME);
40              if (node == null) {
41                  throw new WorkflowException("Couldn't locate node for name: " + NEXT_NODE_NAME);
42              }
43              RouteNodeInstance nextNodeInstance = helper.getNodeFactory().createRouteNodeInstance(context.getDocument().getDocumentId(), node);
44              Branch branch = helper.getNodeFactory().createBranch(roleName, context.getNodeInstance().getBranch(), nextNodeInstance);
45              branch.addBranchState(new BranchState("role", roleName));
46              branch.setSplitNode(context.getNodeInstance());
47              nextNodeInstances.add(nextNodeInstance);
48          }
49          
50          throw new UnsupportedOperationException("No!!!!");
51      }
52      
53      
54  
55      public DynamicResult transitioningOutOf(RouteContext context, RouteHelper helper) throws Exception {
56          throw new UnsupportedOperationException("never written");
57      }
58  }