diff options
author | Godin <mandrikov@gmail.com> | 2010-12-21 22:45:14 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-12-21 22:45:14 +0000 |
commit | 2398469a24eb259e8b8de911a373bb49615d761c (patch) | |
tree | 8006be4514c54495b66cdb7adf9fafdeedc27133 /sonar-server/src/main/java | |
parent | 4d2ccd83150e1e769e67fb71bd4d519c6913cd6e (diff) | |
download | sonarqube-2398469a24eb259e8b8de911a373bb49615d761c.tar.gz sonarqube-2398469a24eb259e8b8de911a373bb49615d761c.zip |
SONAR-1722: Merge two fields ActiveRule.inherited and ActiveRule.overridden into one with enum type
Diffstat (limited to 'sonar-server/src/main/java')
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java | 6 | ||||
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java | 24 |
2 files changed, 13 insertions, 17 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java index 85dfbbae810..543606779fb 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java @@ -169,8 +169,7 @@ public class ProfilesBackup implements Backupable { writeNode(writer, "key", rule.getRule().getKey()); writeNode(writer, "plugin", rule.getRule().getRepositoryKey()); writeNode(writer, "level", rule.getSeverity().name()); - writeNode(writer, "inherited", Boolean.toString(rule.isInherited())); - writeNode(writer, "overridden", Boolean.toString(rule.isOverridden())); + writeNode(writer, "inherited", rule.getInheritanceStatus().toString()); if (!rule.getActiveRuleParams().isEmpty()) { writer.startNode("params"); @@ -206,8 +205,7 @@ public class ProfilesBackup implements Backupable { ActiveRule activeRule = new ActiveRule(null, new Rule(valuesRule.get("plugin"), valuesRule.get("key")), RulePriority .valueOf(valuesRule.get("level"))); activeRule.setActiveRuleParams(params); - activeRule.setInherited(Boolean.parseBoolean(valuesRule.get("inherited"))); - activeRule.setOverridden(Boolean.parseBoolean(valuesRule.get("overridden"))); + activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.valueOf(valuesRule.get("inherited"))); return activeRule; } diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java index bae9f3bff68..f17cb5194d9 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java @@ -19,6 +19,8 @@ */ package org.sonar.server.configuration; +import org.sonar.api.rules.ActiveRuleInheritanceStatus; + import org.sonar.api.database.DatabaseSession; import org.sonar.api.database.model.ResourceModel; import org.sonar.api.profiles.RulesProfile; @@ -116,8 +118,8 @@ public class ProfilesManager extends BaseDao { */ public void activatedOrChanged(int parentProfileId, int activeRuleId) { ActiveRule parentActiveRule = getSession().getEntity(ActiveRule.class, activeRuleId); - if (parentActiveRule.isInherited() && !parentActiveRule.isOverridden()) { - parentActiveRule.setOverridden(true); + if (parentActiveRule.getInheritanceStatus() == ActiveRuleInheritanceStatus.INHERITED) { + parentActiveRule.setInheritanceStatus(ActiveRuleInheritanceStatus.OVERRIDDEN); getSession().saveWithoutFlush(parentActiveRule); } for (RulesProfile child : getChildren(parentProfileId)) { @@ -153,13 +155,12 @@ public class ProfilesManager extends BaseDao { public void revert(int profileId, int activeRuleId) { RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId); ActiveRule activeRule = getSession().getEntity(ActiveRule.class, activeRuleId); - if (activeRule != null && activeRule.isInherited() && activeRule.isOverridden()) { + if (activeRule != null && activeRule.getInheritanceStatus() == ActiveRuleInheritanceStatus.OVERRIDDEN) { ActiveRule parentActiveRule = getParentProfile(profile).getActiveRule(activeRule.getRule()); removeActiveRule(profile, activeRule); activeRule = (ActiveRule) parentActiveRule.clone(); activeRule.setRulesProfile(profile); - activeRule.setInherited(true); - activeRule.setOverridden(false); + activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.INHERITED); profile.getActiveRules().add(activeRule); getSession().saveWithoutFlush(activeRule); @@ -174,19 +175,17 @@ public class ProfilesManager extends BaseDao { private void activateOrChange(RulesProfile profile, ActiveRule parentActiveRule) { ActiveRule activeRule = profile.getActiveRule(parentActiveRule.getRule()); if (activeRule != null) { - if (activeRule.isInherited() && !activeRule.isOverridden()) { + if (activeRule.getInheritanceStatus() == ActiveRuleInheritanceStatus.INHERITED) { removeActiveRule(profile, activeRule); } else { - activeRule.setInherited(true); - activeRule.setOverridden(true); + activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.OVERRIDDEN); getSession().saveWithoutFlush(activeRule); return; // no need to change in children } } activeRule = (ActiveRule) parentActiveRule.clone(); activeRule.setRulesProfile(profile); - activeRule.setInherited(true); - activeRule.setOverridden(false); + activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.INHERITED); profile.getActiveRules().add(activeRule); getSession().saveWithoutFlush(activeRule); @@ -198,11 +197,10 @@ public class ProfilesManager extends BaseDao { private void deactivate(RulesProfile profile, Rule rule) { ActiveRule activeRule = profile.getActiveRule(rule); if (activeRule != null) { - if (activeRule.isInherited() && !activeRule.isOverridden()) { + if (activeRule.getInheritanceStatus() == ActiveRuleInheritanceStatus.INHERITED) { removeActiveRule(profile, activeRule); } else { - activeRule.setInherited(false); - activeRule.setOverridden(false); + activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.NO); getSession().saveWithoutFlush(activeRule); return; // no need to change in children } |