Interface WorkflowStateProvider

All Superinterfaces:
Provider
All Known Implementing Classes:
JpaWorkflowStateProvider

public interface WorkflowStateProvider extends Provider
Defines a provider interface for managing workflow execution state and scheduled steps.

Implementations of this interface are responsible for persisting and retrieving workflow state information, including scheduled steps that need to be executed at specific times. This provider acts as the state management layer for workflow executions within a realm.
  • Method Details

    • removeByResource

      void removeByResource(String resourceId)
      Deletes all state records associated with the given resource ID.

      This method removes all workflow state information for the specified resource, regardless of which workflows the resource is associated with.
      Parameters:
      resourceId - the ID of the resource whose state records should be deleted
    • removeByWorkflowAndResource

      void removeByWorkflowAndResource(String workflowId, String resourceId)
      Deletes the state record associated with a specific workflow and resource combination.

      This method removes only the state information for the specified resource within the context of the specified workflow, leaving state records for other workflows intact.
      Parameters:
      workflowId - the ID of the workflow
      resourceId - the ID of the resource
    • removeByWorkflow

      void removeByWorkflow(String workflowId)
      Removes all state records associated with the specified workflow.

      This method deletes all state information for the given workflow across all resources.
      Parameters:
      workflowId - the ID of the workflow whose state records should be deleted
    • remove

      void remove(String executionId)
      Removes the state record identified by the specified execution ID.

      This method deletes a specific workflow execution state record.
      Parameters:
      executionId - the ID of the execution whose state record should be deleted
    • removeAll

      void removeAll()
      Deletes all workflow state records associated with the current realm.

      This method removes all workflow state information for the realm bound to the current session.
    • hasScheduledSteps

      boolean hasScheduledSteps(String workflowId)
      Checks whether there are any scheduled steps for the given workflow.
      Parameters:
      workflowId - the ID of the workflow to check
      Returns:
      true if there are scheduled steps for this workflow, false otherwise
    • scheduleStep

      WorkflowStateProvider.ScheduleResult scheduleStep(Workflow workflow, WorkflowStep step, String resourceId, String executionId)
      Schedules a workflow step for future execution.

      This method persists the scheduling information for a step that should be executed at a later time, typically based on the step's configuration (e.g., delay settings).
      Parameters:
      workflow - the workflow containing the step
      step - the workflow step to schedule
      resourceId - the ID of the resource associated with this scheduled step
      executionId - the ID of the workflow execution
      Returns:
      CREATED if the execution was created (when the workflow first activates for a resource), {@code UPDATED) if it was just updated.
    • getScheduledStep

      WorkflowStateProvider.ScheduledStep getScheduledStep(String workflowId, String resourceId)
      Retrieves the scheduled step for a specific workflow and resource combination.
      Parameters:
      workflowId - the ID of the workflow
      resourceId - the ID of the resource
      Returns:
      the scheduled step, or null if no step is scheduled for this combination
    • getScheduledStepsByResource

      Stream<WorkflowStateProvider.ScheduledStep> getScheduledStepsByResource(String resourceId)
      Retrieves all scheduled steps associated with the specified resource.
      Parameters:
      resourceId - the ID of the resource
      Returns:
      a stream of scheduled steps for the given resource
    • getScheduledStepsByWorkflow

      Stream<WorkflowStateProvider.ScheduledStep> getScheduledStepsByWorkflow(String workflowId)
      Retrieves all scheduled steps associated with the specified workflow.
      Parameters:
      workflowId - the ID of the workflow
      Returns:
      a stream of scheduled steps for the given workflow
    • getScheduledStepsByStep

      Stream<WorkflowStateProvider.ScheduledStep> getScheduledStepsByStep(String workflowId, String stepId)
      Retrieves all scheduled steps for a specific step within a workflow.
      Parameters:
      workflowId - the ID of the workflow
      stepId - the ID of the step
      Returns:
      a stream of scheduled steps matching the workflow and step IDs
    • getDueScheduledSteps

      Stream<WorkflowStateProvider.ScheduledStep> getDueScheduledSteps(Workflow workflow)
      Retrieves all scheduled steps that are due for execution for the given workflow.

      This method returns steps whose scheduled execution time has been reached or passed.
      Parameters:
      workflow - the workflow to check for due steps
      Returns:
      a stream of scheduled steps that are due for execution