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 ofIWorkflowExecutionContextthat is used by theWorkflowTaskRunner. Contains the state that needs to be kept during workflow execution.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description WorkflowExecutionContext(IWorkflowTaskRunnerParams params, IWorkflowRunTasksForEventParams runTasksParams)Creates a new execution context for executing the given task queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterTaskEnd(IWorkflowEventData eventData, WorkflowTask task, WorkflowTrigger trigger)Invoked internally before a task is about to be executed.voidbeforeTaskStart(Object triggerData, IWorkflowFileValue triggerFiles, IWorkflowEventData eventData, WorkflowTask task, WorkflowTrigger trigger)Invoked internally before a task is about to be executed.voidclose()WorkflowTaskExecutionExceptioncreateExecutionException(String message, com.google.common.collect.ImmutableList<Long> tasks, Throwable cause, boolean handled)Should be called after the task was executed completely and threw an exception.ITaskExecutionSuccessResultcreateExecutionSuccessResult(com.google.common.collect.ImmutableList<Long> tasks)Should be called after the task was executed completely.ITaskExecutionResultcreateFinalResult(List<ITaskExecutionResult> individualResults)Internal method called after the list of tasks were executed.IWorkflowExecutionEnvironmentDataenv()IWorkflowEventDataevent()IWorkflowExecutorexecutor()Grants access to the executor that can be used to execute children, or to trigger events.IWorkflowFileHandlerfile()IWorkflowFormHandlerform()EWorkflowStateTypegetDefaultSystemState()de.xima.fc.workflow.processor.logic.execution.WorkflowExecutionEnvironmentDatagetEnvironmentData()de.xima.fc.workflow.processor.logic.execution.WorkflowExecutorgetExecutor()de.xima.fc.workflow.processor.logic.execution.WorkflowFileHandlergetFileHandler()de.xima.fc.workflow.processor.logic.execution.WorkflowFormHandlergetFormHandler()de.xima.fc.workflow.processor.logic.execution.WorkflowHttpHandlergetHttpHandler()de.xima.fc.workflow.processor.logic.execution.WorkflowLimitsHandlergetLimitsHandler()de.xima.fc.workflow.processor.logic.execution.WorkflowLoggingHandlergetLoggingHandler()de.xima.fc.workflow.processor.logic.execution.WorkflowNodeLocatorgetNodeLocator()de.xima.fc.workflow.processor.logic.execution.WorkflowPlaceholderHandlergetPlaceholderHandler()Iterable<IWorkflowExecutionPostProcessor>getPostProcessors()TaskQueuegetTaskQueue()de.xima.fc.workflow.processor.logic.execution.WorkflowVariableHandlergetVariableHandler()IWorkflowHttpHandlerhttp()booleanisWasFormRecordDeleted()IWorkflowLoggingHandlerlogging()booleanmarkErrorEventTriggered()Sets theerrorEventTriggeredflag totrueand returns the previous value of the flag.IWorkflowNodeLocatornode()IWorkflowPlaceholderHandlerplaceholder()longprocessId()voidsetCurrentEvent(IWorkflowEventData eventData)voidsetCurrentTask(WorkflowTask task)WorkflowTasktask()IWorkflowTriggerLocatortrigger()IWorkflowVariableHandlervariable()-
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 Detail
-
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 Detail
-
afterTaskEnd
public void afterTaskEnd(IWorkflowEventData eventData, WorkflowTask task, WorkflowTrigger trigger)
Invoked internally before a task is about to be executed.- Parameters:
eventData- Event data that was triggered.task- Task about to be executed.trigger- Trigger that was triggered.
-
beforeTaskStart
public void beforeTaskStart(Object triggerData, IWorkflowFileValue triggerFiles, IWorkflowEventData eventData, WorkflowTask task, WorkflowTrigger trigger)
Invoked internally before a task is about to be executed.- Parameters:
triggerData- Data made available by the trigger.triggerFiles- Files 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
createExecutionException
public WorkflowTaskExecutionException createExecutionException(String message, com.google.common.collect.ImmutableList<Long> tasks, Throwable 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
public IWorkflowExecutionEnvironmentData env()
- Specified by:
envin interfaceIBaseWorkflowExecutionContext- Specified by:
envin interfaceIWorkflowExecutionContext- 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:
eventin 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
public IWorkflowExecutor executor()
Description copied from interface:IWorkflowExecutionContextGrants access to the executor that can be used to execute children, or to trigger events.- Specified by:
executorin interfaceIWorkflowExecutionContext- Returns:
- The executor handler associated with this execution context.
-
file
public IWorkflowFileHandler file()
- Specified by:
filein 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
public IWorkflowFormHandler form()
- Specified by:
formin interfaceIWorkflowExecutionContext- 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.
-
getExecutor
public de.xima.fc.workflow.processor.logic.execution.WorkflowExecutor getExecutor()
- Returns:
- The workflow executor 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:
- The internal queue with all tasks that still need to be executed.
-
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:
httpin 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
public IWorkflowLoggingHandler logging()
- Specified by:
loggingin interfaceIWorkflowExecutionContext- Returns:
- The handler for interacting with the logging system. Lets you create and retrieve protocol entries.
-
markErrorEventTriggered
public boolean markErrorEventTriggered()
Sets theerrorEventTriggeredflag totrueand 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
errorEventTriggeredflag.
-
node
public IWorkflowNodeLocator node()
- Specified by:
nodein interfaceIWorkflowExecutionContext- 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:
placeholderin interfaceIBaseWorkflowExecutionContext- Specified by:
placeholderin 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:
processIdin interfaceIWorkflowExecutionContext- Returns:
- ID of the
WorkflowProcessof 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:
taskin interfaceIWorkflowExecutionContext- Returns:
- The task that is being executed.
-
trigger
public IWorkflowTriggerLocator trigger()
- Specified by:
triggerin interfaceIWorkflowExecutionContext- Returns:
- A handler for locating triggers by their name, ID, or UUID. Also lets you access the trigger that fired the current task.
-
variable
public IWorkflowVariableHandler variable()
- Specified by:
variablein interfaceIWorkflowExecutionContext- Returns:
- The handler for retrieving results of previous workflow actions, or adding new results.
-
-