Interface WorkflowInstanceStore


public interface WorkflowInstanceStore
Interface for storing and managing workflow instance data. WorkflowInstanceStore provides persistence operations for workflow instances, including state instances, attributes, and workflow instance entities.
Since:
1.0
See Also:
  • Method Details

    • updateWorkflowInstanceStatus

      WorkflowInstanceStoreEntity updateWorkflowInstanceStatus(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId, WorkflowInstanceStatus status)
      Updates the status of a workflow instance.
      Parameters:
      callerContext - the context of the caller making the request
      workflowInstanceId - the ID of the workflow instance to update
      status - the new status to set for the workflow instance
      Returns:
      the updated workflow instance store entity
    • getAttributes

      MutableAttributes getAttributes(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId)
      Retrieves the mutable attributes for a workflow instance.
      Parameters:
      callerContext - the context of the caller making the request
      workflowInstanceId - the ID of the workflow instance
      Returns:
      the mutable attributes for the workflow instance
    • createStateInstance

      StateInstance createStateInstance(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId, StateId stateId, List<String> owners, Instant startedAt, Instant dueAt, ResultStatus enterStatus, List<StateInstanceId> previousIds, Attributes inputs) throws WorkflowException
      Creates a new state instance within a workflow instance.
      Parameters:
      callerContext - the context of the caller making the request
      workflowInstanceId - the ID of the workflow instance
      stateId - the ID of the state to create an instance for
      owners - the list of users responsible for this state instance
      startedAt - the timestamp when the state instance was started
      dueAt - the timestamp when the state instance is due
      enterStatus - the status when entering this state
      previousIds - the list of previous state instance IDs
      inputs - the immutable attributes containing input data
      Returns:
      the created state instance
      Throws:
      WorkflowException - if the creation operation fails
    • createWorkflowInstanceEntity

      WorkflowInstanceStoreEntity createWorkflowInstanceEntity(WorkflowCallerContext callerContext, WorkflowDefinitionId workflowDefinitionId, Attributes inputs) throws WorkflowException
      Creates a new workflow instance entity.
      Parameters:
      callerContext - the context of the caller making the request
      workflowDefinitionId - the ID of the workflow definition
      inputs - the immutable attributes containing input data for the workflow instance
      Returns:
      the created workflow instance store entity
      Throws:
      WorkflowException - if the creation operation fails
    • findStateInstances

      List<StateInstance> findStateInstances(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId)
      Finds all active state instances for a workflow instance.
      Parameters:
      callerContext - the context of the caller making the request
      workflowInstanceId - the ID of the workflow instance
      Returns:
      a list of active state instances for the workflow instance
    • findWorkflowInstanceEntity

      Optional<WorkflowInstanceStoreEntity> findWorkflowInstanceEntity(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId)
      Finds a workflow instance entity by its ID.
      Parameters:
      callerContext - the context of the caller making the request
      workflowInstanceId - the ID of the workflow instance
      Returns:
      an Optional containing the workflow instance entity if found
    • findHistoryStateInstances

      List<StateInstance> findHistoryStateInstances(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId)
      Finds all historical state instances for a workflow instance.
      Parameters:
      callerContext - the context of the caller making the request
      workflowInstanceId - the ID of the workflow instance
      Returns:
      a list of historical state instances for the workflow instance
    • findLastHistoryStateInstances

      Map<StateId,StateInstance> findLastHistoryStateInstances(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId)
      Finds the last historical state instance for each state in a workflow instance.
      Parameters:
      callerContext - the context of the caller making the request
      workflowInstanceId - the ID of the workflow instance
      Returns:
      a map of state IDs to their last historical state instances
    • init

      void init(WorkflowClock clock, Properties props)
      Initializes the workflow instance store with the provided clock and properties.
      Parameters:
      clock - the workflow clock for time operations
      props - the configuration properties for the store
    • markCompleted

      StateInstance markCompleted(WorkflowCallerContext callerContext, StateInstance stateInstance, TransitionId transitionId, Instant completedAt, ResultStatus exitStatus)
      Marks a state instance as completed with the specified transition and status.
      Parameters:
      callerContext - the context of the caller making the request
      stateInstance - the state instance to mark as completed
      transitionId - the transition that led to completion
      completedAt - the timestamp when the state was completed
      exitStatus - the status when exiting this state
      Returns:
      the updated state instance
    • moveToHistory

      StateInstance moveToHistory(WorkflowCallerContext callerContext, StateInstance stateInstance)
      Moves a state instance to the history, marking it as no longer active.
      Parameters:
      callerContext - the context of the caller making the request
      stateInstance - the state instance to move to history
      Returns:
      the updated state instance