Package com.axelor.workflow.registry
Class WorkflowRegistry
java.lang.Object
com.axelor.workflow.registry.WorkflowRegistry
- All Implemented Interfaces:
WorkflowDefinitions
Resolves the ordered workflows eligible for a model and trigger: each
(model, jsonModel,
name) collapses to its highest-priority active definition, ordered by sequence, then id.
It also keeps, per tenant, which models have any workflow, so the flush listener never queries.
Snapshots rebuild when a (count, sum(version), max(id)) stamp over META_WORKFLOW
moves, checked at dispatch, on repository saves and on each scheduler poll. Bulk JPQL updates
bypass the stamp; the repository is the supported write path.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat a workflow is bound to: an entity class, plus the custom model when that class isMetaJsonRecord. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe engine's contract; delegates tostamp().booleandispatches(String model, String jsonModel) Whether a save here could dispatch a workflow.voidevict()Drop every cached snapshot.booleanhasWorkflows(String model, String jsonModel) Whether any workflow could be bound to a record here, manual ones included; the same fail-open rule.identityOf(String name) The identity of the active workflow namedname, or null; throws when the name is used on several models.voidrefresh()Rebuild this tenant's snapshot when the stamp has moved.resolve(String model, String jsonModel, TriggerKind trigger) The definitions eligible for this record and trigger, in the order they should run.resolveByName(String model, String jsonModel, String name) The effective (highest-priority active) workflow for an override key, or null.resolveByRef(String name) The highest-priority active workflow namedname, ornull.resolveOne(String name, String model, String jsonModel) The effective definition for(model, jsonModel, name), for a programmatic run.static Stringstamp()The stamp this tenant's snapshot was built on, or null before one exists.startingOn(String messageName) The definitions that start on this message name, across every model.
-
Constructor Details
-
WorkflowRegistry
public WorkflowRegistry()
-
-
Method Details
-
dispatches
Whether a save here could dispatch a workflow. Answers from memory and says true before any snapshot exists.- Specified by:
dispatchesin interfaceWorkflowDefinitions- Parameters:
jsonModel- the custom model, whenmodelisMetaJsonRecord; else null
-
currentStamp
The engine's contract; delegates tostamp().- Specified by:
currentStampin interfaceWorkflowDefinitions
-
stamp
The stamp this tenant's snapshot was built on, or null before one exists. Read from memory, for the capture written during a business transaction. -
hasWorkflows
Whether any workflow could be bound to a record here, manual ones included; the same fail-open rule.- Specified by:
hasWorkflowsin interfaceWorkflowDefinitions- Parameters:
jsonModel- the custom model, whenmodelisMetaJsonRecord; else null
-
refresh
public void refresh()Rebuild this tenant's snapshot when the stamp has moved. count catches deletes, the version sum updates, and max(id) an insert that happens to restore both. Needs an EntityManager; never call from a flush.- Specified by:
refreshin interfaceWorkflowDefinitions
-
evict
public void evict()Drop every cached snapshot.dispatches(java.lang.String, java.lang.String)fails open until the nextrefresh(). -
resolve
Description copied from interface:WorkflowDefinitionsThe definitions eligible for this record and trigger, in the order they should run.- Specified by:
resolvein interfaceWorkflowDefinitions
-
startingOn
The definitions that start on this message name, across every model. The name is in the XML, so this compiles the message-started definitions once per name per snapshot.- Specified by:
startingOnin interfaceWorkflowDefinitions
-
resolveOne
The effective definition for(model, jsonModel, name), for a programmatic run.- Specified by:
resolveOnein interfaceWorkflowDefinitions
-
resolveByName
The effective (highest-priority active) workflow for an override key, or null. -
identityOf
The identity of the active workflow namedname, or null; throws when the name is used on several models. -
resolveByRef
The highest-priority active workflow namedname, ornull.- Specified by:
resolveByRefin interfaceWorkflowDefinitions
-