Class ProcedureRunner

java.lang.Object
com.axelor.ai.procedure.ProcedureRunner

public class ProcedureRunner extends Object
Runs a procedure on its form, with no browser: each step as a user would do it.

The form is opened on the record (or a new one) through its action-view, its load hooks run, the when guard is checked on what was loaded, then each step runs in turn. A set value written as eval: is evaluated just before its step, on the form's values at that moment, by the same engine as action-record, with the inputs as inputs.<name>. An alert is answered by the procedure's interactions; one it does not answer is declined.

Must run outside any transaction: every server round trip commits on its own, as in the browser, so a save before a later stop stays saved.

  • Method Details

    • run

      public ProcedureRunner.Outcome run(Procedure procedure, Long id, Map<String,Object> inputs, boolean askable, Map<String,Object> activeView)
      Runs the procedure from the start.
      Parameters:
      procedure - a validated procedure
      id - the record, or null for a new procedure
      inputs - typed as ProcedureInputs types them
      askable - whether a user is there to answer: in a chat, an alert the procedure does not answer pauses the run (FormResult.Status.SUSPENDED); with nobody to ask, it stops it
      activeView - the context of the view open beside the chat, or null: when it is a form of this record, the run starts from what it shows, unsaved edits included. It is read once, here; the run never consults it again.
      Throws:
      ProcedureRunner.GuardFailed - when the when guard is false on the loaded record
    • refusal

      public String refusal(Procedure procedure, Long id, Map<String,Object> inputs, Map<String,Object> activeView)
      Why the procedure would not run on the record, or null when it would: its guard, read on the record as a run would open it — from the open form's values when a run would use them — before any of the form runs. For telling before a run whether it is worth asking the user; the form's hooks are the application's own code, and none may run before the user approves. The run reads the guard again once its load hooks are through.
    • resume

      public ProcedureRunner.Outcome resume(Procedure procedure, Map<String,Object> inputs, ProcedureRunner.Paused paused, boolean answer, boolean askable)
      Carries a paused run on with the user's answer to its question, from where it stopped, with the values it held then.
      Parameters:
      answer - true for the question's Yes, false for its No — on No, the alert's own action runs and the run ends, as in the browser
      Throws:
      ProcedureRunner.GuardFailed - when the run paused in the load hooks and the guard is then false