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;
17  
18  import org.kuali.rice.core.api.reflect.ObjectDefinition;
19  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20  import org.kuali.rice.core.api.util.ClassLoaderUtils;
21  import org.kuali.rice.kew.engine.node.BasicJoinEngine;
22  import org.kuali.rice.kew.engine.node.DynamicNode;
23  import org.kuali.rice.kew.engine.node.JoinEngine;
24  import org.kuali.rice.kew.engine.node.JoinNode;
25  import org.kuali.rice.kew.engine.node.Node;
26  import org.kuali.rice.kew.engine.node.RequestActivationNode;
27  import org.kuali.rice.kew.engine.node.RequestsNode;
28  import org.kuali.rice.kew.engine.node.RouteNode;
29  import org.kuali.rice.kew.engine.node.SimpleNode;
30  import org.kuali.rice.kew.engine.node.SplitNode;
31  import org.kuali.rice.kew.engine.node.SubProcessNode;
32  
33  
34  /**
35   * A helper class which provides some useful utilities for examining and generating nodes.
36   * Provides access to the {@link JoinEngine} and the {@link RoutingNodeFactory}.
37   *
38   * @author Kuali Rice Team (rice.collab@kuali.org)
39   */
40  public class RouteHelper {
41  
42      private JoinEngine joinEngine = new BasicJoinEngine();
43      private RoutingNodeFactory nodeFactory = new RoutingNodeFactory();
44  
45      public JoinEngine getJoinEngine() {
46          return joinEngine;
47      }
48  
49      public RoutingNodeFactory getNodeFactory() {
50          return nodeFactory;
51      }
52  
53      public boolean isSimpleNode(RouteNode routeNode) {
54          return ClassLoaderUtils.isInstanceOf(getNode(routeNode), SimpleNode.class);
55      }
56  
57      public boolean isJoinNode(RouteNode routeNode) {
58          return ClassLoaderUtils.isInstanceOf(getNode(routeNode), JoinNode.class);
59      }
60  
61      public boolean isSplitNode(RouteNode routeNode) {
62          return ClassLoaderUtils.isInstanceOf(getNode(routeNode), SplitNode.class);
63      }
64  
65      public boolean isDynamicNode(RouteNode routeNode) {
66          return ClassLoaderUtils.isInstanceOf(getNode(routeNode), DynamicNode.class);
67      }
68  
69      public boolean isSubProcessNode(RouteNode routeNode) {
70          return ClassLoaderUtils.isInstanceOf(getNode(routeNode), SubProcessNode.class);
71      }
72  
73      public boolean isRequestActivationNode(RouteNode routeNode) {
74          return ClassLoaderUtils.isInstanceOf(getNode(routeNode), RequestActivationNode.class);
75      }
76  
77      public boolean isRequestsNode(RouteNode routeNode) {
78          return getNode(routeNode) instanceof RequestsNode;
79      }
80  
81      public Node getNode(RouteNode routeNode) {
82      	return (Node) GlobalResourceLoader.getObject(new ObjectDefinition(routeNode.getNodeType(), routeNode.getDocumentType().getApplicationId()));
83      }
84  }