Class WorkflowContext

java.lang.Object
com.axelor.workflow.WorkflowContext

public final class WorkflowContext extends Object
The tenant and acting user, read from the ambient context where they are used rather than carried on events: every thread that runs workflow logic is already bound to the right ones.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    A scope opened by one of the methods below; closing it ends that scope on the thread.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    The current tenant, normalized to "" so cache keys match in single-tenant setups.
    static Long
    The acting user's id, or null for a system run.
    Mark definition writes on this thread as a module deployment, exempt from the guard against changing a definition that has parked runs.
    Mark definition writes on this thread as a Studio deploy: like deploy() it re-derives active, but it keeps the in-flight guard and the agent check.
    static boolean
    Whether definition writes on this thread are authoritative deployments.
    static boolean
    Whether definition writes on this thread are an interactive (Studio) deploy.
    static boolean
    Whether workflow dispatch is currently suppressed on this thread.
    Suppress workflow dispatch on this thread: saves inside the scope start no workflow.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • suppress

      public static WorkflowContext.Scope suppress()
      Suppress workflow dispatch on this thread: saves inside the scope start no workflow. For bulk imports, migrations and demo data. Nestable; use with try-with-resources:
      try (var ignored = WorkflowContext.suppress()) { importer.importAll(data); // no
       workflows fire on these saves } 
    • isSuppressed

      public static boolean isSuppressed()
      Whether workflow dispatch is currently suppressed on this thread.
    • deploy

      public static WorkflowContext.Scope deploy()
      Mark definition writes on this thread as a module deployment, exempt from the guard against changing a definition that has parked runs. Nestable.
    • isDeploying

      public static boolean isDeploying()
      Whether definition writes on this thread are authoritative deployments.
    • interactiveDeploy

      public static WorkflowContext.Scope interactiveDeploy()
      Mark definition writes on this thread as a Studio deploy: like deploy() it re-derives active, but it keeps the in-flight guard and the agent check.
    • isInteractiveDeploy

      public static boolean isInteractiveDeploy()
      Whether definition writes on this thread are an interactive (Studio) deploy.
    • currentTenant

      public static String currentTenant()
      The current tenant, normalized to "" so cache keys match in single-tenant setups.
    • currentUserId

      public static Long currentUserId()
      The acting user's id, or null for a system run.