Package com.onenetwork.platform.workflow
Interface WorkflowService
- All Superinterfaces:
Service
public interface WorkflowService extends Service
Service which facilitates the implementation of action-based and time-based workflow activities.
This service should only be used within the context of an action-based or time-based workflow.
-
Method Summary
Modifier and Type Method Description <M extends Model>
voidexecuteIssueComps(ActionBasedWorkflowContext<M> workflowCtx, java.util.List<M> modelsToInclude, java.lang.String... issueCompNames)
Given a list of Models from your workflow, executes the given issue computations on those models.<M extends Model>
voidmergeInputToCurrent(ActionBasedWorkflowContext<M> workflowCtx)
Copies values from the "input" down onto the "current".<M extends Model>
voidpopulateCurrentFromDatabase(ActionBasedWorkflowContext<M> workflowCtx, FetchParam... fetchParams)
Based on the records provided by the user in the input of theActionBasedWorkflowContext
, fetches the current state of those records from the DB into the "current" collection of the context.<M extends Model>
voidwrite(java.util.List<M> models, ActionBasedWorkflowContext<M> workflowCtx)
Writes the given Models to the database in the context of an Action-Based workflow.<M extends Model>
voidwrite(java.util.List<M> models, ActionBasedWorkflowContext<M> workflowCtx, boolean writeWithNKChange)
Writes the given Models to the database in the context of an Action-Based workflow.
-
Method Details
-
populateCurrentFromDatabase
<M extends Model> void populateCurrentFromDatabase(ActionBasedWorkflowContext<M> workflowCtx, FetchParam... fetchParams)Based on the records provided by the user in the input of theActionBasedWorkflowContext
, fetches the current state of those records from the DB into the "current" collection of the context. To select precisely which database records to fetch you should provideFetchParam
values. They are validated according to these rules:- The topmost level of the model should not be specified (it is always implicitly fetched as INPUT_ONLY)
- No level may be specified twice
- No level may be specified unless all its parent levels are specified (except that, as previously mentioned, the topmost level should not be specified)
- All levels must belong to the same model
// valid examples ... populateCurrentFromDatabase(ctx); // fetches header only populateCurrentFromDatabase(ctx, FetchParam.inputOnly(OrderLineItem.class), FetchParam.inputOnly(OrderHeader.class)); populateCurrentFromDatabase(ctx, FetchParam.all(OrderLineItem.class)); populateCurrentFromDatabase(ctx, FetchParam.all(OrderLineItem.class), FetchParam.inputOnly(OrderSchedule.class)); // invalid examples (throws IllegalArgumentException) populateCurrentFromDatabase(ctx, FetchParam.all(OrderSchedule.class)); // can't populate child without including parent
Please note that this API does not fetch ATTACHMENT fields.- Parameters:
workflowCtx
- execution contextfetchParams
- params to indicate what data precisely should be fetched
-
mergeInputToCurrent
Copies values from the "input" down onto the "current". If there is no "current", then this is a direct replace. If there is a "current", then values which are set on the input will overwrite similar values on current. Values which were not specified in "input" (left unset) will remain undisturbed on current, and will not be nullified- Parameters:
workflowCtx
- context of the surrounding action-based workflow
-
write
Writes the given Models to the database in the context of an Action-Based workflow. This will not change the natural keys of the models in the database even if you have modified them in your workflow ... please usewrite(List, ActionBasedWorkflowContext, boolean)
if you need the natural keys have been modified by your workflow.- Type Parameters:
M
- model type- Parameters:
models
- models to be written - frequent usage is workflowCtx.getCurrent().getModels()workflowCtx
- context of the surrounding action-based workflow
-
write
<M extends Model> void write(java.util.List<M> models, ActionBasedWorkflowContext<M> workflowCtx, boolean writeWithNKChange)Writes the given Models to the database in the context of an Action-Based workflow.- Type Parameters:
M
- model type- Parameters:
models
- models to be written - frequent usage is workflowCtx.getCurrent().getModels()workflowCtx
- context of the surrounding action-based workflowwriteWithNKChange
- if true, platform will check if the natural keys of the models have changed and write accordingly
-
executeIssueComps
<M extends Model> void executeIssueComps(ActionBasedWorkflowContext<M> workflowCtx, java.util.List<M> modelsToInclude, java.lang.String... issueCompNames)Given a list of Models from your workflow, executes the given issue computations on those models. Please note that any personalized issue computations provided in the list will be evaluated asynchronously post-workflow.- Type Parameters:
M
- model type- Parameters:
workflowCtx
- context of the surrounding action-based workflowmodelsToInclude
- List of models on which to execute the computationsissueCompNames
- issue computations to be executed
-