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 Details

    • populateCurrentFromDatabase

      <M extends Model> void populateCurrentFromDatabase​(ActionBasedWorkflowContext<M> workflowCtx, FetchParam... fetchParams)
      Based on the records provided by the user in the input of the ActionBasedWorkflowContext, 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 provide FetchParam 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

      For example, take a 3-level model Order, with levels OrderHeader, OrderLineItem and OrderSchedule:

       // 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 context
      fetchParams - params to indicate what data precisely should be fetched
    • mergeInputToCurrent

      <M extends Model> void mergeInputToCurrent​(ActionBasedWorkflowContext<M> workflowCtx)
      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

      <M extends Model> void write​(java.util.List<M> models, ActionBasedWorkflowContext<M> workflowCtx)
      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 use write(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 workflow
      writeWithNKChange - 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 workflow
      modelsToInclude - List of models on which to execute the computations
      issueCompNames - issue computations to be executed