com.opensymphony.workflow
Class AbstractWorkflow

java.lang.Object
  |
  +--com.opensymphony.workflow.AbstractWorkflow
All Implemented Interfaces:
Workflow
Direct Known Subclasses:
BasicWorkflow, OfbizWorkflow, WorkflowEJB

public class AbstractWorkflow
extends java.lang.Object
implements Workflow


Field Summary
protected  WorkflowContext context
           
 
Constructor Summary
AbstractWorkflow()
           
 
Method Summary
 boolean canInitialize(java.lang.String workflowName, int initialState)
          Check if the calling user has enough permissions to initialise the specified workflow
 long createEntry(java.lang.String workflowName)
          Create a workflow entry
protected  java.util.Map createVariableMap(WorkflowEntry entry, java.util.List registers)
           
 void doAction(long id, int actionId, java.util.Map inputs)
          perform an action on the specified workflow
protected  boolean evaluateExpression(java.lang.String expr, WorkflowEntry entry, java.util.List registers)
           
protected  void executeFunction(FunctionDescriptor function, WorkflowEntry entry, java.util.Map inputs, java.util.List registers)
           
 void executeTriggerFunction(long id, int triggerId)
           
 int[] getActionableSteps(java.lang.String workflowName)
          Get an array of steps that have actions in the specified workflow
 java.lang.String getActionName(long id, int actionId)
          Get a verbose string action name for a specified workflow action within the current step
 int[] getAvailableActions(long id)
          Get an array of possible actions for the specified workflow
 HistoryStep getCurrentStatus(long id)
          Get the current status of the specified workflow
 WorkflowHistory getHistory(long id)
          Get the workflow history
protected  Persistence getPersistence()
           
 com.opensymphony.module.propertyset.PropertySet getPropertySet(long id)
           
 java.util.List getSecurityPermissions(long id)
          Get a collection of currently defined permissions for the specified workflow
 java.lang.String getStepName(long id, int stepId)
          Get a string name for the specified step
protected  WorkflowDescriptor getWorkflow(java.lang.String name)
           
 void initialize(long id, int initialState, java.util.Map inputs)
           
 boolean isInitialized(long id)
          Check if the specified workflow has been initialized
protected  void loadConfig()
           
protected  void setBshVariables(bsh.Interpreter i, java.util.Map variables)
           
protected  java.lang.String translateVariables(java.lang.String s, com.opensymphony.module.propertyset.PropertySet ps)
           
protected  boolean validRole(java.util.List roles)
           
protected  void verifyInputs(WorkflowEntry entry, java.util.List validators, java.util.Map inputs, java.util.List registers)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected WorkflowContext context
Constructor Detail

AbstractWorkflow

public AbstractWorkflow()
Method Detail

loadConfig

protected void loadConfig()

getWorkflow

protected WorkflowDescriptor getWorkflow(java.lang.String name)

createVariableMap

protected java.util.Map createVariableMap(WorkflowEntry entry,
                                          java.util.List registers)

setBshVariables

protected void setBshVariables(bsh.Interpreter i,
                               java.util.Map variables)
                        throws bsh.EvalError

evaluateExpression

protected boolean evaluateExpression(java.lang.String expr,
                                     WorkflowEntry entry,
                                     java.util.List registers)

translateVariables

protected java.lang.String translateVariables(java.lang.String s,
                                              com.opensymphony.module.propertyset.PropertySet ps)

getPersistence

protected Persistence getPersistence()

getPropertySet

public com.opensymphony.module.propertyset.PropertySet getPropertySet(long id)
Specified by:
getPropertySet in interface Workflow

getActionableSteps

public int[] getActionableSteps(java.lang.String workflowName)
Get an array of steps that have actions in the specified workflow
Specified by:
getActionableSteps in interface Workflow
Parameters:
workflowName - The name of the workflow
Returns:
an array of step id's

createEntry

public long createEntry(java.lang.String workflowName)
Create a workflow entry
Specified by:
createEntry in interface Workflow
Parameters:
workflowName - The name of the workflow to create
Returns:
the workflow key id

isInitialized

public boolean isInitialized(long id)
Check if the specified workflow has been initialized
Specified by:
isInitialized in interface Workflow
Parameters:
id - The workflow id
Returns:
true if the workflow has been initialized, false otherwise

canInitialize

public boolean canInitialize(java.lang.String workflowName,
                             int initialState)
Check if the calling user has enough permissions to initialise the specified workflow
Specified by:
canInitialize in interface Workflow
Parameters:
workflowName - The name of the workflow to check
initialState - The id of the initial state to check
Returns:
true if the user can successfully call initialize, false otherwise

initialize

public void initialize(long id,
                       int initialState,
                       java.util.Map inputs)
                throws InvalidRoleException,
                       InvalidInputException
Specified by:
initialize in interface Workflow

doAction

public void doAction(long id,
                     int actionId,
                     java.util.Map inputs)
              throws InvalidInputException
perform an action on the specified workflow
Specified by:
doAction in interface Workflow
Parameters:
id - The workflow id to perform the action on
actionId - The action id to perform (action id's are listed in the workflow descriptor)
inputs -  
Throws:
InvalidInputException -  

getAvailableActions

public int[] getAvailableActions(long id)
Get an array of possible actions for the specified workflow
Specified by:
getAvailableActions in interface Workflow
Parameters:
id - the workflow to get actions for
Returns:
an array of action id's. The collection of action is those that can be performed on the current step

getActionName

public java.lang.String getActionName(long id,
                                      int actionId)
Get a verbose string action name for a specified workflow action within the current step
Specified by:
getActionName in interface Workflow
Parameters:
id - The workflow id to query
actionId - The action id to get the name for
Returns:
the step name

getStepName

public java.lang.String getStepName(long id,
                                    int stepId)
Get a string name for the specified step
Specified by:
getStepName in interface Workflow
Parameters:
id - The workflow id
stepId - The step id
Returns:
the name of the step

getHistory

public WorkflowHistory getHistory(long id)
Get the workflow history
Specified by:
getHistory in interface Workflow
Parameters:
id - the workflow id
Returns:
A WorkflowHistory which contains a list of all steps the workflow has been in

getCurrentStatus

public HistoryStep getCurrentStatus(long id)
Get the current status of the specified workflow
Specified by:
getCurrentStatus in interface Workflow
Parameters:
id - The workflow ID
Returns:
The step that the workflow is currently in

getSecurityPermissions

public java.util.List getSecurityPermissions(long id)
Get a collection of currently defined permissions for the specified workflow
Specified by:
getSecurityPermissions in interface Workflow
Parameters:
id - the workflow ID
Returns:
A List of permissions specified currently (a permission is a string name)

validRole

protected boolean validRole(java.util.List roles)

executeFunction

protected void executeFunction(FunctionDescriptor function,
                               WorkflowEntry entry,
                               java.util.Map inputs,
                               java.util.List registers)

verifyInputs

protected void verifyInputs(WorkflowEntry entry,
                            java.util.List validators,
                            java.util.Map inputs,
                            java.util.List registers)
                     throws InvalidInputException

executeTriggerFunction

public void executeTriggerFunction(long id,
                                   int triggerId)
Specified by:
executeTriggerFunction in interface Workflow

See www.opensymphony.com for more information.