Package com.yworkflow.instance
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.
-
Method Summary
Modifier and TypeMethodDescriptioncreateStateInstance(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId, StateId stateId, List<String> owners, Instant startedAt, Instant dueAt, ResultStatus enterStatus, List<StateInstanceId> previousIds, Attributes inputs) Creates a new state instance within a workflow instance.createWorkflowInstanceEntity(WorkflowCallerContext callerContext, WorkflowDefinitionId workflowDefinitionId, Attributes inputs) Creates a new workflow instance entity.findHistoryStateInstances(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId) Finds all historical state instances for a workflow instance.findLastHistoryStateInstances(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId) Finds the last historical state instance for each state in a workflow instance.findStateInstances(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId) Finds all active state instances for a workflow instance.findWorkflowInstanceEntity(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId) Finds a workflow instance entity by its ID.getAttributes(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId) Retrieves the mutable attributes for a workflow instance.voidinit(WorkflowClock clock, Properties props) Initializes the workflow instance store with the provided clock and properties.markCompleted(WorkflowCallerContext callerContext, StateInstance stateInstance, TransitionId transitionId, Instant completedAt, ResultStatus exitStatus) Marks a state instance as completed with the specified transition and status.moveToHistory(WorkflowCallerContext callerContext, StateInstance stateInstance) Moves a state instance to the history, marking it as no longer active.updateWorkflowInstanceStatus(WorkflowCallerContext callerContext, WorkflowInstanceId workflowInstanceId, WorkflowInstanceStatus status) Updates the status of a workflow instance.
-
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 requestworkflowInstanceId- the ID of the workflow instance to updatestatus- 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 requestworkflowInstanceId- 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 requestworkflowInstanceId- the ID of the workflow instancestateId- the ID of the state to create an instance forowners- the list of users responsible for this state instancestartedAt- the timestamp when the state instance was starteddueAt- the timestamp when the state instance is dueenterStatus- the status when entering this statepreviousIds- the list of previous state instance IDsinputs- 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 requestworkflowDefinitionId- the ID of the workflow definitioninputs- 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 requestworkflowInstanceId- 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 requestworkflowInstanceId- 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 requestworkflowInstanceId- 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 requestworkflowInstanceId- the ID of the workflow instance- Returns:
- a map of state IDs to their last historical state instances
-
init
Initializes the workflow instance store with the provided clock and properties.- Parameters:
clock- the workflow clock for time operationsprops- 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 requeststateInstance- the state instance to mark as completedtransitionId- the transition that led to completioncompletedAt- the timestamp when the state was completedexitStatus- the status when exiting this state- Returns:
- the updated state instance
-
moveToHistory
Moves a state instance to the history, marking it as no longer active.- Parameters:
callerContext- the context of the caller making the requeststateInstance- the state instance to move to history- Returns:
- the updated state instance
-