Interface ModuleHandlerCallback

All Known Subinterfaces:
SimpleTriggerHandlerCallback, TriggerHandlerCallback

@NonNullByDefault public interface ModuleHandlerCallback
This class is responsible to provide a RegistryChangeListener logic. An instance of it is added to RuleRegistry service, to listen for changes when a single Rule has been added, updated, enabled, disabled or removed and to involve Rule Engine to process these changes. Also to send a run command for a single Rule to the Rule Engine.
Author:
Kai Kreuzer - Initial contribution
  • Method Details

    • isEnabled

      @Nullable Boolean isEnabled(String ruleUID)
      This method gets enabled RuleStatus for a Rule. The enabled rule statuses are RuleStatus.UNINITIALIZED, RuleStatus.IDLE and RuleStatus.RUNNING. The disabled rule status is RuleStatusDetail.DISABLED.
      Parameters:
      ruleUID - UID of the Rule
      Returns:
      true when the RuleStatus is one of the RuleStatus.UNINITIALIZED, RuleStatus.IDLE and RuleStatus.RUNNING, false when it is RuleStatusDetail.DISABLED and null when it is not available.
    • setEnabled

      void setEnabled(String uid, boolean isEnabled)
      This method is used for changing enabled state of the Rule. The enabled rule statuses are RuleStatus.UNINITIALIZED, RuleStatus.IDLE and RuleStatus.RUNNING. The disabled rule status is RuleStatusDetail.DISABLED.
      Parameters:
      uid - the unique identifier of the Rule.
      isEnabled - a new enabled / disabled state of the Rule.
    • getStatusInfo

      @Nullable RuleStatusInfo getStatusInfo(String ruleUID)
      This method gets RuleStatusInfo of the specified Rule.
      Parameters:
      ruleUID - UID of the Rule
      Returns:
      RuleStatusInfo object containing status of the looking Rule or null when a rule with specified UID does not exist.
    • getStatus

      @Nullable RuleStatus getStatus(String ruleUID)
      Utility method which gets RuleStatus of the specified Rule.
      Parameters:
      ruleUID - UID of the Rule
      Returns:
      RuleStatus object containing status of the looking Rule or null when a rule with specified UID does not exist.
    • runNow

      void runNow(String uid)
      The method skips the triggers and the conditions and directly executes the actions of the rule. This should always be possible unless an action has a mandatory input that is linked to a trigger. In that case the action is skipped and the rule engine continues execution of rest actions.
      Parameters:
      uid - id of the rule whose actions have to be executed.
    • runNow

      void runNow(String uid, boolean considerConditions, @Nullable Map<String,Object> context)
      Same as runNow(String) with the additional option to enable/disable evaluation of conditions defined in the target rule. The context can be set here, too, but also might be null.
      Parameters:
      uid - id of the rule whose actions have to be executed.
      considerConditions - if true the conditions of the rule will be checked.
      context - the context that is passed to the conditions and the actions of the rule.