コード例 #1
0
 @Override
 public synchronized void setEnabled(String uid, boolean isEnabled) {
   ruleEngine.setRuleEnabled(uid, isEnabled);
   if (disabledRulesStorage != null)
     if (isEnabled) {
       disabledRulesStorage.remove(uid);
     } else {
       disabledRulesStorage.put(uid, isEnabled);
     }
 }
コード例 #2
0
 protected void setDisabledRuleStorage(Storage<Boolean> disabledRulesStorage) {
   this.disabledRulesStorage = disabledRulesStorage;
   for (Rule rule : ruleEngine.getRules()) {
     String uid = rule.getUID();
     if (ruleEngine.getRuleStatus(uid).equals(RuleStatus.DISABLED)) {
       disabledRulesStorage.put(uid, false);
     } else {
       disabledRulesStorage.remove(uid);
     }
   }
 }
コード例 #3
0
 @Override
 public synchronized Rule remove(String key) {
   Rule rule = super.remove(key);
   if (ruleEngine.removeRule(key)) {
     postEvent(RuleEventFactory.createRuleRemovedEvent(rule, SOURCE));
   }
   if (disabledRulesStorage != null) {
     disabledRulesStorage.remove(key);
   }
   return rule;
 }
コード例 #4
0
 @Override
 protected synchronized void removeProvider(Provider<Rule> provider) {
   Collection<Rule> rules = provider.getAll();
   for (Iterator<Rule> it = rules.iterator(); it.hasNext(); ) {
     Rule rule = it.next();
     String uid = rule.getUID();
     if (ruleEngine.removeRule(uid)) {
       postEvent(RuleEventFactory.createRuleRemovedEvent(rule, SOURCE));
     }
     if (disabledRulesStorage != null) {
       disabledRulesStorage.remove(uid);
     }
   }
   if (provider instanceof ManagedRuleProvider) {
     hasManagedRuleProvider = false;
   }
   super.removeProvider(provider);
 }