Package com.axelor.workflow.expression
Class WorkflowConditionEvaluator
java.lang.Object
com.axelor.workflow.expression.WorkflowConditionEvaluator
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classAnswers many predicates in one sandbox realm; a fresh realm's first evaluation pays the JS builtins' lazy setup. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbatch()Opens a batch; seeWorkflowConditionEvaluator.Batchfor what may share one.voidParse-checks source as authored, without running it; throws on a syntax error.booleanEvaluates the predicate against the snapshots, as a JavaScript truthiness boolean.boolean[]Evaluates the predicate against the new snapshot and, whenoldis present, against the prior one, in one context.static org.graalvm.polyglot.proxy.ProxyObjectWraps a snapshot map as a guest object, coercing host scalars to guest values.
-
Constructor Details
-
WorkflowConditionEvaluator
public WorkflowConditionEvaluator()
-
-
Method Details
-
evaluate
Evaluates the predicate against the snapshots, as a JavaScript truthiness boolean.- Parameters:
expr- thewhenpredicateself- current scalar field values (never null)old- prior scalar field values, or null on create
-
evaluateTransition
Evaluates the predicate against the new snapshot and, whenoldis present, against the prior one, in one context. Returns[whenNew, whenOld];whenOldis false on create. -
check
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 apredicate(java.lang.String). -
batch
Opens a batch; seeWorkflowConditionEvaluator.Batchfor what may share one. -
toGuest
Wraps a snapshot map as a guest object, coercing host scalars to guest values.
-