Class WorkflowConditionEvaluator

java.lang.Object
com.axelor.workflow.expression.WorkflowConditionEvaluator

public class WorkflowConditionEvaluator extends Object
Evaluates a workflow when predicate in a sandbox. Exposes only the self and old scalar snapshots and log: no __repo__, __bean__, host classes or polyglot access, which keeps it safe on the save path. Compiled sources are cached.
  • Constructor Details

    • WorkflowConditionEvaluator

      public WorkflowConditionEvaluator()
  • Method Details

    • evaluate

      public boolean evaluate(String expr, Map<String,Object> self, Map<String,Object> old)
      Evaluates the predicate against the snapshots, as a JavaScript truthiness boolean.
      Parameters:
      expr - the when predicate
      self - current scalar field values (never null)
      old - prior scalar field values, or null on create
    • evaluateTransition

      public boolean[] evaluateTransition(String expr, Map<String,Object> self, Map<String,Object> old)
      Evaluates the predicate against the new snapshot and, when old is present, against the prior one, in one context. Returns [whenNew, whenOld]; whenOld is false on create.
    • check

      public void check(String expr)
      Parse-checks source as authored, without running it; throws on a syntax error. Also used for script bodies, which are statements, so the source is not wrapped as a predicate(java.lang.String).
    • batch

      Opens a batch; see WorkflowConditionEvaluator.Batch for what may share one.
    • toGuest

      public static org.graalvm.polyglot.proxy.ProxyObject toGuest(Map<String,Object> snapshot)
      Wraps a snapshot map as a guest object, coercing host scalars to guest values.