org.kuali.rice.kew.engine.node.service.impl
Class RouteNodeServiceImpl

java.lang.Object
  extended by org.kuali.rice.kew.engine.node.service.impl.RouteNodeServiceImpl
All Implemented Interfaces:
RouteNodeService

public class RouteNodeServiceImpl
extends Object
implements RouteNodeService


Nested Class Summary
private static class RouteNodeServiceImpl.NodeInstanceIdSorter
           
private static class RouteNodeServiceImpl.RouteNodeSorter
          Sorts by RouteNodeId or the order the nodes will be evaluated in *roughly*.
 
Field Summary
private  RouteHelper helper
           
protected  org.apache.log4j.Logger LOG
           
private static Comparator NODE_INSTANCE_BACKWARD_SORT
           
private static Comparator NODE_INSTANCE_FORWARD_SORT
           
static String REVOKED_NODE_INSTANCES_STATE_KEY
           
private  RouteNodeDAO routeNodeDAO
           
 
Constructor Summary
RouteNodeServiceImpl()
           
 
Method Summary
 void deleteByRouteNodeInstance(RouteNodeInstance routeNodeInstance)
           
 void deleteNodeStateById(Long nodeStateId)
           
 void deleteNodeStates(List statesToBeDeleted)
           
private  void determineExactPath(List exactPath, Map<Long,RouteNodeInstance> visited, Collection startingNodeInstances, RouteNodeInstance nodeInstance)
           
private  List determineExactPath(NodeGraphContext context, int searchDirection, Collection startingNodeInstances)
           
 List findFinalApprovalRouteNodes(Long documentTypeId)
           
 List<String> findFutureNodeNames(Long documentId)
          Returns a List of the distinct node names through which this document might pass in it's future routing.
 List findNextRouteNodesInPath(RouteNodeInstance nodeInstance, String nodeName)
           
private  List<RouteNode> findNextRouteNodesInPath(String nodeName, RouteNode node, Set<Long> inspected)
           
 NodeState findNodeState(Long nodeInstanceId, String key)
           
 Set findPreviousNodeNames(Long documentId)
           
 List findProcessNodeInstances(RouteNodeInstance process)
           
 RouteNode findRouteNodeById(Long nodeId)
           
 RouteNode findRouteNodeByName(Long documentTypeId, String name)
           
 RouteNodeInstance findRouteNodeInstanceById(Long nodeInstanceId)
           
 RouteNodeInstance findRouteNodeInstanceById(Long nodeInstanceId, DocumentRouteHeaderValue document)
          This method looks though the passed in DocumentRouteHeaderValue and retrieves a nodeInstance that matches the ID passed in.
 List findRouteNodeInstances(Long documentId)
           
private  void flattenNodeGraph(Map<String,RouteNode> nodes, RouteNode node)
          Recursively walks the node graph and builds up the map.
private  void flattenNodeInstanceGraph(List<RouteNodeInstance> nodeInstances, Set<Long> visitedNodeInstanceIds, RouteNodeInstance nodeInstance, boolean includeProcesses)
           
 List<RouteNodeInstance> getActiveNodeInstances(DocumentRouteHeaderValue document)
           
 List<RouteNodeInstance> getActiveNodeInstances(DocumentRouteHeaderValue document, String nodeName)
          Returns a list of active node instances associated with the document that are active
 List<RouteNodeInstance> getActiveNodeInstances(Long documentId)
          Retrieves the active node instances of the given Document.
 List getCurrentNodeInstances(Long documentId)
          Returns the node instances representing the most recent node instances in the document.
 List<RouteNodeInstance> getFlattenedNodeInstances(DocumentRouteHeaderValue document, boolean includeProcesses)
          Returns a flattened list of RouteNodeInstances on the given document.
 List<RouteNode> getFlattenedNodes(DocumentType documentType, boolean climbHierarchy)
          Flatten all the document types route nodes into a single List.
 List<RouteNode> getFlattenedNodes(Process process)
           
 List getInitialNodeInstances(Long documentId)
          Retrieves the initial node instances of the given document.
 List getRevokedNodeInstances(DocumentRouteHeaderValue document)
          Queries the list of revoked node instances from the root BranchState of the Document and returns a List of revoked RouteNodeInstances.
 List<RouteNodeInstance> getTerminalNodeInstances(Long documentId)
          Retrieves the terminal node instances of the given Document.
 boolean isNodeInPath(DocumentRouteHeaderValue document, String nodeName)
           
 void revokeNodeInstance(DocumentRouteHeaderValue document, RouteNodeInstance nodeInstance)
          Records the revocation in the root BranchState of the document.
 void save(Branch branch)
           
 void save(NodeState nodeState)
           
 void save(RouteNode node)
           
 void save(RouteNodeInstance nodeInstance)
           
 NodeGraphSearchResult searchNodeGraph(NodeGraphSearchCriteria criteria)
           
private  void searchNodeGraphBackward(NodeGraphContext context, NodeMatcher matcher)
           
private  void searchNodeGraphBackward(NodeGraphContext context, NodeMatcher matcher, RouteNodeInstance previousNodeInstance, Collection nodeInstances)
           
 void setRouteNodeDAO(RouteNodeDAO dao)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected final org.apache.log4j.Logger LOG

REVOKED_NODE_INSTANCES_STATE_KEY

public static final String REVOKED_NODE_INSTANCES_STATE_KEY
See Also:
Constant Field Values

NODE_INSTANCE_FORWARD_SORT

private static final Comparator NODE_INSTANCE_FORWARD_SORT

NODE_INSTANCE_BACKWARD_SORT

private static final Comparator NODE_INSTANCE_BACKWARD_SORT

helper

private RouteHelper helper

routeNodeDAO

private RouteNodeDAO routeNodeDAO
Constructor Detail

RouteNodeServiceImpl

public RouteNodeServiceImpl()
Method Detail

save

public void save(RouteNode node)
Specified by:
save in interface RouteNodeService

save

public void save(RouteNodeInstance nodeInstance)
Specified by:
save in interface RouteNodeService

save

public void save(NodeState nodeState)
Specified by:
save in interface RouteNodeService

save

public void save(Branch branch)
Specified by:
save in interface RouteNodeService

findRouteNodeById

public RouteNode findRouteNodeById(Long nodeId)
Specified by:
findRouteNodeById in interface RouteNodeService

findRouteNodeInstanceById

public RouteNodeInstance findRouteNodeInstanceById(Long nodeInstanceId)
Specified by:
findRouteNodeInstanceById in interface RouteNodeService

findRouteNodeInstanceById

public RouteNodeInstance findRouteNodeInstanceById(Long nodeInstanceId,
                                                   DocumentRouteHeaderValue document)
Description copied from interface: RouteNodeService
This method looks though the passed in DocumentRouteHeaderValue and retrieves a nodeInstance that matches the ID passed in.

Specified by:
findRouteNodeInstanceById in interface RouteNodeService
Returns:

getCurrentNodeInstances

public List getCurrentNodeInstances(Long documentId)
Description copied from interface: RouteNodeService
Returns the node instances representing the most recent node instances in the document. The algorithm for locating the current nodes is as follows: If the document has active node instances, return those, otherwise return it's terminal node instances.

Specified by:
getCurrentNodeInstances in interface RouteNodeService

getActiveNodeInstances

public List<RouteNodeInstance> getActiveNodeInstances(Long documentId)
Description copied from interface: RouteNodeService
Retrieves the active node instances of the given Document. The active node instances represent where in the route path the document is currently located.

Specified by:
getActiveNodeInstances in interface RouteNodeService
Parameters:
documentId - of the document
Returns:
list of route node instances

getActiveNodeInstances

public List<RouteNodeInstance> getActiveNodeInstances(DocumentRouteHeaderValue document)
Specified by:
getActiveNodeInstances in interface RouteNodeService

getTerminalNodeInstances

public List<RouteNodeInstance> getTerminalNodeInstances(Long documentId)
Description copied from interface: RouteNodeService
Retrieves the terminal node instances of the given Document. The terminal node instances are nodes in the route path which are both inactive and complete and have no next nodes in their path. Terminal node instances will typically only exist on documents which are no longer Enroute.

Specified by:
getTerminalNodeInstances in interface RouteNodeService
Parameters:
documentId - for the given Document
Returns:
list of terminal node instances

getInitialNodeInstances

public List getInitialNodeInstances(Long documentId)
Description copied from interface: RouteNodeService
Retrieves the initial node instances of the given document. The initial node instances are those node instances which are at the very beginning of the route. Usually, this will just be a single node instance.

Specified by:
getInitialNodeInstances in interface RouteNodeService

findNodeState

public NodeState findNodeState(Long nodeInstanceId,
                               String key)
Specified by:
findNodeState in interface RouteNodeService

findRouteNodeByName

public RouteNode findRouteNodeByName(Long documentTypeId,
                                     String name)
Specified by:
findRouteNodeByName in interface RouteNodeService

findFinalApprovalRouteNodes

public List findFinalApprovalRouteNodes(Long documentTypeId)
Specified by:
findFinalApprovalRouteNodes in interface RouteNodeService

findNextRouteNodesInPath

public List findNextRouteNodesInPath(RouteNodeInstance nodeInstance,
                                     String nodeName)
Specified by:
findNextRouteNodesInPath in interface RouteNodeService

findNextRouteNodesInPath

private List<RouteNode> findNextRouteNodesInPath(String nodeName,
                                                 RouteNode node,
                                                 Set<Long> inspected)

isNodeInPath

public boolean isNodeInPath(DocumentRouteHeaderValue document,
                            String nodeName)
Specified by:
isNodeInPath in interface RouteNodeService

findRouteNodeInstances

public List findRouteNodeInstances(Long documentId)
Specified by:
findRouteNodeInstances in interface RouteNodeService

setRouteNodeDAO

public void setRouteNodeDAO(RouteNodeDAO dao)

findProcessNodeInstances

public List findProcessNodeInstances(RouteNodeInstance process)
Specified by:
findProcessNodeInstances in interface RouteNodeService

findPreviousNodeNames

public Set findPreviousNodeNames(Long documentId)
Specified by:
findPreviousNodeNames in interface RouteNodeService

findFutureNodeNames

public List<String> findFutureNodeNames(Long documentId)
Description copied from interface: RouteNodeService
Returns a List of the distinct node names through which this document might pass in it's future routing. In certain cases this will be an approximation based on what the system knows at the time of execution.

Specified by:
findFutureNodeNames in interface RouteNodeService

getFlattenedNodes

public List<RouteNode> getFlattenedNodes(DocumentType documentType,
                                         boolean climbHierarchy)
Description copied from interface: RouteNodeService
Flatten all the document types route nodes into a single List. This includes all processes on the DocumentType.

Specified by:
getFlattenedNodes in interface RouteNodeService
Parameters:
documentType - DocumentType who's nodes will be flattened.
climbHierarchy - whether to include the parents nodes if the passed in DocumentType contains no nodes
Returns:
List or empty List

getFlattenedNodes

public List<RouteNode> getFlattenedNodes(Process process)
Specified by:
getFlattenedNodes in interface RouteNodeService

flattenNodeGraph

private void flattenNodeGraph(Map<String,RouteNode> nodes,
                              RouteNode node)
Recursively walks the node graph and builds up the map. Uses a map because we will end up walking through duplicates, as is the case with Join nodes.


getFlattenedNodeInstances

public List<RouteNodeInstance> getFlattenedNodeInstances(DocumentRouteHeaderValue document,
                                                         boolean includeProcesses)
Description copied from interface: RouteNodeService
Returns a flattened list of RouteNodeInstances on the given document. If the includeProcesses flag is true than this method includes process RouteNodeInstances, otherwise they are excluded. which are processes.

Specified by:
getFlattenedNodeInstances in interface RouteNodeService
Parameters:
document - route header value
includeProcesses - flag
Returns:
list of routeNodeInstances

flattenNodeInstanceGraph

private void flattenNodeInstanceGraph(List<RouteNodeInstance> nodeInstances,
                                      Set<Long> visitedNodeInstanceIds,
                                      RouteNodeInstance nodeInstance,
                                      boolean includeProcesses)

searchNodeGraph

public NodeGraphSearchResult searchNodeGraph(NodeGraphSearchCriteria criteria)
Specified by:
searchNodeGraph in interface RouteNodeService

searchNodeGraphBackward

private void searchNodeGraphBackward(NodeGraphContext context,
                                     NodeMatcher matcher,
                                     RouteNodeInstance previousNodeInstance,
                                     Collection nodeInstances)

searchNodeGraphBackward

private void searchNodeGraphBackward(NodeGraphContext context,
                                     NodeMatcher matcher)

getActiveNodeInstances

public List<RouteNodeInstance> getActiveNodeInstances(DocumentRouteHeaderValue document,
                                                      String nodeName)
Description copied from interface: RouteNodeService
Returns a list of active node instances associated with the document that are active

Specified by:
getActiveNodeInstances in interface RouteNodeService
Returns:

determineExactPath

private List determineExactPath(NodeGraphContext context,
                                int searchDirection,
                                Collection startingNodeInstances)

determineExactPath

private void determineExactPath(List exactPath,
                                Map<Long,RouteNodeInstance> visited,
                                Collection startingNodeInstances,
                                RouteNodeInstance nodeInstance)

deleteByRouteNodeInstance

public void deleteByRouteNodeInstance(RouteNodeInstance routeNodeInstance)
Specified by:
deleteByRouteNodeInstance in interface RouteNodeService

deleteNodeStateById

public void deleteNodeStateById(Long nodeStateId)
Specified by:
deleteNodeStateById in interface RouteNodeService

deleteNodeStates

public void deleteNodeStates(List statesToBeDeleted)
Specified by:
deleteNodeStates in interface RouteNodeService

revokeNodeInstance

public void revokeNodeInstance(DocumentRouteHeaderValue document,
                               RouteNodeInstance nodeInstance)
Records the revocation in the root BranchState of the document.

Specified by:
revokeNodeInstance in interface RouteNodeService

getRevokedNodeInstances

public List getRevokedNodeInstances(DocumentRouteHeaderValue document)
Queries the list of revoked node instances from the root BranchState of the Document and returns a List of revoked RouteNodeInstances.

Specified by:
getRevokedNodeInstances in interface RouteNodeService
See Also:
revokeNodeInstance


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.