Interface WorkflowDefinition

All Superinterfaces:
CanCopy<WorkflowDefinition>, HasId<WorkflowDefinitionId>, Model<WorkflowDefinition,WorkflowDefinitionId>, Validatable
All Known Subinterfaces:
MutableWorkflowDefinition

public interface WorkflowDefinition extends Model<WorkflowDefinition,WorkflowDefinitionId>
Represents a complete workflow definition. Workflow is the root model element that contains all the components needed to define a business process, including states, transitions, forks, joins, and other workflow elements.

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 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 retrieve
      context - 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

      Optional<Transition> getCommonTransition(TransitionId transitionId)
      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

      Optional<Join> getJoin(JoinId id)
      Gets a join by its ID.
      Parameters:
      id - the ID of the join to retrieve
      Returns:
      an Optional containing the join if found
    • getFork

      Optional<Fork> getFork(ForkId id)
      Gets a fork by its ID.
      Parameters:
      id - the ID of the fork to retrieve
      Returns:
      an Optional containing the fork if found
    • getState

      Optional<State> getState(StateId id)
      Gets a state by its StateId.
      Parameters:
      id - the StateId of the state to retrieve
      Returns:
      an Optional containing the state if found
    • getState

      Optional<State> getState(String stateId)
      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

      Optional<Function> getTriggerFunction(String id)
      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 check
      context - the execution context
      Returns:
      true if the workflow can be initialized, false otherwise
      Throws:
      WorkflowException - if there's an error checking initialization
    • getInitialTransition

      Optional<Transition> getInitialTransition(TransitionId initialTransitionId)
      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

      List<State> getStates()
      Gets all states in the workflow.
      Returns:
      a list containing all states
    • getForks

      List<Fork> getForks()
      Gets all forks in the workflow.
      Returns:
      a list containing all forks
    • getJoins

      List<Join> 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

      Map<String,String> getMetaAttributes()
      Gets the meta attributes of the workflow.
      Returns:
      a map of meta attributes
    • getRegisters

      List<Register> getRegisters()
      Gets all attribute registers in the workflow.
      Returns:
      a list containing all registers
    • getTriggerFunctions

      List<Function> 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

      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: