org.kuali.rice.kew.engine
Class StandardWorkflowEngine

java.lang.Object
  extended by org.kuali.rice.kew.engine.StandardWorkflowEngine
All Implemented Interfaces:
WorkflowEngine
Direct Known Subclasses:
BlanketApproveEngine, SimulationEngine

public class StandardWorkflowEngine
extends Object
implements WorkflowEngine

The standard and supported implementation of the WorkflowEngine. Runs a processing loop against a given Document, processing nodes on the document until the document is completed or a node halts the processing.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Field Summary
protected  RouteHelper helper
           
private static org.apache.log4j.Logger LOG
           
private  boolean runPostProcessorLogic
           
 
Constructor Summary
StandardWorkflowEngine()
           
StandardWorkflowEngine(boolean runPostProcessorLogic)
           
 
Method Summary
private  boolean checkAssertions(RouteContext context)
          Checks various assertions regarding the processing of the current node.
private  void checkDefaultApprovalPolicy(DocumentRouteHeaderValue document)
          Check the default approval policy for the document.
protected  RouteHeaderService getRouteHeaderService()
           
protected  RouteNodeService getRouteNodeService()
           
private  void handleBackwardCompatibility(RouteContext context, RouteNodeInstance nextNodeInstance)
           
private  boolean hasContactedPostProcessor(RouteContext context, DocumentRouteStatusChange event)
          Returns true if the post processor has already been contacted about a PROCESSED or FINAL post processor change.
 void initializeDocument(DocumentRouteHeaderValue document)
          This method initializes the document by materializing and activating the first node instance on the document.
private  List invokeTransition(RouteContext context, RouteNodeInstance nodeInstance, ProcessResult processResult, TransitionEngine transitionEngine)
          Invokes the transition and returns the next node instances to transition to from the current node instance on the route context.
private  boolean isRunawayProcessDetected(EngineState engineState)
           
 boolean isRunPostProcessorLogic()
           
protected  void lockAdditionalDocuments(DocumentRouteHeaderValue document)
           
protected  DocumentRouteHeaderValue nodePostProcess(RouteContext context)
           
private  void notifyNodeChange(RouteContext context, RouteNodeInstance nextNodeInstance)
           
private  DocumentRouteHeaderValue notifyPostProcessor(DocumentRouteHeaderValue document, RouteNodeInstance nodeInstance, DocumentRouteLevelChange event)
          TODO in some cases, someone may modify the route header in the post processor, if we don't save before and reload after we will get an optimistic lock exception, we need to work on a better solution for this! TODO get the routeContext in this method - it should be a better object than the nodeInstance
private  DocumentRouteHeaderValue notifyPostProcessor(RouteContext context, DocumentRouteStatusChange event)
           
private  DocumentRouteHeaderValue notifyPostProcessorAfterProcess(DocumentRouteHeaderValue document, Long nodeInstanceId, AfterProcessEvent event)
          TODO get the routeContext in this method - it should be a better object than the nodeInstance
private  DocumentRouteHeaderValue notifyPostProcessorAfterProcess(DocumentRouteHeaderValue document, Long nodeInstanceId, boolean successfullyProcessed)
          TODO get the routeContext in this method - it should be a better object than the nodeInstance
private  DocumentRouteHeaderValue notifyPostProcessorBeforeProcess(DocumentRouteHeaderValue document, Long nodeInstanceId)
          TODO get the routeContext in this method - it should be a better object than the nodeInstance
private  DocumentRouteHeaderValue notifyPostProcessorBeforeProcess(DocumentRouteHeaderValue document, Long nodeInstanceId, BeforeProcessEvent event)
          TODO get the routeContext in this method - it should be a better object than the nodeInstance
 void process(Long documentId, Long nodeInstanceId)
           
protected  ProcessContext processNodeInstance(RouteContext context, RouteHelper helper)
           
private  void saveBranch(RouteContext context, Branch branch)
           
private  void saveDocument(RouteContext context)
           
protected  void saveNode(RouteContext context, RouteNodeInstance nodeInstance)
           
 void setRunPostProcessorLogic(boolean runPostProcessorLogic)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG

helper

protected RouteHelper helper

runPostProcessorLogic

private boolean runPostProcessorLogic
Constructor Detail

StandardWorkflowEngine

public StandardWorkflowEngine()

StandardWorkflowEngine

public StandardWorkflowEngine(boolean runPostProcessorLogic)
Method Detail

setRunPostProcessorLogic

public void setRunPostProcessorLogic(boolean runPostProcessorLogic)
Specified by:
setRunPostProcessorLogic in interface WorkflowEngine

isRunPostProcessorLogic

public boolean isRunPostProcessorLogic()

process

public void process(Long documentId,
                    Long nodeInstanceId)
             throws Exception
Specified by:
process in interface WorkflowEngine
Throws:
Exception

processNodeInstance

protected ProcessContext processNodeInstance(RouteContext context,
                                             RouteHelper helper)
                                      throws Exception
Throws:
Exception

checkAssertions

private boolean checkAssertions(RouteContext context)
                         throws Exception
Checks various assertions regarding the processing of the current node. If this method returns true, then the node will not be processed. This method will throw an exception if it deems that the processing is in a illegal state.

Throws:
Exception

invokeTransition

private List invokeTransition(RouteContext context,
                              RouteNodeInstance nodeInstance,
                              ProcessResult processResult,
                              TransitionEngine transitionEngine)
                       throws Exception
Invokes the transition and returns the next node instances to transition to from the current node instance on the route context. This is a 3-step process:
  1) If the node instance already has next nodes, return those,
  2) otherwise, invoke the transition engine for the node, if the resulting node instances are not empty, return those,
  3) lastly, if our node is in a process and no next nodes were returned from it's transition engine, invoke the
     transition engine of the process node and return the resulting node instances.
 

Throws:
Exception

notifyNodeChange

private void notifyNodeChange(RouteContext context,
                              RouteNodeInstance nextNodeInstance)
                       throws Exception
Throws:
Exception

handleBackwardCompatibility

private void handleBackwardCompatibility(RouteContext context,
                                         RouteNodeInstance nextNodeInstance)

saveDocument

private void saveDocument(RouteContext context)

saveBranch

private void saveBranch(RouteContext context,
                        Branch branch)

saveNode

protected void saveNode(RouteContext context,
                        RouteNodeInstance nodeInstance)

nodePostProcess

protected DocumentRouteHeaderValue nodePostProcess(RouteContext context)
                                            throws InvalidActionTakenException
Throws:
InvalidActionTakenException

checkDefaultApprovalPolicy

private void checkDefaultApprovalPolicy(DocumentRouteHeaderValue document)
                                 throws RouteManagerException
Check the default approval policy for the document. If the default approval policy is no and no approval action requests have been created then throw an execption so that the document will get thrown into exception routing.

Parameters:
rh - route header to be checked
docType - docType of the routeHeader to be checked.
Throws:
RouteManagerException

notifyPostProcessor

private DocumentRouteHeaderValue notifyPostProcessor(RouteContext context,
                                                     DocumentRouteStatusChange event)

hasContactedPostProcessor

private boolean hasContactedPostProcessor(RouteContext context,
                                          DocumentRouteStatusChange event)
Returns true if the post processor has already been contacted about a PROCESSED or FINAL post processor change. If the post processor has not been contacted, this method will record on the document that it has been. This is because, in certain cases, a document could end up in exception routing after it has already gone PROCESSED or FINAL (i.e. on Mass Action processing) and we don't want to re-contact the post processor in these cases.


notifyPostProcessor

private DocumentRouteHeaderValue notifyPostProcessor(DocumentRouteHeaderValue document,
                                                     RouteNodeInstance nodeInstance,
                                                     DocumentRouteLevelChange event)
TODO in some cases, someone may modify the route header in the post processor, if we don't save before and reload after we will get an optimistic lock exception, we need to work on a better solution for this! TODO get the routeContext in this method - it should be a better object than the nodeInstance


notifyPostProcessorBeforeProcess

private DocumentRouteHeaderValue notifyPostProcessorBeforeProcess(DocumentRouteHeaderValue document,
                                                                  Long nodeInstanceId)
TODO get the routeContext in this method - it should be a better object than the nodeInstance


notifyPostProcessorBeforeProcess

private DocumentRouteHeaderValue notifyPostProcessorBeforeProcess(DocumentRouteHeaderValue document,
                                                                  Long nodeInstanceId,
                                                                  BeforeProcessEvent event)
TODO get the routeContext in this method - it should be a better object than the nodeInstance


lockAdditionalDocuments

protected void lockAdditionalDocuments(DocumentRouteHeaderValue document)
                                throws Exception
Throws:
Exception

notifyPostProcessorAfterProcess

private DocumentRouteHeaderValue notifyPostProcessorAfterProcess(DocumentRouteHeaderValue document,
                                                                 Long nodeInstanceId,
                                                                 boolean successfullyProcessed)
TODO get the routeContext in this method - it should be a better object than the nodeInstance


notifyPostProcessorAfterProcess

private DocumentRouteHeaderValue notifyPostProcessorAfterProcess(DocumentRouteHeaderValue document,
                                                                 Long nodeInstanceId,
                                                                 AfterProcessEvent event)
TODO get the routeContext in this method - it should be a better object than the nodeInstance


initializeDocument

public void initializeDocument(DocumentRouteHeaderValue document)
This method initializes the document by materializing and activating the first node instance on the document.

Specified by:
initializeDocument in interface WorkflowEngine

getRouteNodeService

protected RouteNodeService getRouteNodeService()

isRunawayProcessDetected

private boolean isRunawayProcessDetected(EngineState engineState)
                                  throws NumberFormatException
Throws:
NumberFormatException

getRouteHeaderService

protected RouteHeaderService getRouteHeaderService()


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