View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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          //return new DynamicResult(true, nextNodeInstances);
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  }