Пример #1
0
  public void revert(int profileId, int activeRuleId, String userName) {
    RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId);
    ActiveRule oldActiveRule = getSession().getEntity(ActiveRule.class, activeRuleId);
    if (oldActiveRule != null && oldActiveRule.doesOverride()) {
      ActiveRule parentActiveRule =
          getParentProfile(profile).getActiveRule(oldActiveRule.getRule());
      removeActiveRule(profile, oldActiveRule);
      ActiveRule newActiveRule = (ActiveRule) parentActiveRule.clone();
      newActiveRule.setRulesProfile(profile);
      newActiveRule.setInheritance(ActiveRule.INHERITED);
      profile.addActiveRule(newActiveRule);
      getSession().saveWithoutFlush(newActiveRule);

      // Compute change
      ruleChanged(profile, oldActiveRule, newActiveRule, userName);

      for (RulesProfile child : getChildren(profile)) {
        activateOrChange(child, newActiveRule, userName);
      }

      getSession().commit();
    }
  }