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-2008 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 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  
  * Handles transitions into and out of {@link SplitNode} nodes.
 29  
  * 
 30  
  * @see SplitNode
 31  
  *
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  */
 34  0
 public class SplitTransitionEngine extends TransitionEngine {
 35  
         
 36  
     public ProcessResult isComplete(RouteContext context) throws Exception {
 37  0
         SplitNode node = (SplitNode)getNode(context.getNodeInstance().getRouteNode(), SplitNode.class);
 38  0
         return node.process(context, getRouteHelper());
 39  
     }
 40  
     
 41  
         public Transition transitionFrom(RouteContext context, ProcessResult processResult)
 42  
                         throws Exception {
 43  0
                 RouteNodeInstance splitInstance = context.getNodeInstance();
 44  0
                 List<RouteNodeInstance> nextNodeInstances = new ArrayList<RouteNodeInstance>();
 45  0
         SplitResult result = (SplitResult)processResult;
 46  0
         for (String branchName : result.getBranchNames())
 47  
         {
 48  0
             for (RouteNode routeNode : splitInstance.getRouteNode().getNextNodes())
 49  
             {
 50  0
                 if (routeNode.getBranch() != null && routeNode.getBranch().getName().equals(branchName))
 51  
                 {
 52  0
                     nextNodeInstances.add(createSplitChild(branchName, routeNode, splitInstance));
 53  
                 }
 54  
             }
 55  
         }
 56  0
                 return new Transition(nextNodeInstances);
 57  
         }
 58  
         
 59  
         public static RouteNodeInstance createSplitChild(String branchName, RouteNode routeNode, RouteNodeInstance splitInstance) {
 60  0
             RouteHelper routeHelper = new RouteHelper();
 61  0
             RouteNodeInstance nextNodeInstance = routeHelper.getNodeFactory().createRouteNodeInstance(splitInstance.getDocumentId(), routeNode);
 62  0
                 Branch branch = routeHelper.getNodeFactory().createBranch(branchName, splitInstance.getBranch(), nextNodeInstance);
 63  0
                 branch.setSplitNode(splitInstance);
 64  0
                 nextNodeInstance.setBranch(branch);
 65  0
                 nextNodeInstance.setProcess(splitInstance.getProcess());
 66  0
                 return nextNodeInstance;
 67  
         }
 68  
         
 69  
 }