| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| TransitionEngineFactory |
|
| 7.0;7 |
| 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.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 | 0 | public class TransitionEngineFactory { |
| 32 | ||
| 33 | public static TransitionEngine createTransitionEngine(RouteNodeInstance nodeInstance) throws Exception { | |
| 34 | 0 | RouteHelper helper = new RouteHelper(); |
| 35 | 0 | RouteNode routeNode = nodeInstance.getRouteNode(); |
| 36 | 0 | TransitionEngine engine = null; |
| 37 | 0 | if (helper.isSimpleNode(routeNode)) { |
| 38 | 0 | engine = new SimpleTransitionEngine(); |
| 39 | 0 | } else if (helper.isSplitNode(routeNode)) { |
| 40 | 0 | engine = new SplitTransitionEngine(); |
| 41 | 0 | } else if (helper.isJoinNode(routeNode)) { |
| 42 | 0 | engine = new JoinTransitionEngine(); |
| 43 | 0 | } else if (helper.isDynamicNode(routeNode)) { |
| 44 | 0 | engine = new DynamicTransitionEngine(); |
| 45 | 0 | } else if (helper.isSubProcessNode(routeNode)) { |
| 46 | 0 | engine = new SubProcessTransitionEngine(); |
| 47 | } else { | |
| 48 | 0 | throw new WorkflowException("Could not locate transition engine for node " + routeNode.getNodeType()); |
| 49 | } | |
| 50 | 0 | engine.setRouteHelper(helper); |
| 51 | 0 | return engine; |
| 52 | } | |
| 53 | ||
| 54 | } |