Package com.opensymphony.workflow
Class AbstractWorkflow
java.lang.Object
com.opensymphony.workflow.AbstractWorkflow
- All Implemented Interfaces:
Workflow
- Direct Known Subclasses:
BasicWorkflow,OfbizWorkflow
Abstract workflow instance that serves as the base for specific implementations, such as EJB or SOAP.
- Author:
- Pat Lightbody, Hani Suleiman
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Configurationprotected WorkflowContextprotected final org.apache.commons.logging.Logprotected ThreadLocalFields inherited from interface com.opensymphony.workflow.Workflow
BSF_COL, BSF_LANGUAGE, BSF_ROW, BSF_SCRIPT, BSF_SOURCE, BSH_SCRIPT, CLASS_NAME, EJB_LOCATION, JNDI_LOCATION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanInitialize(String workflowName, int initialAction) Check if the calling user has enough permissions to initialise the specified workflow.booleancanInitialize(String workflowName, int initialAction, Map inputs) Determine if a particular workflow can be initialized.protected booleancanInitialize(String workflowName, int initialAction, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) booleancanModifyEntryState(long id, int newState) Check if the state of the specified workflow instance can be changed to the new specified one.voidchangeEntryState(long id, int newState) Modify the state of the specified workflow instance.protected voidcompleteEntry(ActionDescriptor action, long id, Collection currentSteps, int state) Mark the specified entry as completed, and move all current steps to history.protected StepcreateNewCurrentStep(ResultDescriptor theResult, WorkflowEntry entry, WorkflowStore store, int actionId, Step currentStep, long[] previousIds, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) voidPerform an action on the specified workflow instance.protected voidexecuteFunction(FunctionDescriptor function, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) Executes a function.voidexecuteTriggerFunction(long id, int triggerId) Executes a special trigger-function using the context of the given workflow instance id.int[]getAvailableActions(long id) Deprecated.int[]getAvailableActions(long id, Map inputs) Get the available actions for the specified workflow instance.protected ListgetAvailableActionsForStep(WorkflowDescriptor wf, Step step, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) protected int[]getAvailableAutoActions(long id, Map inputs) protected ListgetAvailableAutoActionsForStep(WorkflowDescriptor wf, Step step, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) Get just auto action availables for a stepGet the configuration for this workflow.protected StepgetCurrentStep(WorkflowDescriptor wfDesc, int actionId, List currentSteps, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) getCurrentSteps(long id) Returns a Collection of Step objects that are the current steps of the specified workflow instance.intgetEntryState(long id) Return the state of the specified workflow instance id.getHistorySteps(long id) Returns a list of all steps that are completed for the given workflow instance id.protected WorkflowStorecom.opensymphony.module.propertyset.PropertySetgetPropertySet(long id) Get the PropertySet for the specified workflow IDgetSecurityPermissions(long id) Get a collection (Strings) of currently defined permissions for the specified workflow instance.getSecurityPermissions(long id, Map inputs) Get a collection (Strings) of currently defined permissions for the specified workflow instance.getWorkflowDescriptor(String workflowName) Returns a workflow definition object associated with the given name.getWorkflowName(long id) Get the name of the specified workflow instance.String[]Get a list of workflow names availablelonginitialize(String workflowName, int initialAction, Map inputs) Initializes a workflow so that it can begin processing.protected booleanisActionAvailable(ActionDescriptor action, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps, int stepId) check if an action is available or notprotected booleanpassesCondition(ConditionDescriptor conditionDesc, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps, int currentStepId) protected booleanpassesConditions(ConditionsDescriptor descriptor, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps, int currentStepId) protected booleanpassesConditions(String conditionType, List conditions, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps, int currentStepId) protected voidpopulateTransientMap(WorkflowEntry entry, Map transientVars, List registers, Integer actionId, Collection currentSteps, com.opensymphony.module.propertyset.PropertySet ps) query(WorkflowExpressionQuery query) Query the workflow store for matching instancesquery(WorkflowQuery query) Query the workflow store for matching instancesbooleanremoveWorkflowDescriptor(String workflowName) Remove the specified workflow descriptor.booleansaveWorkflowDescriptor(String workflowName, WorkflowDescriptor descriptor, boolean replace) Add a new workflow descriptorvoidsetConfiguration(Configuration configuration) Set the configuration for this workflow.voidsetResolver(TypeResolver resolver) protected booleantransitionWorkflow(WorkflowEntry entry, List currentSteps, WorkflowStore store, WorkflowDescriptor wf, ActionDescriptor action, Map transientVars, Map inputs, com.opensymphony.module.propertyset.PropertySet ps) protected voidverifyInputs(WorkflowEntry entry, List validators, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) Validates input against a list of ValidatorDescriptor objects.
-
Field Details
-
log
protected final org.apache.commons.logging.Log log -
configuration
-
stateCache
-
context
-
-
Constructor Details
-
AbstractWorkflow
public AbstractWorkflow()
-
-
Method Details
-
getAvailableActions
public int[] getAvailableActions(long id) Deprecated.usegetAvailableActions(long, Map)with an empty Map instead.- Specified by:
getAvailableActionsin interfaceWorkflow
-
getAvailableActions
Get the available actions for the specified workflow instance.- Specified by:
getAvailableActionsin interfaceWorkflow- Parameters:
id- The workflow instance id.inputs- The inputs map to pass on to conditions- Returns:
- An array of action id's that can be performed on the specified entry.
- Throws:
IllegalArgumentException- if the specified id does not exist, or if its workflow descriptor is no longer available or has become invalid.
-
setConfiguration
Description copied from interface:WorkflowSet the configuration for this workflow. If not set, then the workflow will use the default configuration static instance.- Specified by:
setConfigurationin interfaceWorkflow- Parameters:
configuration- a workflow configuration
-
getConfiguration
Get the configuration for this workflow. This method also checks if the configuration has been initialized, and if not, initializes it.- Returns:
- The configuration that was set. If no configuration was set, then the default (static) configuration is returned.
-
getCurrentSteps
Description copied from interface:WorkflowReturns a Collection of Step objects that are the current steps of the specified workflow instance.- Specified by:
getCurrentStepsin interfaceWorkflow- Parameters:
id- The workflow instance id.- Returns:
- The steps that the workflow instance is currently in.
-
getEntryState
public int getEntryState(long id) Description copied from interface:WorkflowReturn the state of the specified workflow instance id.- Specified by:
getEntryStatein interfaceWorkflow- Parameters:
id- The workflow instance id.- Returns:
- int The state id of the specified workflow
-
getHistorySteps
Description copied from interface:WorkflowReturns a list of all steps that are completed for the given workflow instance id.- Specified by:
getHistoryStepsin interfaceWorkflow- Parameters:
id- The workflow instance id.- Returns:
- a List of Steps
- See Also:
-
getPersistenceProperties
-
getPropertySet
public com.opensymphony.module.propertyset.PropertySet getPropertySet(long id) Get the PropertySet for the specified workflow ID- Specified by:
getPropertySetin interfaceWorkflow- Parameters:
id- The workflow ID
-
setResolver
-
getResolver
-
getSecurityPermissions
Description copied from interface:WorkflowGet a collection (Strings) of currently defined permissions for the specified workflow instance.- Specified by:
getSecurityPermissionsin interfaceWorkflow- Parameters:
id- the workflow instance id.- Returns:
- A List of permissions specified currently (a permission is a string name).
-
getSecurityPermissions
Description copied from interface:WorkflowGet a collection (Strings) of currently defined permissions for the specified workflow instance.- Specified by:
getSecurityPermissionsin interfaceWorkflow- Parameters:
id- id the workflow instance id.inputs- inputs The inputs to the workflow instance.- Returns:
- A List of permissions specified currently (a permission is a string name).
-
getWorkflowDescriptor
Returns a workflow definition object associated with the given name.- Specified by:
getWorkflowDescriptorin interfaceWorkflow- Parameters:
workflowName- the name of the workflow- Returns:
- the object graph that represents a workflow definition
-
getWorkflowName
Description copied from interface:WorkflowGet the name of the specified workflow instance.- Specified by:
getWorkflowNamein interfaceWorkflow- Parameters:
id- the workflow instance id.
-
getWorkflowNames
Get a list of workflow names available- Specified by:
getWorkflowNamesin interfaceWorkflow- Returns:
- String[] an array of workflow names.
-
canInitialize
Description copied from interface:WorkflowCheck if the calling user has enough permissions to initialise the specified workflow.- Specified by:
canInitializein interfaceWorkflow- Parameters:
workflowName- The name of the workflow to check.initialAction- The id of the initial state to check.- Returns:
- true if the user can successfully call initialize, false otherwise.
-
canInitialize
Description copied from interface:WorkflowDetermine if a particular workflow can be initialized.- Specified by:
canInitializein interfaceWorkflow- Parameters:
workflowName- the name of the workflow to checkinitialAction- The initial action to checkinputs- the inputs map- Returns:
- true if the workflow can be initialized
-
canModifyEntryState
public boolean canModifyEntryState(long id, int newState) Description copied from interface:WorkflowCheck if the state of the specified workflow instance can be changed to the new specified one.- Specified by:
canModifyEntryStatein interfaceWorkflow- Parameters:
id- The workflow instance id.newState- The new state id.- Returns:
- true if the state of the workflow can be modified, false otherwise.
-
changeEntryState
Description copied from interface:WorkflowModify the state of the specified workflow instance.- Specified by:
changeEntryStatein interfaceWorkflow- Parameters:
id- The workflow instance id.newState- the new state to change the workflow instance to. If the new state isorinvalid reference
com.opensymphony.workflow.spi.WorkflowEntry.KILLEDthen all current steps are moved to history steps. If the new state isinvalid reference
com.opensymphony.workflow.spi.WorkflowEntry.COMPLETED- Throws:
WorkflowException
-
doAction
Description copied from interface:WorkflowPerform an action on the specified workflow instance.- Specified by:
doActionin interfaceWorkflow- Parameters:
id- The workflow instance id.actionId- The action id to perform (action id's are listed in the workflow descriptor).inputs- The inputs to the workflow instance.- Throws:
WorkflowException
-
executeTriggerFunction
Description copied from interface:WorkflowExecutes a special trigger-function using the context of the given workflow instance id. Note that this method is exposed for Quartz trigger jobs, user code should never call it.- Specified by:
executeTriggerFunctionin interfaceWorkflow- Parameters:
id- The workflow instance idtriggerId- The id of the speciail trigger-function- Throws:
WorkflowException
-
initialize
public long initialize(String workflowName, int initialAction, Map inputs) throws InvalidRoleException, InvalidInputException, WorkflowException Description copied from interface:WorkflowInitializes a workflow so that it can begin processing. A workflow must be initialized before it can begin any sort of activity. It can only be initialized once.- Specified by:
initializein interfaceWorkflow- Parameters:
workflowName- The workflow name to create and initialize an instance forinitialAction- The initial step to start the workflowinputs- The inputs entered by the end-user- Throws:
InvalidRoleException- if the user can't start this functionInvalidInputException- if a validator is specified and an input is invalid.WorkflowException
-
query
Description copied from interface:WorkflowQuery the workflow store for matching instances- Specified by:
queryin interfaceWorkflow- Throws:
StoreException
-
query
Description copied from interface:WorkflowQuery the workflow store for matching instances- Specified by:
queryin interfaceWorkflow- Throws:
WorkflowException
-
removeWorkflowDescriptor
Description copied from interface:WorkflowRemove the specified workflow descriptor.- Specified by:
removeWorkflowDescriptorin interfaceWorkflow- Parameters:
workflowName- The workflow name of the workflow to remove.- Returns:
- true if the workflow was removed, false otherwise.
- Throws:
FactoryException- If the underlying workflow factory has an error removing the workflow, or if it does not support the removal of workflows.
-
saveWorkflowDescriptor
public boolean saveWorkflowDescriptor(String workflowName, WorkflowDescriptor descriptor, boolean replace) throws FactoryException Description copied from interface:WorkflowAdd a new workflow descriptor- Specified by:
saveWorkflowDescriptorin interfaceWorkflow- Parameters:
workflowName- The workflow name of the workflow to adddescriptor- The workflow descriptor to addreplace- true, if an existing descriptor should be overwritten- Returns:
- true if the workflow was added, fales otherwise
- Throws:
FactoryException- If the underlying workflow factory has an error adding the workflow, or if it does not support adding workflows.
-
isActionAvailable
protected boolean isActionAvailable(ActionDescriptor action, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps, int stepId) throws WorkflowException check if an action is available or not- Parameters:
action- The action descriptor- Returns:
- true if the action is available
- Throws:
WorkflowException
-
getAvailableActionsForStep
protected List getAvailableActionsForStep(WorkflowDescriptor wf, Step step, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) throws WorkflowException - Throws:
WorkflowException
-
getAvailableAutoActions
-
getAvailableAutoActionsForStep
protected List getAvailableAutoActionsForStep(WorkflowDescriptor wf, Step step, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) throws WorkflowException Get just auto action availables for a step- Throws:
WorkflowException
-
getCurrentStep
protected Step getCurrentStep(WorkflowDescriptor wfDesc, int actionId, List currentSteps, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) throws WorkflowException - Throws:
WorkflowException
-
getPersistence
- Throws:
StoreException
-
canInitialize
protected boolean canInitialize(String workflowName, int initialAction, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) throws WorkflowException - Throws:
WorkflowException
-
completeEntry
protected void completeEntry(ActionDescriptor action, long id, Collection currentSteps, int state) throws StoreException Mark the specified entry as completed, and move all current steps to history.- Throws:
StoreException
-
createNewCurrentStep
protected Step createNewCurrentStep(ResultDescriptor theResult, WorkflowEntry entry, WorkflowStore store, int actionId, Step currentStep, long[] previousIds, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) throws WorkflowException - Throws:
WorkflowException
-
executeFunction
protected void executeFunction(FunctionDescriptor function, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) throws WorkflowException Executes a function.- Parameters:
function- the function to executetransientVars- the transientVars given by the end-userps- the persistence variables- Throws:
WorkflowException
-
passesCondition
protected boolean passesCondition(ConditionDescriptor conditionDesc, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps, int currentStepId) throws WorkflowException - Throws:
WorkflowException
-
passesConditions
protected boolean passesConditions(String conditionType, List conditions, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps, int currentStepId) throws WorkflowException - Throws:
WorkflowException
-
passesConditions
protected boolean passesConditions(ConditionsDescriptor descriptor, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps, int currentStepId) throws WorkflowException - Throws:
WorkflowException
-
populateTransientMap
protected void populateTransientMap(WorkflowEntry entry, Map transientVars, List registers, Integer actionId, Collection currentSteps, com.opensymphony.module.propertyset.PropertySet ps) throws WorkflowException - Throws:
WorkflowException
-
transitionWorkflow
protected boolean transitionWorkflow(WorkflowEntry entry, List currentSteps, WorkflowStore store, WorkflowDescriptor wf, ActionDescriptor action, Map transientVars, Map inputs, com.opensymphony.module.propertyset.PropertySet ps) throws WorkflowException - Returns:
- true if the instance has been explicitly completed is this transition, false otherwise
- Throws:
WorkflowException
-
verifyInputs
protected void verifyInputs(WorkflowEntry entry, List validators, Map transientVars, com.opensymphony.module.propertyset.PropertySet ps) throws WorkflowException Validates input against a list of ValidatorDescriptor objects.- Parameters:
entry- the workflow instancevalidators- the list of ValidatorDescriptorstransientVars- the transientVarsps- the persistence variables- Throws:
InvalidInputException- if the input is deemed invalid by any validatorWorkflowException
-
getAvailableActions(long, Map)with an empty Map instead.