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 org.kuali.rice.core.api.reflect.ObjectDefinition;
019 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
020 import org.kuali.rice.core.api.util.ClassLoaderUtils;
021 import org.kuali.rice.kew.engine.node.BasicJoinEngine;
022 import org.kuali.rice.kew.engine.node.DynamicNode;
023 import org.kuali.rice.kew.engine.node.JoinEngine;
024 import org.kuali.rice.kew.engine.node.JoinNode;
025 import org.kuali.rice.kew.engine.node.Node;
026 import org.kuali.rice.kew.engine.node.RequestActivationNode;
027 import org.kuali.rice.kew.engine.node.RequestsNode;
028 import org.kuali.rice.kew.engine.node.RouteNode;
029 import org.kuali.rice.kew.engine.node.SimpleNode;
030 import org.kuali.rice.kew.engine.node.SplitNode;
031 import org.kuali.rice.kew.engine.node.SubProcessNode;
032
033
034 /**
035 * A helper class which provides some useful utilities for examining and generating nodes.
036 * Provides access to the {@link JoinEngine} and the {@link RoutingNodeFactory}.
037 *
038 * @author Kuali Rice Team (rice.collab@kuali.org)
039 */
040 public class RouteHelper {
041
042 private JoinEngine joinEngine = new BasicJoinEngine();
043 private RoutingNodeFactory nodeFactory = new RoutingNodeFactory();
044
045 public JoinEngine getJoinEngine() {
046 return joinEngine;
047 }
048
049 public RoutingNodeFactory getNodeFactory() {
050 return nodeFactory;
051 }
052
053 public boolean isSimpleNode(RouteNode routeNode) {
054 return ClassLoaderUtils.isInstanceOf(getNode(routeNode), SimpleNode.class);
055 }
056
057 public boolean isJoinNode(RouteNode routeNode) {
058 return ClassLoaderUtils.isInstanceOf(getNode(routeNode), JoinNode.class);
059 }
060
061 public boolean isSplitNode(RouteNode routeNode) {
062 return ClassLoaderUtils.isInstanceOf(getNode(routeNode), SplitNode.class);
063 }
064
065 public boolean isDynamicNode(RouteNode routeNode) {
066 return ClassLoaderUtils.isInstanceOf(getNode(routeNode), DynamicNode.class);
067 }
068
069 public boolean isSubProcessNode(RouteNode routeNode) {
070 return ClassLoaderUtils.isInstanceOf(getNode(routeNode), SubProcessNode.class);
071 }
072
073 public boolean isRequestActivationNode(RouteNode routeNode) {
074 return ClassLoaderUtils.isInstanceOf(getNode(routeNode), RequestActivationNode.class);
075 }
076
077 public boolean isRequestsNode(RouteNode routeNode) {
078 return getNode(routeNode) instanceof RequestsNode;
079 }
080
081 public Node getNode(RouteNode routeNode) {
082 return (Node) GlobalResourceLoader.getObject(new ObjectDefinition(routeNode.getNodeType(), routeNode.getDocumentType().getApplicationId()));
083 }
084 }