org.apache.fulcrum.osworkflow
Class WorkflowInstance

java.lang.Object
  extended byorg.apache.fulcrum.osworkflow.WorkflowInstance

public class WorkflowInstance
extends java.lang.Object

WorkflowInstance represents a specific instance of a workflow. Therefore it has all the context information like what state it is in, what it's actions are etc.

Version:
$Id: WorkflowInstance.java 535465 2007-05-05 06:58:06Z tv $
Author:
Eric Pugh

Constructor Summary
WorkflowInstance(Workflow workflow, long id)
          Simple constructor to create a workflow instance with the workflow, and the id of an instance of the workflow.
 
Method Summary
 boolean canInitialize(java.lang.String workflowName, int initialStep)
           
 boolean canModifyEntryState(int step)
          Whether you can modify the entry state of this workflow instance
 void changeEntryState(int entryState)
          Modify the state of the specified workflow instance.
 void doAction(int actionId, java.util.Map inputs)
          Perform an action on the the workflow instance.
 boolean equals(java.lang.Object obj)
          Returns whether another workflow equals this workflow.
 void executeTriggerFunction(int triggerId)
          Executes a special trigger-function using the context of the workflow instance.
 java.util.List getAllAvailableActions()
          Get the available actions for the workflow instance.
 int[] getAvailableActions(java.util.Map inputs)
          Get the available actions for the workflow instance.
 java.util.List getCurrentSteps()
          Returns a Collection of Step objects that are the current steps of the workflow instance.
 int getEntryState()
          Return the state of the workflow instance.
 java.util.List getHistorySteps()
          Returns a list of all steps that are completed for the workflow instance.
 long getId()
           
 com.opensymphony.module.propertyset.PropertySet getPropertySet()
          Get the PropertySet for the workflow instance.
 java.util.List getSecurityPermissions()
          Get a collection (Strings) of currently defined permissions for the workflow instance.
 WorkflowDescriptor getWorkflowDescriptor()
          Get the workflow descriptor for the workflow instance.
 java.lang.String getWorkflowName()
          Get the name of the specified workflow instance.
 int hashCode()
           
 java.util.List query(WorkflowQuery query)
          Execute a workflow query and returns the list of workflows
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WorkflowInstance

public WorkflowInstance(Workflow workflow,
                        long id)
Simple constructor to create a workflow instance with the workflow, and the id of an instance of the workflow.

Parameters:
workflow - The workflow this instance belongs to
id - The id of this workflow instance
Method Detail

getId

public long getId()
Returns:
long id of this workflow

canInitialize

public boolean canInitialize(java.lang.String workflowName,
                             int initialStep)
                      throws WorkflowException
Returns:
boolean whether we can initialize at this step or not
Throws:
WorkflowException - If there is a problem

canModifyEntryState

public boolean canModifyEntryState(int step)
                            throws WorkflowException
Whether you can modify the entry state of this workflow instance

Returns:
Whether we can modify the entry state
Throws:
WorkflowException - If there is a problem

changeEntryState

public void changeEntryState(int entryState)
                      throws WorkflowException
Modify the state of the specified workflow instance.

Parameters:
entryState - the new state to change the workflow instance to.
Throws:
WorkflowException - If a problem occurs

doAction

public void doAction(int actionId,
                     java.util.Map inputs)
              throws InvalidInputException,
                     WorkflowException
Perform an action on the the workflow instance.

Parameters:
actionId - The action id to perform (action id's are listed in the workflow descriptor).
inputs - The inputs to the workflow instance.
Throws:
InvalidInputException - if a validator is specified and an input is invalid.
WorkflowException - If a problem occurs

equals

public boolean equals(java.lang.Object obj)
Returns whether another workflow equals this workflow. Doesn't compare the id's.

See Also:
Object.equals(java.lang.Object)

executeTriggerFunction

public void executeTriggerFunction(int triggerId)
                            throws WorkflowException
Executes a special trigger-function using the context of the workflow instance.

Parameters:
triggerId - The id of the special trigger-function
Throws:
WorkflowException - If there is a problem

getAvailableActions

public int[] getAvailableActions(java.util.Map inputs)
                          throws WorkflowException
Get the available actions for the workflow instance.

Parameters:
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:
java.lang.IllegalArgumentException - if the specified id does not exist, or if its workflow descriptor is no longer available or has become invalid.
WorkflowException - If there is a problem

getCurrentSteps

public java.util.List getCurrentSteps()
                               throws WorkflowException
Returns a Collection of Step objects that are the current steps of the workflow instance.

Returns:
The steps that the workflow instance is currently in.
Throws:
WorkflowException - If there is a problem

getEntryState

public int getEntryState()
                  throws WorkflowException
Return the state of the workflow instance.

Returns:
int The state id of the specified workflow
Throws:
WorkflowException - If there is a problem

getHistorySteps

public java.util.List getHistorySteps()
                               throws WorkflowException
Returns a list of all steps that are completed for the workflow instance.

Returns:
a List of Steps
Throws:
WorkflowException - If there is a problem
See Also:
Step

getPropertySet

public com.opensymphony.module.propertyset.PropertySet getPropertySet()
                                                               throws WorkflowException
Get the PropertySet for the workflow instance.

Throws:
WorkflowException - If there is a problem

getSecurityPermissions

public java.util.List getSecurityPermissions()
                                      throws WorkflowException
Get a collection (Strings) of currently defined permissions for the workflow instance.

Returns:
A List of permissions specified currently (a permission is a string name).
Throws:
WorkflowException - If there is a problem

getWorkflowDescriptor

public WorkflowDescriptor getWorkflowDescriptor()
                                         throws WorkflowException
Get the workflow descriptor for the workflow instance.

Throws:
WorkflowException - If there is a problem

getWorkflowName

public java.lang.String getWorkflowName()
                                 throws WorkflowException
Get the name of the specified workflow instance.

Returns:
The name
Throws:
WorkflowException - If there is a problem

hashCode

public int hashCode()
See Also:
Object.hashCode()

query

public java.util.List query(WorkflowQuery query)
                     throws WorkflowException
Execute a workflow query and returns the list of workflows

Parameters:
query - The workflow query
Returns:
a List of workflows
Throws:
WorkflowException - If there is a problem

toString

public java.lang.String toString()
See Also:
Object.toString()

getAllAvailableActions

public java.util.List getAllAvailableActions()
                                      throws WorkflowException
Get the available actions for the workflow instance.

Returns:
An list of actions that can be performed on the specified entry
Throws:
java.lang.IllegalArgumentException - if the specified id does not exist, or if its workflow descriptor is no longer available or has become invalid.
WorkflowException - If there is a problem


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.