Class WorkflowRunService

java.lang.Object
com.axelor.workflow.history.WorkflowRunService

public class WorkflowRunService extends Object
Persists workflow run history. Failed and parked runs are always recorded; successful and skipped runs only when workflow.trace asks for them (see WorkflowTraceLevel).
  • Constructor Details

    • WorkflowRunService

      public WorkflowRunService()
  • Method Details

    • begin

      public MetaWorkflowRun begin(MetaWorkflow def, String model, Long recordId, TriggerKind trigger, Long episode, Long parentRunId, String subflowNode, String callerParkKey)
      Begins a run row whatever the trace level, for a run that must exist before its outcome is known: a parent for child runs, or a row to link node visits to.
    • beginFrom

      public MetaWorkflowRun beginFrom(MetaWorkflowRun host, String subflowNode)
      Begins a non-cancelling boundary's escape branch, copying the host run's pinned identity (xmlId, revision, name, model, jsonModel) so it walks the host's revision.
      Parameters:
      subflowNode - the boundary's own id, never the host's node id: WorkflowWaitService.resumeCaller(com.axelor.meta.db.MetaWorkflowRun) tells a call's child from an escape branch by this never matching the host's current node
    • finish

      public void finish(MetaWorkflowRun run, WorkflowResult result)
      Finishes a run begun with begin(com.axelor.meta.db.MetaWorkflow, java.lang.String, java.lang.Long, com.axelor.meta.schema.workflows.TriggerKind, java.lang.Long, java.lang.Long, java.lang.String, java.lang.String), whatever the trace level.

      A terminal result is held at "waiting" while an escape branch this run spawned is still live; settleAsLastBranch(com.axelor.meta.db.MetaWorkflowRun) applies it when the last branch finishes. Such a run is told apart from a real park by having no park key and no open approval (isParked(com.axelor.meta.db.MetaWorkflowRun)).

    • recordFailure

      public MetaWorkflowRun recordFailure(MetaWorkflow def, String model, Long recordId, TriggerKind trigger, WorkflowResult result, LocalDateTime startedAt, Long episode)
      Record a failed run. Always persisted (not gated on workflow.trace).
    • recordSkipped

      public void recordSkipped(MetaWorkflow def, String model, Long recordId, TriggerKind trigger, String reason, Long episode)
      Records a run rejected before executing, such as by the re-entrancy guard. Skipped unless workflow.trace is at least runs, since a workflow saving its own record yields one per run.
    • stitchResume

      public void stitchResume(String parkKey)
      Closes the open park identified by parkKey, stamping when it resumed and how long it waited. Never throws: a woken run must not fail over a timestamp.
    • stitchResume

      public void stitchResume(String parkKey, String viaBoundary)
      Parameters:
      viaBoundary - the boundary that ended this park, or null when the node's own trigger did; two boundaries may lead to the same node, so the next row cannot tell
    • cancelParkedVisits

      public void cancelParkedVisits(Collection<MetaWorkflowBranch> branches)
      Rewrites the visits these branches were parked at as cancelled, for branches taken down after their walk committed: a race loser, or seats still open when a quorum is met or a veto ends the run. The committed counterpart of NodeRunBuffer.cancelPark(java.lang.String).
    • closeHeldVisit

      public void closeHeldVisit(MetaWorkflowSplit split, WorkflowNodeRunStatus status, String error, String viaBoundary)
      Closes the visit of a subflow or iterating call left waiting on its elements, once the activation they were written into is over: completed when they settled or a boundary led away, failed when one of them failed. It has no park of its own to stitch, so it is found through the activation: its node, on the branch the activation hangs from.
      Parameters:
      error - the failure to record, or null
      viaBoundary - the boundary that led away, or null