Class WorkflowInstance.Builder
- java.lang.Object
-
- io.nflow.engine.workflow.instance.WorkflowInstance.Builder
-
- Enclosing class:
- WorkflowInstance
public static class WorkflowInstance.Builder extends Object
Builder for workflow instance.
-
-
Constructor Summary
Constructors Constructor Description Builder()Create a workflow instance builder.Builder(ObjectStringMapper objectMapper)Create a workflow instance builder with an object mapper.Builder(WorkflowInstance copy)Create a workflow instance builder based on an existing workflow instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WorkflowInstancebuild()Create the workflow instance object.WorkflowInstance.BuilderputStateVariable(String key, Object value)Put a state variable to the state variables map.WorkflowInstance.BuilderputStateVariable(String key, String value)Put a state variable to the state variables map.WorkflowInstance.BuilderputStateVariable(String key, Optional<?> optionalValue)Put a state variable to the state variables map if the optional value is present.WorkflowInstance.BuildersetActions(List<WorkflowInstanceAction> actions)Set the workflow instance actions.WorkflowInstance.BuildersetArchived(boolean isArchived)Set whether the workflow instance is stored in archive or main tables.WorkflowInstance.BuildersetBusinessKey(String businessKey)Set the business key.WorkflowInstance.BuildersetCreated(org.joda.time.DateTime created)Set the creation timestamp.WorkflowInstance.BuildersetExecutorGroup(String executorGroup)Set the executor group name.WorkflowInstance.BuildersetExecutorId(Integer executorId)Set the executor instance identifier.WorkflowInstance.BuildersetExternalId(String externalId)Set the external identifier.WorkflowInstance.BuildersetId(long id)Set the workflow instance identifier.WorkflowInstance.BuildersetModified(org.joda.time.DateTime modified)Set the modification timestamp.WorkflowInstance.BuildersetNextActivation(org.joda.time.DateTime nextActivation)Set the next activation time.WorkflowInstance.BuildersetOriginalStateVariables(Map<String,String> originalStateVariables)Set the original state variables.WorkflowInstance.BuildersetParentActionId(Long parentActionId)Set the parent workflow identifier.WorkflowInstance.BuildersetParentWorkflowId(Long parentWorkflowId)Set the parent workflow identifier.WorkflowInstance.BuildersetPriority(Short priority)Set the priority of the workflow instance.WorkflowInstance.BuildersetRetries(int retries)Set the number of retries.WorkflowInstance.BuildersetSignal(Optional<Integer> signal)Set the signal value.WorkflowInstance.BuildersetStartedIfNotSet(org.joda.time.DateTime started)Set the started timestamp if it has not already been set.WorkflowInstance.BuildersetState(WorkflowState state)Set the state.WorkflowInstance.BuildersetState(String state)Set the state.WorkflowInstance.BuildersetStateText(String stateText)Set the state text.WorkflowInstance.BuildersetStateVariables(Map<String,String> stateVariables)Set the state variables.WorkflowInstance.BuildersetStatus(WorkflowInstance.WorkflowInstanceStatus status)Set the status.WorkflowInstance.BuildersetType(String type)Set the type of the workflow definition.
-
-
-
Constructor Detail
-
Builder
public Builder()
Create a workflow instance builder.
-
Builder
public Builder(ObjectStringMapper objectMapper)
Create a workflow instance builder with an object mapper.- Parameters:
objectMapper- The object mapper.
-
Builder
public Builder(WorkflowInstance copy)
Create a workflow instance builder based on an existing workflow instance.- Parameters:
copy- The instance to be used as a basis for the new instance.
-
-
Method Detail
-
setId
public WorkflowInstance.Builder setId(long id)
Set the workflow instance identifier.- Parameters:
id- The identifier.- Returns:
- this.
-
setExecutorId
public WorkflowInstance.Builder setExecutorId(Integer executorId)
Set the executor instance identifier.- Parameters:
executorId- The identifier.- Returns:
- this.
-
setParentWorkflowId
public WorkflowInstance.Builder setParentWorkflowId(Long parentWorkflowId)
Set the parent workflow identifier.- Parameters:
parentWorkflowId- The identifier.- Returns:
- this.
-
setParentActionId
public WorkflowInstance.Builder setParentActionId(Long parentActionId)
Set the parent workflow identifier.- Parameters:
parentActionId- The identifier.- Returns:
- this.
-
setStatus
public WorkflowInstance.Builder setStatus(WorkflowInstance.WorkflowInstanceStatus status)
Set the status.- Parameters:
status- The status.- Returns:
- this.
-
setType
public WorkflowInstance.Builder setType(String type)
Set the type of the workflow definition.- Parameters:
type- The type.- Returns:
- this.
-
setPriority
public WorkflowInstance.Builder setPriority(Short priority)
Set the priority of the workflow instance. When an executor chooses from many available scheduled workflow instances it primarily (unfairly) schedules the workflow instance with the larger priority value, and for workflows with the same priority, the one scheduled first. Priority defaults to 0 and can also be negative.- Parameters:
priority- The priority.- Returns:
- this.
-
setBusinessKey
public WorkflowInstance.Builder setBusinessKey(String businessKey)
Set the business key.- Parameters:
businessKey- The business key.- Returns:
- this.
-
setExternalId
public WorkflowInstance.Builder setExternalId(String externalId)
Set the external identifier.- Parameters:
externalId- The external identifier.- Returns:
- this.
-
setState
public WorkflowInstance.Builder setState(String state)
Set the state.- Parameters:
state- The name of the state.- Returns:
- this.
-
setState
public WorkflowInstance.Builder setState(WorkflowState state)
Set the state.- Parameters:
state- The state.- Returns:
- this.
-
setStateText
public WorkflowInstance.Builder setStateText(String stateText)
Set the state text.- Parameters:
stateText- The state text.- Returns:
- this.
-
setNextActivation
public WorkflowInstance.Builder setNextActivation(org.joda.time.DateTime nextActivation)
Set the next activation time.- Parameters:
nextActivation- The next activation time.- Returns:
- this.
-
setOriginalStateVariables
public WorkflowInstance.Builder setOriginalStateVariables(Map<String,String> originalStateVariables)
Set the original state variables.- Parameters:
originalStateVariables- The original state variables.- Returns:
- this.
-
setStateVariables
public WorkflowInstance.Builder setStateVariables(Map<String,String> stateVariables)
Set the state variables.- Parameters:
stateVariables- The state variables.- Returns:
- this.
-
putStateVariable
public WorkflowInstance.Builder putStateVariable(String key, String value)
Put a state variable to the state variables map.- Parameters:
key- The name of the variable.value- The string value of the variable.- Returns:
- this.
-
putStateVariable
public WorkflowInstance.Builder putStateVariable(String key, Object value)
Put a state variable to the state variables map.- Parameters:
key- The name of the variable.value- The value of the variable, serialized by object mapper.- Returns:
- this.
-
putStateVariable
public WorkflowInstance.Builder putStateVariable(String key, Optional<?> optionalValue)
Put a state variable to the state variables map if the optional value is present. If the optionalValue is empty, existing state variable value is not changed.- Parameters:
key- The name of the variable.optionalValue- The optional value of the variable, serialized by object mapper.- Returns:
- this.
-
setActions
public WorkflowInstance.Builder setActions(List<WorkflowInstanceAction> actions)
Set the workflow instance actions.- Parameters:
actions- List of actions.- Returns:
- this.
-
setRetries
public WorkflowInstance.Builder setRetries(int retries)
Set the number of retries.- Parameters:
retries- The number of retries.- Returns:
- this.
-
setCreated
public WorkflowInstance.Builder setCreated(org.joda.time.DateTime created)
Set the creation timestamp.- Parameters:
created- Creation time.- Returns:
- this.
-
setModified
public WorkflowInstance.Builder setModified(org.joda.time.DateTime modified)
Set the modification timestamp.- Parameters:
modified- Modification time.- Returns:
- this.
-
setStartedIfNotSet
public WorkflowInstance.Builder setStartedIfNotSet(org.joda.time.DateTime started)
Set the started timestamp if it has not already been set.- Parameters:
started- Start time.- Returns:
- this.
-
setExecutorGroup
public WorkflowInstance.Builder setExecutorGroup(String executorGroup)
Set the executor group name.- Parameters:
executorGroup- The executor group name.- Returns:
- this.
-
setSignal
public WorkflowInstance.Builder setSignal(Optional<Integer> signal)
Set the signal value.- Parameters:
signal- The signal value.- Returns:
- this.
-
setArchived
public WorkflowInstance.Builder setArchived(boolean isArchived)
Set whether the workflow instance is stored in archive or main tables.- Parameters:
isArchived- True if this workflow is stored in archive tables.- Returns:
- this.
-
build
public WorkflowInstance build()
Create the workflow instance object.- Returns:
- The workflow instance.
-
-