View Javadoc

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