Package com.yworkflow
Interface WorkflowInstances
public interface WorkflowInstances
Manages workflow instances within the yWorkflow engine. This interface provides operations for
creating, retrieving, and managing workflow instances.
A workflow instance is a running execution of a workflow definition. Each instance has its own state, data (attributes), and execution history. Multiple instances can be created from the same workflow definition.
Workflow instances are created using initial transitions, which are special transitions that start a new workflow execution. The instance can then progress through various states by executing transitions.
All operations in this interface can be executed with a specific caller context using the
with(WorkflowCallerContext) method, which allows for access control and audit trails.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanInit(WorkflowDefinitionId workflowDefinitionId, TransitionId initialTransitionId) Checks if a workflow can be initialized with the specified workflow definition ID and initial transition.booleancanInit(WorkflowDefinitionId workflowDefinitionId, TransitionId initialTransitionId, Attributes inputs) Checks if a workflow can be initialized with the specified workflow definition ID, initial transition, and input attributes.get(WorkflowInstanceId workflowInstanceId) Retrieves a workflow instance by its ID.default WorkflowInstanceinit(WorkflowDefinitionId workflowDefinitionId, TransitionId initialTransition) Creates a new workflow instance with the specified workflow definition ID and initial transition.init(WorkflowDefinitionId workflowDefinitionId, TransitionId initialTransition, Attributes inputs) Creates a new workflow instance with the specified workflow definition ID, initial transition, and input attributes.with(WorkflowCallerContext callerContext) Creates a new WorkflowInstances instance that operates with the specified caller context.
-
Method Details
-
get
Retrieves a workflow instance by its ID.- Parameters:
workflowInstanceId- the unique identifier of the workflow instance- Returns:
- the workflow instance
- Throws:
WorkflowException- if an error occurs while retrieving the workflow instance
-
canInit
default boolean canInit(WorkflowDefinitionId workflowDefinitionId, TransitionId initialTransitionId) throws WorkflowException Checks if a workflow can be initialized with the specified workflow definition ID and initial transition. This is a convenience method that uses empty attributes.- Parameters:
workflowDefinitionId- the ID of the workflow definitioninitialTransitionId- the ID of the initial transition- Returns:
- true if the workflow can be initialized, false otherwise
- Throws:
WorkflowException- if an error occurs while checking initialization capability
-
canInit
boolean canInit(WorkflowDefinitionId workflowDefinitionId, TransitionId initialTransitionId, Attributes inputs) throws WorkflowException Checks if a workflow can be initialized with the specified workflow definition ID, initial transition, and input attributes.- Parameters:
workflowDefinitionId- the ID of the workflow definitioninitialTransitionId- the ID of the initial transitioninputs- the input attributes for the workflow instance- Returns:
- true if the workflow can be initialized, false otherwise
- Throws:
WorkflowException- if an error occurs while checking initialization capability
-
init
default WorkflowInstance init(WorkflowDefinitionId workflowDefinitionId, TransitionId initialTransition) throws WorkflowException Creates a new workflow instance with the specified workflow definition ID and initial transition. This is a convenience method that uses empty attributes.- Parameters:
workflowDefinitionId- the ID of the workflow definitioninitialTransition- the initial transition to execute- Returns:
- the newly created workflow instance
- Throws:
WorkflowException- if an error occurs while creating the workflow instance
-
init
WorkflowInstance init(WorkflowDefinitionId workflowDefinitionId, TransitionId initialTransition, Attributes inputs) throws WorkflowException Creates a new workflow instance with the specified workflow definition ID, initial transition, and input attributes.- Parameters:
workflowDefinitionId- the ID of the workflow definitioninitialTransition- the initial transition to executeinputs- the input attributes for the workflow instance- Returns:
- the newly created workflow instance
- Throws:
WorkflowException- if an error occurs while creating the workflow instance
-
with
Creates a new WorkflowInstances instance that operates with the specified caller context. This allows for access control and audit trails for workflow instance operations.- Parameters:
callerContext- the caller context to use for operations- Returns:
- a new WorkflowInstances instance with the specified caller context
-