View Javadoc
1   /**
2    * Copyright 2005-2014 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.api.exception.WorkflowException;
19  import org.kuali.rice.kew.engine.RouteHelper;
20  import org.kuali.rice.kew.engine.node.RouteNode;
21  import org.kuali.rice.kew.engine.node.RouteNodeInstance;
22  
23  /**
24   * Factory which creates a {@link TransitionEngine} for the given {@link RouteNodeInstance}.  The 
25   * transition engine is determined based on the type of the node instance.
26   * 
27   * @see TransitionEngine
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class TransitionEngineFactory {
32  
33  	public static TransitionEngine createTransitionEngine(RouteNodeInstance nodeInstance) throws Exception {
34  		RouteHelper helper = new RouteHelper();
35  		RouteNode routeNode = nodeInstance.getRouteNode();
36  		TransitionEngine engine = null;
37  		if (helper.isSimpleNode(routeNode)) {
38  			engine = new SimpleTransitionEngine();
39  		} else if (helper.isSplitNode(routeNode)) {
40  			engine = new SplitTransitionEngine();
41  		} else if (helper.isJoinNode(routeNode)) {
42  			engine = new JoinTransitionEngine();
43  		} else if (helper.isDynamicNode(routeNode)) {
44  			engine = new DynamicTransitionEngine();
45  		} else if (helper.isSubProcessNode(routeNode)) {
46  			engine = new SubProcessTransitionEngine();
47  		} else {
48  			throw new WorkflowException("Could not locate transition engine for node " + routeNode.getNodeType());
49  		}
50  		engine.setRouteHelper(helper);
51  		return engine;
52  	}
53  	
54  }