Interface WorkflowDefinition
- All Superinterfaces:
CanCopy<WorkflowDefinition>,HasId<WorkflowDefinitionId>,Model<WorkflowDefinition,,WorkflowDefinitionId> Validatable
- All Known Subinterfaces:
MutableWorkflowDefinition
A workflow definition is a static blueprint that describes how a business process should be executed. It defines the possible states, the transitions between states, the conditions for those transitions, and the functions to be executed during the workflow lifecycle.
Workflows support various types of transitions:
- Initial Transitions - Used to start workflow instances
- State Transitions - Transitions within specific states
- Common Transitions - Transitions available from multiple states
- Global Transitions - Transitions available from any state
Workflows also support parallel execution through forks and joins, allowing complex business processes to be modeled with multiple concurrent paths.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanInitialize(WorkflowExecutionContext context, TransitionId initialTransitionId) Checks if the workflow can be initialized with the specified transition and attributes.diff(WorkflowDefinition other) Compares this workflow with another workflow and returns the differences.getAvailableGlobalTransition(WorkflowExecutionContext context, TransitionId transitionId) Gets an available global transition for the specified transition ID and attributes.getCommonTransition(TransitionId transitionId) Gets a common transition by its ID.Gets all common transitions in the workflow.Gets a fork by its ID.getForks()Gets all forks in the workflow.Gets the global conditions for the workflow.Gets all global transitions in the workflow.getInitialTransition(TransitionId initialTransitionId) Gets an initial transition by its ID.Gets all initial transitions in the workflow.Gets a join by its ID.getJoins()Gets all joins in the workflow.Gets the meta attributes of the workflow.getName()Gets the name of the workflow.Gets all attribute registers in the workflow.Gets a state by its StateId.Gets a state by its string ID.Gets all states in the workflow.Gets a trigger function by its ID.Gets all trigger functions in the workflow.Creates a new WorkflowDefinitionBuilder initialized with the current workflow definition.Methods inherited from interface com.yworkflow.definition.model.base.Model
getExtensions, getParent, getProperties, getPropertyDifferenceMethods inherited from interface com.yworkflow.definition.model.validation.Validatable
validate
-
Method Details
-
getAvailableGlobalTransition
Optional<Transition> getAvailableGlobalTransition(WorkflowExecutionContext context, TransitionId transitionId) throws WorkflowException Gets an available global transition for the specified transition ID and attributes. Global transitions are available from any state in the workflow.- Parameters:
transitionId- the ID of the transition to retrievecontext- the execution context- Returns:
- an Optional containing the transition if available and conditions are met
- Throws:
WorkflowException- if there's an error evaluating the transition
-
getCommonTransition
Gets a common transition by its ID. Common transitions are available from multiple states but not all states.- Parameters:
transitionId- the ID of the transition to retrieve- Returns:
- an Optional containing the transition if found
-
getJoin
Gets a join by its ID.- Parameters:
id- the ID of the join to retrieve- Returns:
- an Optional containing the join if found
-
getFork
Gets a fork by its ID.- Parameters:
id- the ID of the fork to retrieve- Returns:
- an Optional containing the fork if found
-
getState
Gets a state by its StateId.- Parameters:
id- the StateId of the state to retrieve- Returns:
- an Optional containing the state if found
-
getState
Gets a state by its string ID.- Parameters:
stateId- the string ID of the state to retrieve- Returns:
- an Optional containing the state if found
-
getTriggerFunction
Gets a trigger function by its ID.- Parameters:
id- the ID of the trigger function to retrieve- Returns:
- an Optional containing the function if found
-
canInitialize
boolean canInitialize(WorkflowExecutionContext context, TransitionId initialTransitionId) throws WorkflowException Checks if the workflow can be initialized with the specified transition and attributes.- Parameters:
initialTransitionId- the ID of the initial transition to checkcontext- the execution context- Returns:
- true if the workflow can be initialized, false otherwise
- Throws:
WorkflowException- if there's an error checking initialization
-
getInitialTransition
Gets an initial transition by its ID.- Parameters:
initialTransitionId- the ID of the initial transition to retrieve- Returns:
- an Optional containing the initial transition if found
-
getInitialTransitions
List<Transition> getInitialTransitions()Gets all initial transitions in the workflow.- Returns:
- a list containing all initial transitions
-
getGlobalTransitions
List<Transition> getGlobalTransitions()Gets all global transitions in the workflow.- Returns:
- a list containing all global transitions
-
getCommonTransitions
List<Transition> getCommonTransitions()Gets all common transitions in the workflow.- Returns:
- a list containing all common transitions
-
getStates
Gets all states in the workflow.- Returns:
- a list containing all states
-
getForks
Gets all forks in the workflow.- Returns:
- a list containing all forks
-
getJoins
Gets all joins in the workflow.- Returns:
- a list containing all joins
-
getName
String getName()Gets the name of the workflow.- Returns:
- the workflow name
-
getMetaAttributes
Gets the meta attributes of the workflow.- Returns:
- a map of meta attributes
-
getRegisters
Gets all attribute registers in the workflow.- Returns:
- a list containing all registers
-
getTriggerFunctions
Gets all trigger functions in the workflow.- Returns:
- a list containing all trigger functions
-
getGlobalConditions
Conditions getGlobalConditions()Gets the global conditions for the workflow.- Returns:
- the global conditions
-
diff
Compares this workflow with another workflow and returns the differences.- Parameters:
other- the other workflow to compare with- Returns:
- a WorkflowDiffResult containing the differences
-
toBuilder
WorkflowDefinitionBuilder toBuilder()Creates a new WorkflowDefinitionBuilder initialized with the current workflow definition. This method allows for easy modification of existing workflow definitions by providing a builder that starts with the current state of the workflow.The returned builder can be used to modify the workflow definition by adding, removing, or modifying states, transitions, forks, joins, and other workflow elements. After making the desired changes, call
WorkflowDefinitionBuilder.build()to create a new WorkflowDefinition instance.This is particularly useful for:
- Creating variations of existing workflows
- Implementing workflow versioning
- Making incremental changes to workflow definitions
- Returns:
- a new WorkflowDefinitionBuilder initialized with this workflow's current state
- See Also:
-