Class WorkflowRunContext

java.lang.Object
com.axelor.workflow.exec.WorkflowRunContext
All Implemented Interfaces:
ActivityContext, AutoCloseable

public final class WorkflowRunContext extends Object implements ActivityContext, AutoCloseable
  • Method Details

    • model

      public String model()
      Description copied from interface: ActivityContext
      The entity class the run is about.
      Specified by:
      model in interface ActivityContext
    • jsonModel

      public String jsonModel()
      Description copied from interface: ActivityContext
      The custom model, when ActivityContext.model() is a custom record; else null.
      Specified by:
      jsonModel in interface ActivityContext
    • recordId

      public Long recordId()
      Description copied from interface: ActivityContext
      The record the run is about, or null for a run with no record.
      Specified by:
      recordId in interface ActivityContext
    • event

      public WorkflowEvent event()
    • currentRunId

      public Long currentRunId()
      Description copied from interface: ActivityContext
      The run this walk belongs to, or null before one has been written.
      Specified by:
      currentRunId in interface ActivityContext
    • workflowName

      public String workflowName()
      Description copied from interface: ActivityContext
      The definition's name, as authored.
      Specified by:
      workflowName in interface ActivityContext
    • workflowXmlId

      public String workflowXmlId()
      The definition's xmlId, or null.
      Specified by:
      workflowXmlId in interface ActivityContext
    • recordName

      public String recordName()
      The record's display name: a custom record's name or the model's name column, or null.
      Specified by:
      recordName in interface ActivityContext
    • recordNameOf

      public static String recordNameOf(String model, Long recordId)
      recordName() for an arbitrary record; see recordOf(java.lang.String, java.lang.Long).
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • nodes

      public NodeRunBuffer nodes()
      Per-node history for this walk.
    • executing

      public void executing(String nodeId)
      Tell the context which node is about to run, for the bindings that describe it.
    • currentVisit

      public int currentVisit()
      Which pass over the executing node this is, from 1: durable across resumes for nodes that park, counted within this segment for the rest.
    • inFork

      public boolean inFork()
      Whether this walk belongs to a split's branch, walking or resumed; its park then belongs to the branch.
    • nodePath

      public String nodePath()
      The subflow node whose body this walk is in, or null for the definition's own graph; stamped on every visit it records.
    • nodePath

      public void nodePath(String nodePath)
    • enclosingToken

      public MetaWorkflowBranch enclosingToken()
      The branch this walk was resumed from, if any.
    • enclosingToken

      public void enclosingToken(MetaWorkflowBranch token)
    • enterFork

      public void enterFork()
      Track entering and leaving a split, so a nested park can be recognised.
    • leaveFork

      public void leaveFork()
    • forkDepth

      public int forkDepth()
    • parkedWith

      public void parkedWith(String key)
      Record that this node parked under key, for the visit about to be written.
    • reParked

      public void reParked()
      Record that this node's existing park was asked again rather than a new one opened.
    • splitTook

      public void splitTook(List<String> flowIds)
      Record the flows the executing split took, by id; its visit keeps them.
    • vars

      public Map<String,Object> vars()
      Description copied from interface: ActivityContext
      The process variables visible at this point, flattened.
      Specified by:
      vars in interface ActivityContext
    • setAgentBinding

      public void setAgentBinding(Map<String,Object> binding)
      Description copied from interface: ActivityContext
      Publish an activity's answer for the nodes after it to read by name.
      Specified by:
      setAgentBinding in interface ActivityContext
    • bindings

      public WalkBindings bindings()
      What this walk reads as agent, task and error now.
    • setTaskBinding

      public void setTaskBinding(Map<String,Object> binding)
    • setErrorBinding

      public void setErrorBinding(String message, String code)
      Bind the failure a boundary caught as error: its message, and its code or null.
    • cascadeId

      public String cascadeId()
      The cascade this walk belongs to, or null. A call's child inherits its caller's cascade, so a loop through a call stays bounded, but not its message.
      Specified by:
      cascadeId in interface ActivityContext
    • cascadeDepth

      public int cascadeDepth()
      How deep in that cascade this walk is; zero when nothing started it by message.
      Specified by:
      cascadeDepth in interface ActivityContext
    • runScript

      public void runScript(String id, String body)
      Run a <script> body: it may change self, build records with create(name) and persist them with save(obj), or save() for self.
    • evalExpr

      public Object evalExpr(String stepId, String expr)
      Evaluate a JS expression against the read-only scope, as a durable host value.
    • evalCondition

      public boolean evalCondition(String stepId, String expr)
      Evaluate a condition: anything but boolean true is false.
    • decide

      public List<Integer> decide(String nodeId, List<String> conditions, boolean inclusive)
      Evaluate a split's flow conditions in one call and return the matching indices in order; a one split stops at the first match.
    • renderTemplate

      public String renderTemplate(String stepId, String text)
      Render a template, evaluating its ${expr} spans against this run's scope.
      Specified by:
      renderTemplate in interface ActivityContext
    • resolveUser

      public User resolveUser(String stepId, String expr)
      Evaluate expr and coerce the result to a User, or null.
    • resolveSelf

      public List<RecordRef> resolveSelf()
      This run's own record, for a selector-less call; empty only for a run with no record.
    • resolveRecord

      public List<RecordRef> resolveRecord(String stepId, String expr)
      The one persisted record record selects; anything else fails.
    • resolveCollection

      public List<RecordRef> resolveCollection(String stepId, String expr)
      The records each selects; a scalar is refused, since record says one record.
    • resolveQueryIds

      public List<Long> resolveQueryIds(String stepId, String model, String filter, int cap)
      The ids a filter selects, and the records behind them.
    • loadByIds

      public <T extends Model> List<T> loadByIds(String model, List<Long> ids)