Exemple #1
0
  private void activateOrChange(
      RulesProfile profile, ActiveRule parentActiveRule, String userName) {
    ActiveRule oldActiveRule = profile.getActiveRule(parentActiveRule.getRule());
    if (oldActiveRule != null) {
      if (oldActiveRule.isInherited()) {
        removeActiveRule(profile, oldActiveRule);
      } else {
        oldActiveRule.setInheritance(ActiveRule.OVERRIDES);
        getSession().saveWithoutFlush(oldActiveRule);
        return; // no need to change in children
      }
    }
    ActiveRule newActiveRule = (ActiveRule) parentActiveRule.clone();
    newActiveRule.setRulesProfile(profile);
    newActiveRule.setInheritance(ActiveRule.INHERITED);
    profile.addActiveRule(newActiveRule);
    getSession().saveWithoutFlush(newActiveRule);

    if (oldActiveRule != null) {
      ruleChanged(profile, oldActiveRule, newActiveRule, userName);
    } else {
      ruleEnabled(profile, newActiveRule, userName);
    }

    for (RulesProfile child : getChildren(profile)) {
      activateOrChange(child, newActiveRule, userName);
    }
  }
Exemple #2
0
 /** Rule was activated/changed in parent profile. */
 private void activatedOrChanged(int parentProfileId, int activeRuleId, String userName) {
   ActiveRule parentActiveRule = getSession().getEntity(ActiveRule.class, activeRuleId);
   if (parentActiveRule.isInherited()) {
     parentActiveRule.setInheritance(ActiveRule.OVERRIDES);
     getSession().saveWithoutFlush(parentActiveRule);
   }
   for (RulesProfile child : getChildren(parentProfileId)) {
     activateOrChange(child, parentActiveRule, userName);
   }
   getSession().commit();
 }
Exemple #3
0
  private void deactivate(RulesProfile profile, Rule rule, String userName) {
    ActiveRule activeRule = profile.getActiveRule(rule);
    if (activeRule != null) {
      if (activeRule.isInherited()) {
        ruleDisabled(profile, activeRule, userName);
        removeActiveRule(profile, activeRule);
      } else {
        activeRule.setInheritance(null);
        getSession().saveWithoutFlush(activeRule);
        return; // no need to change in children
      }

      for (RulesProfile child : getChildren(profile)) {
        deactivate(child, rule, userName);
      }
    }
  }