Interface ProcessInstanceModificationBuilder
- All Superinterfaces:
InstantiationBuilder<ProcessInstanceModificationInstantiationBuilder>
- All Known Subinterfaces:
ProcessInstanceModificationInstantiationBuilder
- All Known Implementing Classes:
ProcessInstanceModificationBuilderImpl
A fluent builder to specify a modification of process instance state in terms of cancellation of activity instances and instantiations of activities and sequence flows. Allows to specify an ordered set of instructions that are all executed within one transaction. Individual instructions are executed in the order of their specification.
- Author:
- Thorben Lindhauer
-
Method Summary
Modifier and TypeMethodDescriptioncancelActivityInstance
(String activityInstanceId) Submits the instruction:cancelAllForActivity
(String activityId) Submits the instruction:cancellationSourceExternal
(boolean external) A canceled process instance receives a termination state to indicate the source of the cancellation call.cancelTransitionInstance
(String transitionInstanceId) Submits the instruction:void
execute()
Execute all instructions.void
execute
(boolean skipCustomListeners, boolean skipIoMappings) Execute all instructions asynchronously.executeAsync
(boolean skipCustomListeners, boolean skipIoMappings) setAnnotation
(String annotation) Provides annotation for the current modification.startAfterActivity
(String activityId, String ancestorActivityInstanceId) Submits an instruction that behaves likestartTransition(String,String)
and always instantiates the single outgoing sequence flow of the given activity.startBeforeActivity
(String activityId, String ancestorActivityInstanceId) Submits the instruction:startTransition
(String transitionId, String ancestorActivityInstanceId) Submits the instruction:Methods inherited from interface org.camunda.bpm.engine.runtime.InstantiationBuilder
startAfterActivity, startBeforeActivity, startTransition
-
Method Details
-
startBeforeActivity
ProcessInstanceModificationInstantiationBuilder startBeforeActivity(String activityId, String ancestorActivityInstanceId) Submits the instruction:
Start before the specified activity. Instantiate the given activity as a descendant of the given ancestor activity instance.
In particular:
- Instantiate all activities between the ancestor activity and the activity to execute
- Instantiate and execute the given activity (respects the asyncBefore attribute of the activity)
- Parameters:
activityId
- the activity to instantiateancestorActivityInstanceId
- the ID of an existing activity instance under which the new activity instance should be created
-
startAfterActivity
ProcessInstanceModificationInstantiationBuilder startAfterActivity(String activityId, String ancestorActivityInstanceId) Submits an instruction that behaves likestartTransition(String,String)
and always instantiates the single outgoing sequence flow of the given activity. Does not consider asyncAfter.- Parameters:
activityId
- the activity for which the outgoing flow should be executed- Throws:
ProcessEngineException
- if the activity has 0 or more than 1 outgoing sequence flows
-
startTransition
ProcessInstanceModificationInstantiationBuilder startTransition(String transitionId, String ancestorActivityInstanceId) Submits the instruction:
Start the specified sequence flow. Instantiate the given sequence flow as a descendant of the given ancestor activity instance.
In particular:
- Instantiate all activities between the ancestor activity and the activity to execute
- Execute the given transition (does not consider sequence flow conditions)
- Parameters:
transitionId
- the sequence flow to executeancestorActivityInstanceId
- the ID of an existing activity instance under which the new transition should be executed
-
cancelActivityInstance
Submits the instruction:
Cancel an activity instance in a process. If this instance has child activity instances (e.g. in a subprocess instance), these children, their grandchildren, etc. are cancelled as well.
Process instance cancellation will propagate upward, removing any parent process instances that are only waiting on the cancelled process to complete.
- Parameters:
activityInstanceId
- the id of the activity instance to cancel
-
cancelTransitionInstance
Submits the instruction:
Cancel a transition instance (i.e. an async continuation) in a process.
- Parameters:
transitionInstanceId
- the id of the transition instance to cancel
-
cancelAllForActivity
Submits the instruction:
Cancel all instances of the given activity in an arbitrary order, which are:
- activity instances of that activity
- transition instances entering or leaving that activity
Therefore behaves like
cancelActivityInstance(String)
for each individual activity instance and likecancelTransitionInstance(String)
for each individual transition instance.The cancellation order of the instances is arbitrary
- Parameters:
activityId
- the activity for which all instances should be cancelled
-
cancellationSourceExternal
A canceled process instance receives a termination state to indicate the source of the cancellation call. The state can have the following values:
EXTERNALLY_TERMINATED
: the cancellation was triggered by an external source. (e.g. REST call, external application)INTERNALLY_TERMINATED
: the cancellation was triggered internally. (e.g. by the engine)
- Parameters:
external
- was the cancellation triggered by an external source?true
forEXTERNALLY_TERMINATED
,false
forINTERNALLY_TERMINATED
.
-
setAnnotation
Provides annotation for the current modification. -
execute
void execute()Execute all instructions. Custom execution and task listeners, as well as task input output mappings are executed.- Throws:
AuthorizationException
- if the user has noPermissions.UPDATE
permission onResources.PROCESS_INSTANCE
or noPermissions.UPDATE_INSTANCE
permission onResources.PROCESS_DEFINITION
. if the process instance will be delete and the user has noPermissions.DELETE
permission onResources.PROCESS_INSTANCE
or noPermissions.DELETE_INSTANCE
permission onResources.PROCESS_DEFINITION
.
-
execute
void execute(boolean skipCustomListeners, boolean skipIoMappings) - Parameters:
skipCustomListeners
- specifies whether custom listeners (task and execution) should be invoked when executing the instructionsskipIoMappings
- specifies whether input/output mappings for tasks should be invoked throughout the transaction when executing the instructions- Throws:
AuthorizationException
- if the user has noPermissions.UPDATE
permission onResources.PROCESS_INSTANCE
or noPermissions.UPDATE_INSTANCE
permission onResources.PROCESS_DEFINITION
. if the process instance will be delete and the user has noPermissions.DELETE
permission onResources.PROCESS_INSTANCE
or noPermissions.DELETE_INSTANCE
permission onResources.PROCESS_DEFINITION
.
-
executeAsync
Batch executeAsync()Execute all instructions asynchronously. Custom execution and task listeners, as well as task input output mappings are executed.- Returns:
- a batch job to be executed by the executor
- Throws:
AuthorizationException
- if the user has noPermissions.CREATE
orBatchPermissions.CREATE_BATCH_MODIFY_PROCESS_INSTANCES
permission onResources.BATCH
.
-
executeAsync
- Parameters:
skipCustomListeners
- specifies whether custom listeners (task and execution) should be invoked when executing the instructionsskipIoMappings
- specifies whether input/output mappings for tasks should be invoked throughout the transaction when executing the instructions- Returns:
- a batch job to be executed by the executor
- Throws:
AuthorizationException
- if the user has noPermissions.CREATE
orBatchPermissions.CREATE_BATCH_MODIFY_PROCESS_INSTANCES
permission onResources.BATCH
.
-