Package com.axelor.ai.procedure
Class ProcedureRunner
java.lang.Object
com.axelor.ai.procedure.ProcedureRunner
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn alert met during the run, and how it was answered.static final classThe guard said no; nothing ran beyond loading the form.static enumHow the form open beside the chat was used, when it showed the procedure's record.static final recordWhat a run did.static final recordA run stopped at a question for the user, with all it needs to carry on: the form's state, the procedure step it stopped in (-1for the form's load hooks), and what the run met so far.static final recordA message the browser would have shown, kept with a paused run. -
Method Summary
Modifier and TypeMethodDescriptionWhy 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.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.run(Procedure procedure, Long id, Map<String, Object> inputs, boolean askable, Map<String, Object> activeView) Runs the procedure from the start.
-
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 procedureid- the record, or null for anewprocedureinputs- typed asProcedureInputstypes themaskable- 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 itactiveView- 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 thewhenguard 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-truefor the question's Yes,falsefor 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
-