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.node.service; 17 18 import org.kuali.rice.kew.doctype.bo.DocumentType; 19 import org.kuali.rice.kew.engine.node.Branch; 20 import org.kuali.rice.kew.engine.node.NodeGraphSearchCriteria; 21 import org.kuali.rice.kew.engine.node.NodeGraphSearchResult; 22 import org.kuali.rice.kew.engine.node.NodeState; 23 import org.kuali.rice.kew.engine.node.ProcessDefinitionBo; 24 import org.kuali.rice.kew.engine.node.RouteNode; 25 import org.kuali.rice.kew.engine.node.RouteNodeInstance; 26 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; 27 28 import java.util.List; 29 30 31 /** 32 * A service which provides data access for {@link RouteNode}, {@link RouteNodeInstance}, 33 * {@link NodeState}, and {@link Branch} objects. 34 * 35 * @author Kuali Rice Team (rice.collab@kuali.org) 36 */ 37 public interface RouteNodeService { 38 39 public void save(RouteNode node); 40 public void save(RouteNodeInstance nodeInstance); 41 public void save(NodeState nodeState); 42 public void save(Branch branch); 43 public RouteNode findRouteNodeById(String nodeId); 44 public RouteNodeInstance findRouteNodeInstanceById(String nodeInstanceId); 45 46 /** 47 * 48 * This method looks though the passed in DocumentRouteHeaderValue and retrieves a nodeInstance that 49 * matches the ID passed in. 50 * 51 * @param nodeInstanceId 52 * @param document 53 * @return 54 */ 55 public RouteNodeInstance findRouteNodeInstanceById(String nodeInstanceId, DocumentRouteHeaderValue document); 56 57 /** 58 * Retrieves the initial node instances of the given document. The initial node instances are 59 * those node instances which are at the very beginning of the route. Usually, this will 60 * just be a single node instance. 61 */ 62 public List getInitialNodeInstances(String documentId); 63 64 /** 65 * Retrieves the active node instances of the given Document. The active node instances 66 * represent where in the route path the document is currently located. 67 * @param documentId of the document 68 * @return list of route node instances 69 */ 70 public List<RouteNodeInstance> getActiveNodeInstances(String documentId); 71 72 /** 73 * Retrieves the names of the route node instances where the document is currently located 74 * for the document with the given id. This could be active nodes in the document if it is 75 * in the middle of the routing process or it could be the names of the terminal nodes if 76 * the document has completed routing. 77 * 78 * @param documentId of the document 79 * @return list of names of the current route node instances 80 * @since 2.1 81 */ 82 public List<String> getCurrentRouteNodeNames(String documentId); 83 84 /** 85 * Retrieves the names of active node instances for the document with the 86 * given id. The active node instances represent where in the route path 87 * the document is currently located. 88 * @param documentId of the document 89 * @return list of names of route node instances 90 * @since 2.1 91 */ 92 public List<String> getActiveRouteNodeNames(String documentId); 93 94 public List<RouteNodeInstance> getActiveNodeInstances(DocumentRouteHeaderValue document); 95 96 /** 97 * Retrieves the names of terminal node instances for the document with the 98 * given id. The terminal node instances are nodes in the route path which 99 * are both inactive and complete and have no next nodes in their path. 100 * Terminal node instances will typically only exist on documents which are 101 * no longer enroute. 102 * @param documentId for the given Document 103 * @return list of terminal node instances 104 * @since 2.1 105 */ 106 public List<String> getTerminalRouteNodeNames(String documentId); 107 108 /** 109 * Retrieves the terminal node instances of the given Document. The terminal node instances 110 * are nodes in the route path which are both inactive and complete and have no next nodes 111 * in their path. Terminal node instances will typically only exist on documents which are no 112 * longer Enroute. 113 * @param documentId for the given Document 114 * @return list of terminal node instances 115 */ 116 public List<RouteNodeInstance> getTerminalNodeInstances(String documentId); 117 118 /** 119 * Returns the node instances representing the most recent node instances in the document. 120 * The algorithm for locating the current nodes is as follows: If the document has 121 * active node instances, return those, otherwise return it's terminal node instances. 122 */ 123 public List<RouteNodeInstance> getCurrentNodeInstances(String documentId); 124 125 public NodeState findNodeState(Long nodeInstanceId, String key); 126 public RouteNode findRouteNodeByName(String documentTypeId, String name); 127 public List<RouteNode> findFinalApprovalRouteNodes(String documentTypeId); 128 public List findNextRouteNodesInPath(RouteNodeInstance nodeInstance, String nodeName); 129 public boolean isNodeInPath(DocumentRouteHeaderValue document, String nodeName); 130 public List findRouteNodeInstances(String documentId); 131 public List findProcessNodeInstances(RouteNodeInstance process); 132 public List<String> findPreviousNodeNames(String documentId); 133 134 /** 135 * Returns a List of the distinct node names through which this document might pass in it's future 136 * routing. In certain cases this will be an approximation based on what the system knows at the 137 * time of execution. 138 */ 139 public List<String> findFutureNodeNames(String documentId); 140 141 /** 142 * Flatten all the document types route nodes into a single List. This includes all processes 143 * on the DocumentType. 144 * 145 * @param documentType DocumentType who's nodes will be flattened. 146 * @param climbHierarchy whether to include the parents nodes if the passed in DocumentType contains no nodes 147 * @return List or empty List 148 */ 149 public List<RouteNode> getFlattenedNodes(DocumentType documentType, boolean climbHierarchy); 150 public List<RouteNode> getFlattenedNodes(ProcessDefinitionBo process); 151 152 /** 153 * Returns a flattened list of RouteNodeInstances on the given document. If the includeProcesses flag is 154 * true than this method includes process RouteNodeInstances, otherwise they are excluded. 155 * which are processes. 156 * @param document route header value 157 * @param includeProcesses flag 158 * @return list of routeNodeInstances 159 */ 160 public List<RouteNodeInstance> getFlattenedNodeInstances(DocumentRouteHeaderValue document, boolean includeProcesses); 161 162 public NodeGraphSearchResult searchNodeGraph(NodeGraphSearchCriteria criteria); 163 164 /** 165 * Returns a list of active node instances associated with the document that are active 166 * @param document 167 * @param nodeName 168 * @return 169 */ 170 public List<RouteNodeInstance> getActiveNodeInstances(DocumentRouteHeaderValue document, String nodeName); 171 public void deleteByRouteNodeInstance(RouteNodeInstance routeNodeInstance); 172 public void deleteNodeStateById(Long nodeStateId); 173 public void deleteNodeStates(List statesToBeDeleted); 174 175 /** 176 * Record that the given RouteNodeInstance on the Document was revoked. This will happen when an 177 * action such as Return to Previous or Move Document bypasses the given RouteNodeInstance on it's 178 * path back to a previous point in the history of the document's route path. 179 */ 180 public void revokeNodeInstance(DocumentRouteHeaderValue document, RouteNodeInstance nodeInstance); 181 182 /** 183 * Returns a List of the revoked RouteNodeInstances on the given Document. 184 * 185 * @see revokeNodeInstance 186 */ 187 public List getRevokedNodeInstances(DocumentRouteHeaderValue document); 188 189 }