Package com.orchestranetworks.workflow

# Class WorkflowTriggerBean

java.lang.Object
com.orchestranetworks.workflow.WorkflowTriggerBean

public abstract class WorkflowTriggerBean extends Object
Defines a specific workflow trigger to be called at each main event in the life cycle of a workflow instance.

This abstract class must be extended to define a custom workflow trigger.

Extended versions of this class need to be registered in file `module.xml` using a `<bean>` element located at `/module/beans`.

A workflow model can be associated to a registered custom trigger class using the workflow model configuration user interface.

### Life cycle

At each main event concerning a workflow instance, the system checks if the corresponding workflow model is associated to a trigger class.

If yes, the trigger object is automatically instantiated and the method corresponding to the event type is called.

The trigger object is then discarded.

When a sub-workflow is executed, only the trigger of the sub-workflow is called (not the trigger of the parent workflow).

### Known limitation

The events associated to the "unpublish" and "replay a step" actions are not managed. For example, if a workflow instance is deleted after an "unpublish" action, the "handleBeforeProcessInstanceTermination" method will not be called.

Since:
  5.5.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WorkflowTriggerBean()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract void`
  `handleAfterProcessInstanceStart(WorkflowTriggerAfterProcessInstanceStartContext aContext)`
  This method is called to notify the creation of a workflow instance.
  `abstract void`
  `handleAfterWorkItemCreation(WorkflowTriggerAfterWorkItemCreationContext aContext)`
  This method is called when the workflow reaches a user task and creates its work items.
  `abstract void`
  `handleBeforeProcessInstanceTermination(WorkflowTriggerBeforeProcessInstanceTerminationContext aContext)`
  This method is called to notify the completion of a workflow instance.
  `abstract void`
  `handleBeforeWorkItemAllocation(WorkflowTriggerBeforeWorkItemAllocationContext aContext)`
  This method is called to notify the allocation of a work item.
  `abstract void`
  `handleBeforeWorkItemDeallocation(WorkflowTriggerBeforeWorkItemDeallocationContext aContext)`
  This method is called to notify the deallocation of a work item.
  `abstract void`
  `handleBeforeWorkItemReallocation(WorkflowTriggerBeforeWorkItemReallocationContext aContext)`
  This method is called to notify the reallocation of a work item.
  `abstract void`
  `handleBeforeWorkItemStart(WorkflowTriggerBeforeWorkItemStartContext aContext)`
  This method is called to notify the start of a work item.
  `abstract void`
  `handleBeforeWorkItemTermination(WorkflowTriggerBeforeWorkItemTerminationContext aContext)`
  This method is called to notify the termination of a work item.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### WorkflowTriggerBean

    public WorkflowTriggerBean()

- ## Method Details

  - ### handleAfterProcessInstanceStart

    public abstract void handleAfterProcessInstanceStart(WorkflowTriggerAfterProcessInstanceStartContext aContext) throws OperationException
    This method is called to notify the creation of a workflow instance.

    When this method is called, workflow instance is fully initialized and the token is in the "to execute" state (this means that the workflow instance has not yet begun the first step).

    Parameters:
      `aContext` - the context of the workflow instance.
    Throws:
      `OperationException` - This exception may be thrown to notify an error. The workflow instance and token are then deleted. If the workflow is a sub-workflow, the parent workflow is set to the "error" state and all its other sub-workflows are also deleted.

  - ### handleBeforeProcessInstanceTermination

    public abstract void handleBeforeProcessInstanceTermination(WorkflowTriggerBeforeProcessInstanceTerminationContext aContext) throws OperationException
    This method is called to notify the completion of a workflow instance.

    More specifically, this method is called when one of the following occurs:

    - the workflow instance has reached the end specified by the workflow model;
    - the workflow instance termination has been forced by an administrator.

    If the workflow termination is forced by an administration action all its sub-workflows triggers will be recursively called.

    Parameters:
      `aContext` - the context of the workflow instance.
    Throws:
      `OperationException` - This exception may be thrown to notify an error. The workflow instance's token is then set to the "error" state and the workflow is not terminated.

      An administrator can correct the issue and the force termination using menus "Force termination" or "Terminate and clean". This method will then be called again. The workflow instance will not terminate until this method executes normally.

  - ### handleAfterWorkItemCreation

    public abstract void handleAfterWorkItemCreation(WorkflowTriggerAfterWorkItemCreationContext aContext) throws OperationException
    This method is called when the workflow reaches a user task and creates its work items. It is called once for each work item.
    Parameters:
      `aContext` - the context of the work item.
    Throws:
      `OperationException` - This exception may be thrown to notify an error. In this case, all work items already created for the current user task are deleted. The action menu "Replay the step" must be used to relaunch the user task. Until then, the workflow will be halted.
    Since:
      5.5.1

  - ### handleBeforeWorkItemStart

    public abstract void handleBeforeWorkItemStart(WorkflowTriggerBeforeWorkItemStartContext aContext) throws OperationException
    This method is called to notify the start of a work item.

    More specifically, this method is called when a user opens a work item for the first time using the button "Take and Start" (if the work item is offered to the user) or "Start" (if the work item is allocated to the user).

    Parameters:
      `aContext` - the context of the work item.
    Throws:
      `OperationException` - This exception may be thrown to notify an error. If an error occurs, the work item is not started and stays in the current state. It will need to be started again until this method succeeds.
    Since:
      5.5.1

  - ### handleBeforeWorkItemAllocation

    public abstract void handleBeforeWorkItemAllocation(WorkflowTriggerBeforeWorkItemAllocationContext aContext) throws OperationException
    This method is called to notify the allocation of a work item.

    More specifically, this method is called when one of the following occurs:

    - A user takes and starts a work item which is offered to himself,
    - An administrator allocates a work item to a user using the administration action "allocate".
    Parameters:
      `aContext` - the context of the work item.
    Throws:
      `OperationException` - This exception may be thrown to notify an error. If an error occurs, the work item is not allocated and stays in the current state. It will need to be allocated again until this method succeeds.
    Since:
      5.5.1

  - ### handleBeforeWorkItemDeallocation

    public abstract void handleBeforeWorkItemDeallocation(WorkflowTriggerBeforeWorkItemDeallocationContext aContext) throws OperationException
    This method is called to notify the deallocation of a work item.

    More specifically, this method is called when an administrator deallocates a work item using the administration action "Deallocate".

    Parameters:
      `aContext` - the context of the work item.
    Throws:
      `OperationException` - This exception may be thrown to notify an error. If an error occurs, the work item is not deallocated and stays in the current state. The work item needs to be deallocated again until this method succeeds.
    Since:
      5.5.1

  - ### handleBeforeWorkItemReallocation

    public abstract void handleBeforeWorkItemReallocation(WorkflowTriggerBeforeWorkItemReallocationContext aContext) throws OperationException
    This method is called to notify the reallocation of a work item.

    More specifically, this method is called when an administrator reallocates a work item using the administration action "Reallocate".

    Parameters:
      `aContext` - the context of the work item.
    Throws:
      `OperationException` - This exception may be thrown to notify an error. If an error occurs, the work item is not reallocated and stays in the current state. The work item needs to be reallocated again until this method succeeds.
    Since:
      5.5.1

  - ### handleBeforeWorkItemTermination

    public abstract void handleBeforeWorkItemTermination(WorkflowTriggerBeforeWorkItemTerminationContext aContext) throws OperationException
    This method is called to notify the termination of a work item.

    More specifically, this method is called when a user completes a work item using the button "Accept" or 'Reject".

    Parameters:
      `aContext` - the context of the work item.
    Throws:
      `OperationException` - This exception may be thrown to notify an error. If an error occurs, the work item is not terminated and stays in the current state. Previous action needs to be resubmitted until this method succeeds.
    Since:
      5.5.1