Interface RuleManager


  • @NonNullByDefault
    public interface RuleManager
    This class is responsible to provide a RegistryChangeListener logic. A 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 Detail

      • 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 RuleStatus#DISABLED.
        Parameters:
        uid - the unique identifier of the Rule.
        isEnabled - a new enabled / disabled state of the Rule.
      • 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 exists.
      • 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:
        ruleUID - 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:
        ruleUID - 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.
      • simulateRuleExecutions

        Stream<RuleExecution> simulateRuleExecutions​(ZonedDateTime from,
                                                     ZonedDateTime until)
        Simulates the execution of all rules with tag 'Schedule' for the given time interval. The result is sorted ascending by execution time.
        Parameters:
        from - ZonedDateTime earliest time to be contained in the rule simulation.
        until - ZonedDateTime latest time to be contained in the rule simulation.
        Returns:
        A Stream with all expected RuleExecution.