Interface CaseExecutionCommandBuilder
-
- All Known Implementing Classes:
CaseExecutionCommandBuilderImpl
public interface CaseExecutionCommandBuilder
A fluent builder for defining a command to execute for a case execution.
This fluent builder offers different points to execute a defined command:
The entry point to use this fluent builder is
CaseService.withCaseExecution(String)
. It expects an id of a case execution as parameter.This fluent builder can be used as follows:
(1) Set and remove case execution variables:
caseService
.withCaseExecution("aCaseDefinitionId")
.setVariable("aVariableName", "aVariableValue")
.setVariable("anotherVariableName", 999)
.removeVariable("aVariableNameToRemove")
.execute();(2) Set case execution variable and start the case execution manually:
caseService
.withCaseExecution("aCaseDefinitionId")
.setVariable("aVariableName", "aVariableValue")
.manualStart();etc.
Note: All defined changes for a case execution within this fluent builder will be performed in one command. So for example: if you set and remove variables of a case execution this happens in a single command. This has the effect that if anything went wrong the whole command will be rolled back.
- Author:
- Roman Smirnov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Additionally toexecute()
the associated case instance will be closed, so that no further work or modifications is allowed for the associated case instance.void
complete()
Additionally toexecute()
the associated case execution will be completed.void
disable()
Additionally toexecute()
the associated case execution will be disabled.void
execute()
Invoking this method will remove and/or set the passed variables.void
manualStart()
Additionally toexecute()
the associated case execution will be started manually.void
reenable()
Additionally toexecute()
the associated case execution will be re-enabled.CaseExecutionCommandBuilder
removeVariable(String variableName)
Pass a variable name of a variable to be removed for a case execution.CaseExecutionCommandBuilder
removeVariableLocal(String variableName)
Pass a variable name of a local variable to be removed for a case execution (not considering parent scopes).CaseExecutionCommandBuilder
removeVariables(Collection<String> variableNames)
Pass a collection of variable names of variables to be removed for a case execution.CaseExecutionCommandBuilder
removeVariablesLocal(Collection<String> variableNames)
Pass a collection of variable names of local variables to be removed for a case execution (not considering parent scopes).CaseExecutionCommandBuilder
setVariable(String variableName, Object variableValue)
Pass a variable to the case execution.CaseExecutionCommandBuilder
setVariableLocal(String variableName, Object variableValue)
Pass a local variable to the case execution (not considering parent scopes).CaseExecutionCommandBuilder
setVariables(Map<String,Object> variables)
Pass a map of variables to the case execution.CaseExecutionCommandBuilder
setVariablesLocal(Map<String,Object> variables)
Pass a map of variables to the case execution (not considering parent scopes).void
terminate()
Additionally toexecute()
the associated case execution will be terminated.
-
-
-
Method Detail
-
setVariable
CaseExecutionCommandBuilder setVariable(String variableName, Object variableValue)
Pass a variable to the case execution. If the variable is not already existing, they will be created in the case instance (which is the root execution) otherwise the existing variable will be updated.
Invoking this method multiple times allows passing multiple variables.
- Parameters:
variableName
- the name of the variable to setvariableValue
- the value of the variable to set- Returns:
- the builder
- Throws:
NotValidException
- when the given variable name is null or the same variable should be removed in the same command
-
setVariables
CaseExecutionCommandBuilder setVariables(Map<String,Object> variables)
Pass a map of variables to the case execution. If the variables are not already existing, they will be created in the case instance (which is the root execution) otherwise the existing variable will be updated.
Invoking this method multiple times allows passing multiple variables.
- Parameters:
variables
- the map of variables- Returns:
- the builder
- Throws:
NotValidException
- when one of the passed variables should be removed in the same command
-
setVariableLocal
CaseExecutionCommandBuilder setVariableLocal(String variableName, Object variableValue)
Pass a local variable to the case execution (not considering parent scopes).
Invoking this method multiple times allows passing multiple variables.
- Parameters:
variableName
- the name of the variable to setvariableValue
- the value of the variable to set- Returns:
- the builder
- Throws:
NotValidException
- when the given variable name is null or the same variable should be removed in the same command
-
setVariablesLocal
CaseExecutionCommandBuilder setVariablesLocal(Map<String,Object> variables)
Pass a map of variables to the case execution (not considering parent scopes).
Invoking this method multiple times allows passing multiple variables.
- Parameters:
variables
- the map of variables- Returns:
- the builder
- Throws:
NotValidException
- when one of the passed variables should be removed in the same command
-
removeVariable
CaseExecutionCommandBuilder removeVariable(String variableName)
Pass a variable name of a variable to be removed for a case execution.
Invoking this method multiple times allows passing multiple variable names.
- Parameters:
variableName
- the name of a variable to remove- Returns:
- the builder
- Throws:
NotValidException
- when the given variable name is null or the same variable should be set in the same command
-
removeVariables
CaseExecutionCommandBuilder removeVariables(Collection<String> variableNames)
Pass a collection of variable names of variables to be removed for a case execution.
Invoking this method multiple times allows passing multiple variable names.
- Parameters:
variableNames
- a collection of names of variables to remove- Returns:
- the builder
- Throws:
NotValidException
- when one of the passed variables should be set in the same command
-
removeVariableLocal
CaseExecutionCommandBuilder removeVariableLocal(String variableName)
Pass a variable name of a local variable to be removed for a case execution (not considering parent scopes).
Invoking this method multiple times allows passing multiple variable names.
- Parameters:
variableName
- the name of a variable to remove- Returns:
- the builder
- Throws:
NotValidException
- when the given variable name is null or the same variable should be set in same command
-
removeVariablesLocal
CaseExecutionCommandBuilder removeVariablesLocal(Collection<String> variableNames)
Pass a collection of variable names of local variables to be removed for a case execution (not considering parent scopes).
Invoking this method multiple times allows passing multiple variable names.
- Parameters:
variableNames
- a collection of names of variables to remove- Returns:
- the builder
- Throws:
NotValidException
- when one of the passed variables should be set in the same command
-
execute
void execute()
Invoking this method will remove and/or set the passed variables.
This behaves as follows:
- if at least one variable name of a variable to remove is passed, those variables will be removed.
- if at least one local variable name of a local variable to remove is passed, those local variables will be removed.
- if at least one variable to add or update is passed, those variables will be set for a case execution.
- if at least one local variable to add or update is passed, those variables will be set for a case execution.
- Throws:
NotValidException
- when the given case execution id is nullNotFoundException
- when no case execution is found for the given case execution idProcessEngineException
- when an internal exception happens during the execution of the command.
-
manualStart
void manualStart()
Additionally to
execute()
the associated case execution will be started manually. Therefore there happens a transition from the stateENABLED
to stateACTIVE
.According to CMMN 1.0 specification the state
ACTIVE
means, that the with the case execution relatedStage
orTask
is executing in this state:Task
: thetask
will be completed immediatelyHumanTask
: a newuser task
will be instantiatedProcessTask
: a newprocess instance
will be instantiatedCaseTask
: a newcase instance
will be instantiated
- Throws:
NotValidException
- when the given case execution id is nullNotFoundException
- when no case execution is found for the given case execution idNotAllowedException
- when the transition is not allowed to be done or when the case execution is a case instanceProcessEngineException
- when an internal exception happens during the execution of the command.
-
disable
void disable()
Additionally to
execute()
the associated case execution will be disabled. Therefore there happens a transition from the stateENABLED
to stateDISABLED
.According to CMMN 1.0 specification the state
DISABLED
means, that the with the case execution relatedStage
orTask
should not be executed in the case instance.If the given case execution has a parent case execution, that parent case execution will be notified that the given case execution has been disabled. This can lead to a completion of the parent case execution if the completion criteria are fulfilled.
- Throws:
NotValidException
- when the given case execution id is nullNotFoundException
- when no case execution is found for the given case execution idNotAllowedException
- when the transition is not allowed to be done or when the case execution is a case instanceProcessEngineException
- when an internal exception happens during the execution of the command.
-
reenable
void reenable()
Additionally to
execute()
the associated case execution will be re-enabled. Therefore there happens a transition from the stateDISABLED
to stateENABLED
.According to CMMN 1.0 specification the state
DISABLED
means, that the with the case execution relatedStage
orTask
is waiting for a decision to becomeACTIVE
orDISABLED
once again.- Throws:
NotValidException
- when the given case execution id is nullNotFoundException
- when no case execution is found for the given case execution idNotAllowedException
- when the transition is not allowed to be done or when the case execution is a case instanceProcessEngineException
- when an internal exception happens during the execution of the command.
-
complete
void complete()
Additionally to
execute()
the associated case execution will be completed. Therefore there happens a transition from the stateACTIVE
to stateCOMPLETED
.It is only possible to complete a case execution which is associated with a
Stage
orTask
.In case of a
Stage
the completion can only be performed when the following criteria are fulfilled:
- there are no children in the state
ACTIVE
For a
Task
instance, this means its purpose has been accomplished:
HumanTask
has been completed by human.
If the given case execution has a parent case execution, that parent case execution will be notified that the given case execution has been completed. This can lead to a completion of the parent case execution if the completion criteria are fulfilled.
- Throws:
NotValidException
- when the given case execution id is nullNotFoundException
- when no case execution is found for the given case execution idNotAllowedException
- when the transition is not allowed to be doneProcessEngineException
- when an internal exception happens during the execution of the command.
- there are no children in the state
-
terminate
void terminate()
Additionally to
execute()
the associated case execution will be terminated. Therefore there happens a transition to stateTERMINATED
.- Throws:
NotValidException
- when the given case execution id is nullNotFoundException
- when no case execution is found for the given case execution idNotAllowedException
- when the transition is not allowed to be done or when the case execution is a case instanceProcessEngineException
- when an internal exception happens during the execution of the command.
-
close
void close()
Additionally to
execute()
the associated case instance will be closed, so that no further work or modifications is allowed for the associated case instance. Therefore there happens a transition from the stateCOMPLETED
to stateCLOSED
.- Throws:
NotValidException
- when the given case execution id is nullNotFoundException
- when no case execution is found for the given case execution idNotAllowedException
- when the transition is not allowed to be doneProcessEngineException
- when an internal exception happens during the execution of the command.
-
-