View Javadoc

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;
17  
18  import org.kuali.rice.kew.engine.node.Branch;
19  import org.kuali.rice.kew.engine.node.RouteNode;
20  import org.kuali.rice.kew.engine.node.RouteNodeInstance;
21  import org.kuali.rice.kew.service.KEWServiceLocator;
22  
23  
24  /**
25   * Provides factory methods for creating {@link Branch} objects and {@link RouteNodeInstance} object.
26   *
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class RoutingNodeFactory {
30  
31      public Branch createBranch(String name, Branch parentBranch, RouteNodeInstance initialNodeInstance) {
32          Branch branch = new Branch();
33          branch.setName(name);
34          branch.setParentBranch(parentBranch);
35          branch.setInitialNode(initialNodeInstance);
36          initialNodeInstance.setBranch(branch);
37          return branch;
38      }
39      
40      public RouteNodeInstance createRouteNodeInstance(String documentId, RouteNode node) {
41          RouteNodeInstance nodeInstance = new RouteNodeInstance();
42          nodeInstance.setActive(false);
43          nodeInstance.setComplete(false);
44          nodeInstance.setRouteNode(node);
45          nodeInstance.setDocumentId(documentId);
46          return nodeInstance;
47      }
48      
49      public RouteNode getRouteNode(RouteContext context, String name) {
50          return KEWServiceLocator.getRouteNodeService().findRouteNodeByName(context.getDocument().getDocumentType().getDocumentTypeId(), name);
51      }
52      
53  }