Interface WorkflowInstance


public interface WorkflowInstance
Represents a running workflow instance. A workflow instance is a single execution of a workflow definition, with its own state, data (attributes), and execution history.
Since:
1.0
See Also:
  • Method Details

    • getTenantId

      TenantId getTenantId()
      Returns the tenant ID associated with this workflow instance.
      Returns:
      the tenant ID
    • getId

      Returns the unique identifier of this workflow instance.
      Returns:
      the workflow instance ID
    • getWorkflowDefinitionId

      WorkflowDefinitionId getWorkflowDefinitionId()
      Returns the ID of the workflow definition that this instance is based on.
      Returns:
      the workflow definition ID
    • getStatusInfo

      Returns the current status of this workflow instance.
      Returns:
      the workflow instance status information
    • getStateInstances

      List<StateInstance> getStateInstances()
      Returns the list of currently active state instances.
      Returns:
      the list of active state instances
    • getHistory

      List<StateInstance> getHistory()
      Returns the execution history of this workflow instance.
      Returns:
      the list of historical state instances
    • attributes

      MutableAttributes attributes()
      Returns the mutable attributes of this workflow instance. These attributes persist across workflow invocations.
      Returns:
      the mutable attributes
    • getCapabilities

      default List<String> getCapabilities() throws WorkflowException
      Returns the capabilities available to this workflow instance. This is a convenience method that uses empty inputs.
      Returns:
      the list of available capabilities
      Throws:
      WorkflowException - if an error occurs while retrieving capabilities
    • getCapabilities

      List<String> getCapabilities(Attributes inputs) throws WorkflowException
      Returns the capabilities available to this workflow instance with the given inputs.
      Parameters:
      inputs - the input attributes to consider when determining capabilities
      Returns:
      the list of available capabilities
      Throws:
      WorkflowException - if an error occurs while retrieving capabilities
    • canModifyStatus

      boolean canModifyStatus(WorkflowInstanceStatus newStatus)
      Checks if the workflow instance status can be modified to the specified status.
      Parameters:
      newStatus - the new status to check
      Returns:
      true if the status can be modified, false otherwise
    • changeStatus

      void changeStatus(WorkflowInstanceStatus newStatus) throws WorkflowException
      Changes the status of this workflow instance to the specified status.
      Parameters:
      newStatus - the new status to set
      Throws:
      WorkflowException - if the status change is not allowed or an error occurs
    • transition

      void transition(TransitionId transitionId, Attributes inputs) throws WorkflowException
      Executes a transition with the specified ID and input attributes.
      Parameters:
      transitionId - the ID of the transition to execute
      inputs - the input attributes for the transition
      Throws:
      WorkflowException - if the transition cannot be executed or an error occurs
    • transition

      default void transition(TransitionId transitionId) throws WorkflowException
      Executes a transition with the specified ID using empty inputs. This is a convenience method.
      Parameters:
      transitionId - the ID of the transition to execute
      Throws:
      WorkflowException - if the transition cannot be executed or an error occurs
    • executeTriggerFunction

      void executeTriggerFunction(String triggerId) throws WorkflowException
      Executes a trigger function with the specified ID.
      Parameters:
      triggerId - the ID of the trigger function to execute
      Throws:
      WorkflowException - if the trigger function cannot be executed or an error occurs
    • getAvailableTransitions

      List<TransitionId> getAvailableTransitions(Attributes inputs) throws WorkflowException
      Returns the list of transitions that are currently available for execution with the given input attributes.
      Parameters:
      inputs - the input attributes to consider when determining available transitions
      Returns:
      the list of available transition IDs
      Throws:
      WorkflowException - if an error occurs while determining available transitions
    • getAvailableTransitions

      default List<TransitionId> getAvailableTransitions() throws WorkflowException
      Returns the list of transitions that are currently available for execution. This is a convenience method that uses empty inputs.
      Returns:
      the list of available transition IDs
      Throws:
      WorkflowException - if an error occurs while determining available transitions
    • actAs

      Creates a new WorkflowInstance view that operates as the specified caller. This allows for role-based access control and different permissions.
      Parameters:
      caller - the caller to act as
      Returns:
      a new WorkflowInstance view with the specified caller context