001 /** 002 * Copyright 2005-2011 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kew.engine; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 021 import org.kuali.rice.kew.engine.node.Branch; 022 import org.kuali.rice.kew.engine.node.BranchState; 023 import org.kuali.rice.kew.engine.node.DynamicNode; 024 import org.kuali.rice.kew.engine.node.DynamicResult; 025 import org.kuali.rice.kew.engine.node.RouteNode; 026 import org.kuali.rice.kew.engine.node.RouteNodeInstance; 027 import org.kuali.rice.kew.api.exception.WorkflowException; 028 029 030 public class DynamicSplitTestNode implements DynamicNode { 031 032 private static final String NEXT_NODE_NAME = "SubRequests"; 033 private static final String[] ROLES = new String[] { "Sub1", "Sub2", "Sub3" }; 034 035 public DynamicResult transitioningInto(RouteContext context, RouteNodeInstance process, RouteHelper helper) throws Exception { 036 List<RouteNodeInstance> nextNodeInstances = new ArrayList<RouteNodeInstance>(); 037 for (int index = 0; index < ROLES.length; index++) { 038 String roleName = ROLES[index]; 039 RouteNode node = helper.getNodeFactory().getRouteNode(context, NEXT_NODE_NAME); 040 if (node == null) { 041 throw new WorkflowException("Couldn't locate node for name: " + NEXT_NODE_NAME); 042 } 043 RouteNodeInstance nextNodeInstance = helper.getNodeFactory().createRouteNodeInstance(context.getDocument().getDocumentId(), node); 044 Branch branch = helper.getNodeFactory().createBranch(roleName, context.getNodeInstance().getBranch(), nextNodeInstance); 045 branch.addBranchState(new BranchState("role", roleName)); 046 branch.setSplitNode(context.getNodeInstance()); 047 nextNodeInstances.add(nextNodeInstance); 048 } 049 //return new DynamicResult(true, nextNodeInstances); 050 throw new UnsupportedOperationException("No!!!!"); 051 } 052 053 054 055 public DynamicResult transitioningOutOf(RouteContext context, RouteHelper helper) throws Exception { 056 throw new UnsupportedOperationException("never written"); 057 } 058 }