Class WorkflowExecutionContext

java.lang.Object
de.xima.fc.workflow.processor.logic.execution.WorkflowExecutionContext
All Implemented Interfaces:
IBaseWorkflowExecutionContext, IWorkflowExecutionContext, Closeable, AutoCloseable

public final class WorkflowExecutionContext extends Object implements IWorkflowExecutionContext
Default implementation of IWorkflowExecutionContext that is used by the WorkflowTaskRunner. Contains the state that needs to be kept during workflow execution.
Since:
7.0.0
Author:
XIMA MEDIA GmbH
  • Constructor Details

  • Method Details

    • beforeTaskStart

      public void beforeTaskStart(Object triggerData, IWorkflowEventData eventData, WorkflowTask task, WorkflowTrigger trigger)
      Invoked internally before a task is about to be executed.
      Parameters:
      triggerData - Data made available by the trigger.
      eventData - Event data that was triggered.
      task - Task about to be executed.
      trigger - Trigger that was triggered.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • createExecutionException

      public WorkflowTaskExecutionException createExecutionException(String message, com.google.common.collect.ImmutableList<Long> tasks, Exception cause, boolean handled)
      Should be called after the task was executed completely and threw an exception. Returns the exception that should be rethrown.
      Parameters:
      message - Message for the exception.
      tasks - List of tasks that were executed when the exception was obtained.
      cause - Exception that caused the task to fail.
      handled - Whether the error is or was handled in some way.
      Returns:
      The exception for the task's execution.
    • createExecutionSuccessResult

      public ITaskExecutionSuccessResult createExecutionSuccessResult(com.google.common.collect.ImmutableList<Long> tasks) throws WorkflowTaskExecutionException
      Should be called after the task was executed completely. Returns the result of the task's execution.
      Parameters:
      tasks - A list of tasks that were executed for this result.
      Returns:
      The result of the task's execution.
      Throws:
      WorkflowTaskExecutionException - When the result could not be created.
    • createFinalResult

      public ITaskExecutionResult createFinalResult(List<ITaskExecutionResult> individualResults)
      Internal method called after the list of tasks were executed. Creates the main result of the execution (i.e. combines all individual results).
      Parameters:
      individualResults - Individual results of each task.
      Returns:
      The main combined result for the task list execution.
    • env

      Specified by:
      env in interface IBaseWorkflowExecutionContext
      Specified by:
      env in interface IWorkflowExecutionContext
      Returns:
      Data from the current workflow execution, such as the form for which the workflow is executed, and the current client.
    • event

      public IWorkflowEventData event()
      Specified by:
      event in interface IWorkflowExecutionContext
      Returns:
      The data of the event that triggered the task being executed, i.e. the event to which the task's trigger reacted.
    • executor

      public IWorkflowExecutor executor()
      Description copied from interface: IWorkflowExecutionContext
      Grants access to the executor that can be used to execute children, or to trigger events.
      Specified by:
      executor in interface IWorkflowExecutionContext
      Returns:
      The executor handler associated with this execution context.
    • file

      public IWorkflowFileHandler file()
      Specified by:
      file in interface IWorkflowExecutionContext
      Returns:
      The file handler for interacting with files and the file system. Use this to create temporary files, to read files created by other workflow elements, or to attach files to the form record.
    • form

      public IWorkflowFormHandler form()
      Specified by:
      form in interface IWorkflowExecutionContext
      Returns:
      The file handler for interacting with the form and its data.
    • getDefaultSystemState

      public EWorkflowStateType getDefaultSystemState()
      Returns:
      The default system state to set, for internal use.
    • getEnvironmentData

      public de.xima.fc.workflow.processor.logic.execution.WorkflowExecutionEnvironmentData getEnvironmentData()
      Returns:
      The environment data implementation for internal use.
    • getFileHandler

      public de.xima.fc.workflow.processor.logic.execution.WorkflowFileHandler getFileHandler()
      Returns:
      The file handler implementation for internal use.
    • getFormHandler

      public de.xima.fc.workflow.processor.logic.execution.WorkflowFormHandler getFormHandler()
      Returns:
      The form handler implementation for internal use.
    • getHttpHandler

      public de.xima.fc.workflow.processor.logic.execution.WorkflowHttpHandler getHttpHandler()
      Returns:
      The HTTP handler implementation for internal use.
    • getLimitsHandler

      public de.xima.fc.workflow.processor.logic.execution.WorkflowLimitsHandler getLimitsHandler()
      Returns:
      The limits handler implementation for internal use.
    • getLoggingHandler

      public de.xima.fc.workflow.processor.logic.execution.WorkflowLoggingHandler getLoggingHandler()
      Returns:
      The logging handler implementation for internal use.
    • getNodeLocator

      public de.xima.fc.workflow.processor.logic.execution.WorkflowNodeLocator getNodeLocator()
      Returns:
      The node locator implementation for internal use.
    • getPlaceholderHandler

      public de.xima.fc.workflow.processor.logic.execution.WorkflowPlaceholderHandler getPlaceholderHandler()
      Returns:
      The placeholder handler implementation for internal use.
    • getPostProcessors

      public Iterable<IWorkflowExecutionPostProcessor> getPostProcessors()
      Returns:
      Internal, the post processors applied after the workflow finishes.
    • getTaskQueue

      public TaskQueue getTaskQueue()
      Returns:
      All tasks that are scheduled to be executed. The last task in this queue Deque.pollLast() is the task that should be run next.
    • getVariableHandler

      public de.xima.fc.workflow.processor.logic.execution.WorkflowVariableHandler getVariableHandler()
      Returns:
      The variable handler implementation for internal use.
    • http

      public IWorkflowHttpHandler http()
      Specified by:
      http in interface IWorkflowExecutionContext
      Returns:
      The handler for interacting with the current HTTP request. It can be used, for example, to initiate redirects or read/write session parameters. If no HTTP request is currently active, this returns a dummy instance that takes no action.
    • isWasFormRecordDeleted

      public boolean isWasFormRecordDeleted()
      Returns:
      Whether the form record was deleted or not
    • logging

      public IWorkflowLoggingHandler logging()
      Specified by:
      logging in interface IWorkflowExecutionContext
      Returns:
      The handler for interacting with the logging system. Lets you create and retrieve protocol entries.
    • markErrorEventTriggered

      public boolean markErrorEventTriggered()
      Sets the errorEventTriggered flag to true and returns the previous value of the flag.

      Internal method that keeps track of whether an error event was already triggered. When a task throws an unhandled exception, an error event is triggered that lets the user handle that exception globally by adding an error trigger to the workflow. When the task for that error trigger throws an unhandled exception, we end the workflow execution to prevent infinite loops.

      Returns:
      The previous value of the errorEventTriggered flag.
    • node

      public IWorkflowNodeLocator node()
      Specified by:
      node in interface IWorkflowExecutionContext
      Returns:
      A handler for locating nodes by their name, ID, or UUID. Also lets you access the node currently being executed.
    • placeholder

      public IWorkflowPlaceholderHandler placeholder()
      Specified by:
      placeholder in interface IBaseWorkflowExecutionContext
      Specified by:
      placeholder in interface IWorkflowExecutionContext
      Returns:
      A handler for replacing placeholders in strings, using the current workflow execution context. This is a shortcut for the methods provided by {code de.xima.fc.placeholder.PlaceholderReplacer} that supplies the required parameters automatically.
    • processId

      public long processId()
      Specified by:
      processId in interface IWorkflowExecutionContext
      Returns:
      ID of the WorkflowProcess of the task being executed.
    • setCurrentEvent

      public void setCurrentEvent(IWorkflowEventData eventData)
      Parameters:
      eventData - The event data of the task that is currently being executed. Internal-use only.
    • setCurrentTask

      public void setCurrentTask(WorkflowTask task)
      Parameters:
      task - The task that is currently being executed. Internal-use only.
    • task

      public WorkflowTask task()
      Specified by:
      task in interface IWorkflowExecutionContext
      Returns:
      The task that is being executed.
    • variable

      public IWorkflowVariableHandler variable()
      Specified by:
      variable in interface IWorkflowExecutionContext
      Returns:
      The handler for retrieving results of previous workflow actions, or adding new results.
    • doExecute

      protected IWorkflowNodeResult doExecute(WorkflowNode node) throws ExecutionAbortedException
      Throws:
      ExecutionAbortedException