Class StateExecutionImpl
java.lang.Object
io.nflow.engine.model.ModelObject
io.nflow.engine.internal.workflow.StateExecutionImpl
- All Implemented Interfaces:
StateExecution
-
Constructor Summary
ConstructorsConstructorDescriptionStateExecutionImpl(WorkflowInstance instance, ObjectStringMapper objectMapper, WorkflowInstanceDao workflowDao, WorkflowInstancePreProcessor workflowInstancePreProcessor, WorkflowInstanceService workflowInstanceService) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChildWorkflows(WorkflowInstance... childWorkflows) Add new child workflows.voidaddWorkflows(WorkflowInstance... workflows) Add new workflows.booleanReturn all child workflows for current workflow.Return the business key associated to the workflow instance.org.joda.time.DateTimeReturn the parent workflow instance id if this is a child workflow, otherwise return empty.intReturn the number of retry attempts in the current state.Return the signal value from database if it has been set, otherwise return empty.getVariable(String name) Return a string value of the given variable.<T> TgetVariable(String name, Class<T> type) Return the value of the given variable.<T> TgetVariable(String name, Class<T> type, T defaultValue) Return the value of the given variable, or {code defaultValue} if the variable does not exist.getVariable(String name, String defaultValue) Return the string value of the given variable, or {code defaultValue} if the variable does not exist.Return the external id of the workflow instance.longReturn the id of the workflow instance.voidhandleFailure(WorkflowDefinition definition, String failureReason) voidhandleRetryAfter(org.joda.time.DateTime activation, WorkflowDefinition definition) booleanReturn true if this workflow instance has unfinished child workflow instances.booleanisFailed()booleanbooleanisRetry()booleanbooleanReturn child workflow instances for current workflow.voidsetBusinessKey(String businessKey) Set the business key associated to the workflow instance.voidsetCreateAction(boolean createAction) Control if action is created when workflow instance is updated to the database after state processing.voidvoidvoidsetHistoryCleaningForced(boolean historyCleaningForced) Set to true to force workflow instance history cleaning when workflow instance is updated to the database after state processing.voidsetNextActivation(org.joda.time.DateTime activation) voidsetNextState(WorkflowState state) voidsetNextStateReason(String reason) voidsetRetry(boolean isRetry) voidSet the signal value to the database.voidsetStateProcessInvoked(boolean isStateProcessInvoked) voidsetVariable(String name, Object value) Set the value for the given varible.voidsetVariable(String name, String value) Set the string value of the given variable.voidwakeUpParentWorkflow(String... expectedStates) Notify parent workflow that it may start processing again.Create a builder for creating child workflows.Methods inherited from class io.nflow.engine.model.ModelObject
equals, hashCode, toString
-
Constructor Details
-
StateExecutionImpl
public StateExecutionImpl(WorkflowInstance instance, ObjectStringMapper objectMapper, WorkflowInstanceDao workflowDao, WorkflowInstancePreProcessor workflowInstancePreProcessor, WorkflowInstanceService workflowInstanceService)
-
-
Method Details
-
getNextActivation
public org.joda.time.DateTime getNextActivation() -
getNextState
-
getNextStateReason
-
getCurrentStateName
-
getWorkflowInstanceId
public long getWorkflowInstanceId()Description copied from interface:StateExecutionReturn the id of the workflow instance.- Specified by:
getWorkflowInstanceIdin interfaceStateExecution- Returns:
- The workflow instance id.
-
getWorkflowInstanceExternalId
Description copied from interface:StateExecutionReturn the external id of the workflow instance.- Specified by:
getWorkflowInstanceExternalIdin interfaceStateExecution- Returns:
- The external id of the workflow instance.
-
getBusinessKey
Description copied from interface:StateExecutionReturn the business key associated to the workflow instance.- Specified by:
getBusinessKeyin interfaceStateExecution- Returns:
- The business key.
-
setBusinessKey
Description copied from interface:StateExecutionSet the business key associated to the workflow instance.- Specified by:
setBusinessKeyin interfaceStateExecution- Parameters:
businessKey- The business key.
-
getNewBusinessKey
-
getRetries
public int getRetries()Description copied from interface:StateExecutionReturn the number of retry attempts in the current state.- Specified by:
getRetriesin interfaceStateExecution- Returns:
- Number of retries. Zero when the state is executed for the first time. Increased by one every time the same state is executed again.
-
getVariable
Description copied from interface:StateExecutionReturn a string value of the given variable.- Specified by:
getVariablein interfaceStateExecution- Parameters:
name- The name of the variable.- Returns:
- The string value of the variable, or null if the variable does not exist.
-
getVariable
Description copied from interface:StateExecutionReturn the value of the given variable. The value is deserialized by the object mapper.- Specified by:
getVariablein interfaceStateExecution- Type Parameters:
T- The type of object to be deserialized.- Parameters:
name- The name of the variable.type- The class of the variable.- Returns:
- The deserialized value of class {code T}, or null if the variable does not exist.
-
getVariable
Description copied from interface:StateExecutionReturn the value of the given variable, or {code defaultValue} if the variable does not exist. The value is deserialized by the object mapper.- Specified by:
getVariablein interfaceStateExecution- Type Parameters:
T- The type of object to be deserialized.- Parameters:
name- The name of the variable.type- The class of the variable.defaultValue- The default value if the variable does not exist.- Returns:
- The deserialized value of class {code T}.
-
getVariable
Description copied from interface:StateExecutionReturn the string value of the given variable, or {code defaultValue} if the variable does not exist.- Specified by:
getVariablein interfaceStateExecution- Parameters:
name- The name of the variable.defaultValue- The default value if the variable does not exist.- Returns:
- The string value of the variable or the default value.
-
setVariable
Description copied from interface:StateExecutionSet the string value of the given variable.- Specified by:
setVariablein interfaceStateExecution- Parameters:
name- The name of the variable.value- The string value for the varible.
-
setVariable
Description copied from interface:StateExecutionSet the value for the given varible. The value must be serializable by the object mapper.- Specified by:
setVariablein interfaceStateExecution- Parameters:
name- The name of the variable.value- The value for the variable.
-
setNextActivation
public void setNextActivation(org.joda.time.DateTime activation) -
setNextState
-
setNextStateReason
-
isRetry
public boolean isRetry() -
setRetry
public void setRetry(boolean isRetry) -
isFailed
public boolean isFailed() -
getThrown
-
setFailed
public void setFailed() -
setFailed
-
isRetryCountExceeded
public boolean isRetryCountExceeded() -
addChildWorkflows
Description copied from interface:StateExecutionAdd new child workflows. Child workflows are stored to database after current state method processing completes successfully. Note that child workflows are not visible to queryChildWorkflows() method before they are stored to database.- Specified by:
addChildWorkflowsin interfaceStateExecution- Parameters:
childWorkflows- Child workflows to create.
-
addWorkflows
Description copied from interface:StateExecutionAdd new workflows. Workflows are stored to database after current state method processing completes successfully.- Specified by:
addWorkflowsin interfaceStateExecution- Parameters:
workflows- Workflows to create.
-
getNewChildWorkflows
-
getNewWorkflows
-
queryChildWorkflows
Description copied from interface:StateExecutionReturn child workflow instances for current workflow. Query is restricted to childs of current workflow.- Specified by:
queryChildWorkflowsin interfaceStateExecution- Parameters:
query- The query criterias.- Returns:
- List of child workflows that match the query.
-
getAllChildWorkflows
Description copied from interface:StateExecutionReturn all child workflows for current workflow.- Specified by:
getAllChildWorkflowsin interfaceStateExecution- Returns:
- List of all child workflows.
-
wakeUpParentWorkflow
Description copied from interface:StateExecutionNotify parent workflow that it may start processing again. Calling this schedules parent workflow for immediate execution. Scheduling is performed when current state method processing completes successfully.- Specified by:
wakeUpParentWorkflowin interfaceStateExecution- Parameters:
expectedStates- If parent state is not one of the expected states, it is not woken up. If no expected states are given, parent workflow is woken up regardless of the state.
-
getWakeUpParentWorkflowStates
-
workflowInstanceBuilder
Description copied from interface:StateExecutionCreate a builder for creating child workflows. Created builder has nextActivation set to current time.- Specified by:
workflowInstanceBuilderin interfaceStateExecution- Returns:
- Builder for creating child workflows.
-
setStateProcessInvoked
public void setStateProcessInvoked(boolean isStateProcessInvoked) -
isStateProcessInvoked
public boolean isStateProcessInvoked() -
setCreateAction
public void setCreateAction(boolean createAction) Description copied from interface:StateExecutionControl if action is created when workflow instance is updated to the database after state processing. By default the action is created. Additionally, the action is always created when new workflows or child workflows are created or when the state variables are updated, regardless of this setting.- Specified by:
setCreateActionin interfaceStateExecution- Parameters:
createAction- Whether action should be created or not.
-
createAction
public boolean createAction() -
getSignal
Description copied from interface:StateExecutionReturn the signal value from database if it has been set, otherwise return empty.- Specified by:
getSignalin interfaceStateExecution- Returns:
- The signal value.
-
setSignal
Description copied from interface:StateExecutionSet the signal value to the database. Use Optional.empty() to clear the signal value.- Specified by:
setSignalin interfaceStateExecution- Parameters:
signal- Signal value to be set.reason- The reason for setting the signal.
-
getParentId
Description copied from interface:StateExecutionReturn the parent workflow instance id if this is a child workflow, otherwise return empty.- Specified by:
getParentIdin interfaceStateExecution- Returns:
- The parent workflow instance id or empty.
-
setHistoryCleaningForced
public void setHistoryCleaningForced(boolean historyCleaningForced) Description copied from interface:StateExecutionSet to true to force workflow instance history cleaning when workflow instance is updated to the database after state processing. By default (or if set to false) the cleaning is done according to workflow definition settings. Cleaning also requires WorkflowSettings.setHistoryDeletableAfterHours to be set.- Specified by:
setHistoryCleaningForcedin interfaceStateExecution- Parameters:
historyCleaningForced- Whether history cleaning should be forced or not.
-
isHistoryCleaningForced
public boolean isHistoryCleaningForced() -
handleRetryAfter
-
handleFailure
-
hasUnfinishedChildWorkflows
public boolean hasUnfinishedChildWorkflows()Description copied from interface:StateExecutionReturn true if this workflow instance has unfinished child workflow instances.- Specified by:
hasUnfinishedChildWorkflowsin interfaceStateExecution- Returns:
- True if unfinished child workflow instances are found, false otherwise.
-