Coverage Report - org.kuali.rice.kew.engine.transition.SplitTransitionEngine
 
Classes in this File Line Coverage Branch Coverage Complexity
SplitTransitionEngine
0%
0/18
0%
0/8
2.333
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.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  
  * Handles transitions into and out of {@link SplitNode} nodes.
 28  
  * 
 29  
  * @see SplitNode
 30  
  *
 31  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 32  
  */
 33  0
 public class SplitTransitionEngine extends TransitionEngine {
 34  
         
 35  
     public ProcessResult isComplete(RouteContext context) throws Exception {
 36  0
         SplitNode node = (SplitNode)getNode(context.getNodeInstance().getRouteNode(), SplitNode.class);
 37  0
         return node.process(context, getRouteHelper());
 38  
     }
 39  
     
 40  
         public Transition transitionFrom(RouteContext context, ProcessResult processResult)
 41  
                         throws Exception {
 42  0
                 RouteNodeInstance splitInstance = context.getNodeInstance();
 43  0
                 List<RouteNodeInstance> nextNodeInstances = new ArrayList<RouteNodeInstance>();
 44  0
         SplitResult result = (SplitResult)processResult;
 45  0
         for (String branchName : result.getBranchNames())
 46  
         {
 47  0
             for (RouteNode routeNode : splitInstance.getRouteNode().getNextNodes())
 48  
             {
 49  0
                 if (routeNode.getBranch() != null && routeNode.getBranch().getName().equals(branchName))
 50  
                 {
 51  0
                     nextNodeInstances.add(createSplitChild(branchName, routeNode, splitInstance));
 52  
                 }
 53  
             }
 54  
         }
 55  0
                 return new Transition(nextNodeInstances);
 56  
         }
 57  
         
 58  
         public static RouteNodeInstance createSplitChild(String branchName, RouteNode routeNode, RouteNodeInstance splitInstance) {
 59  0
             RouteHelper routeHelper = new RouteHelper();
 60  0
             RouteNodeInstance nextNodeInstance = routeHelper.getNodeFactory().createRouteNodeInstance(splitInstance.getDocumentId(), routeNode);
 61  0
                 Branch branch = routeHelper.getNodeFactory().createBranch(branchName, splitInstance.getBranch(), nextNodeInstance);
 62  0
                 branch.setSplitNode(splitInstance);
 63  0
                 nextNodeInstance.setBranch(branch);
 64  0
                 nextNodeInstance.setProcess(splitInstance.getProcess());
 65  0
                 return nextNodeInstance;
 66  
         }
 67  
         
 68  
 }