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