01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.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 edu.iu.uis.eden.engine;
18:
19: import edu.iu.uis.eden.KEWServiceLocator;
20: import edu.iu.uis.eden.engine.node.Branch;
21: import edu.iu.uis.eden.engine.node.RouteNode;
22: import edu.iu.uis.eden.engine.node.RouteNodeInstance;
23:
24: /**
25: * Provides factory methods for creating {@link Branch} objects and {@link RouteNodeInstance} object.
26: *
27: * @author ewestfal
28: */
29: public class RoutingNodeFactory {
30:
31: public Branch createBranch(String name, Branch parentBranch,
32: 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(Long documentId,
42: RouteNode node) {
43: RouteNodeInstance nodeInstance = new RouteNodeInstance();
44: nodeInstance.setActive(false);
45: nodeInstance.setComplete(false);
46: nodeInstance.setRouteNode(node);
47: nodeInstance.setDocumentId(documentId);
48: return nodeInstance;
49: }
50:
51: public RouteNode getRouteNode(RouteContext context, String name) {
52: return KEWServiceLocator.getRouteNodeService()
53: .findRouteNodeByName(
54: context.getDocument().getDocumentType()
55: .getDocumentTypeId(), name);
56: }
57:
58: }
|