Class WorkflowExecutionContext
java.lang.Object
de.xima.fc.workflow.processor.logic.execution.WorkflowExecutionContext
- All Implemented Interfaces:
IBaseWorkflowExecutionContext
,IWorkflowExecutionContext
,Closeable
,AutoCloseable
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 Summary
ConstructorsConstructorDescriptionWorkflowExecutionContext
(IWorkflowTaskRunnerParams params, IWorkflowRunTasksForEventParams runTasksParams) Creates a new execution context for executing the given task queue. -
Method Summary
Modifier and TypeMethodDescriptionvoid
beforeTaskStart
(Object triggerData, IWorkflowEventData eventData, WorkflowTask task, WorkflowTrigger trigger) Invoked internally before a task is about to be executed.void
close()
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.createExecutionSuccessResult
(com.google.common.collect.ImmutableList<Long> tasks) Should be called after the task was executed completely.createFinalResult
(List<ITaskExecutionResult> individualResults) Internal method called after the list of tasks were executed.protected IWorkflowNodeResult
doExecute
(WorkflowNode node) env()
event()
executor()
Grants access to the executor that can be used to execute children, or to trigger events.file()
form()
de.xima.fc.workflow.processor.logic.execution.WorkflowExecutionEnvironmentData
de.xima.fc.workflow.processor.logic.execution.WorkflowFileHandler
de.xima.fc.workflow.processor.logic.execution.WorkflowFormHandler
de.xima.fc.workflow.processor.logic.execution.WorkflowHttpHandler
de.xima.fc.workflow.processor.logic.execution.WorkflowLimitsHandler
de.xima.fc.workflow.processor.logic.execution.WorkflowLoggingHandler
de.xima.fc.workflow.processor.logic.execution.WorkflowNodeLocator
de.xima.fc.workflow.processor.logic.execution.WorkflowPlaceholderHandler
de.xima.fc.workflow.processor.logic.execution.WorkflowVariableHandler
http()
boolean
logging()
boolean
Sets theerrorEventTriggered
flag totrue
and returns the previous value of the flag.node()
long
void
setCurrentEvent
(IWorkflowEventData eventData) void
setCurrentTask
(WorkflowTask task) task()
variable()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.xima.fc.interfaces.workflow.execution.IWorkflowExecutionContext
event
-
Constructor Details
-
WorkflowExecutionContext
public WorkflowExecutionContext(IWorkflowTaskRunnerParams params, IWorkflowRunTasksForEventParams runTasksParams) throws CouldNotLockFormRecordException Creates a new execution context for executing the given task queue.- Parameters:
params
- Parameters from the task runner.runTasksParams
- The tasks that are to be executed, and optionally an entity context to use.- Throws:
CouldNotLockFormRecordException
- When the form record could not be locked for execution.
-
-
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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
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
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 interfaceIBaseWorkflowExecutionContext
- Specified by:
env
in interfaceIWorkflowExecutionContext
- Returns:
- Data from the current workflow execution, such as the form for which the workflow is executed, and the current client.
-
event
- Specified by:
event
in interfaceIWorkflowExecutionContext
- Returns:
- The data of the event that triggered the task being executed, i.e. the event to which the task's trigger reacted.
-
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 interfaceIWorkflowExecutionContext
- Returns:
- The executor handler associated with this execution context.
-
file
- Specified by:
file
in interfaceIWorkflowExecutionContext
- 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
- Specified by:
form
in interfaceIWorkflowExecutionContext
- Returns:
- The file handler for interacting with the form and its data.
-
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
- Returns:
- Internal, the post processors applied after the workflow finishes.
-
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
- Specified by:
http
in interfaceIWorkflowExecutionContext
- 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
- Specified by:
logging
in interfaceIWorkflowExecutionContext
- Returns:
- The handler for interacting with the logging system. Lets you create and retrieve protocol entries.
-
markErrorEventTriggered
public boolean markErrorEventTriggered()Sets theerrorEventTriggered
flag totrue
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
- Specified by:
node
in interfaceIWorkflowExecutionContext
- Returns:
- A handler for locating nodes by their name, ID, or UUID. Also lets you access the node currently being executed.
-
placeholder
- Specified by:
placeholder
in interfaceIBaseWorkflowExecutionContext
- Specified by:
placeholder
in interfaceIWorkflowExecutionContext
- 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 interfaceIWorkflowExecutionContext
- Returns:
- ID of the
WorkflowProcess
of the task being executed.
-
setCurrentEvent
- Parameters:
eventData
- The event data of the task that is currently being executed. Internal-use only.
-
setCurrentTask
- Parameters:
task
- The task that is currently being executed. Internal-use only.
-
task
- Specified by:
task
in interfaceIWorkflowExecutionContext
- Returns:
- The task that is being executed.
-
variable
- Specified by:
variable
in interfaceIWorkflowExecutionContext
- Returns:
- The handler for retrieving results of previous workflow actions, or adding new results.
-
doExecute
- Throws:
ExecutionAbortedException
-