From: Julien Lancelot Date: Thu, 12 May 2016 15:53:07 +0000 (+0200) Subject: SONAR-7400 Remove parentKey field from active rule index X-Git-Tag: 5.6-RC1~85 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f5caef1c16986e0a535555e604bab799554bf028;p=sonarqube.git SONAR-7400 Remove parentKey field from active rule index --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ActiveRule.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ActiveRule.java index 1afbaba5fa4..f863366203c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ActiveRule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ActiveRule.java @@ -19,7 +19,6 @@ */ package org.sonar.server.qualityprofile; -import javax.annotation.CheckForNull; import org.sonar.db.qualityprofile.ActiveRuleKey; public interface ActiveRule { @@ -38,7 +37,4 @@ public interface ActiveRule { Inheritance inheritance(); - @CheckForNull - ActiveRuleKey parentKey(); - } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java index 472c048246b..12cee53358e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java @@ -22,7 +22,6 @@ package org.sonar.server.qualityprofile.index; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; import java.util.Map; -import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.db.qualityprofile.ActiveRuleKey; import org.sonar.server.qualityprofile.ActiveRule; @@ -32,7 +31,6 @@ import static org.apache.commons.lang.StringUtils.containsIgnoreCase; import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_CREATED_AT; import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_INHERITANCE; import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_KEY; -import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_PARENT_KEY; import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_PROFILE_KEY; import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_REPOSITORY; import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_RULE_KEY; @@ -94,21 +92,6 @@ public class ActiveRuleDoc extends BaseDoc implements ActiveRule { return this; } - @Override - @CheckForNull - public ActiveRuleKey parentKey() { - String data = getNullableField(FIELD_ACTIVE_RULE_PARENT_KEY); - if (data != null && !data.isEmpty()) { - return ActiveRuleKey.parse(data); - } - return null; - } - - public ActiveRuleDoc setParentKey(@Nullable String s) { - setField(FIELD_ACTIVE_RULE_PARENT_KEY, s); - return this; - } - @Override public long createdAt() { return (Long) getField(FIELD_ACTIVE_RULE_CREATED_AT); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIterator.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIterator.java index 5b5e944a84c..362cebb834a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIterator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIterator.java @@ -43,15 +43,13 @@ public class ActiveRuleResultSetIterator extends ResultSetIterator?"; @@ -83,22 +81,10 @@ public class ActiveRuleResultSetIterator extends ResultSetIterator> stats = index.getStatsByProfileKeys(profileKeys); assertThat(stats).hasSize(30); @@ -158,8 +156,7 @@ public class ActiveRuleIndexTest { indexRules( RuleDocTesting.newDoc(RULE_KEY_1), RuleDocTesting.newDoc(RULE_KEY_2), - RuleDocTesting.newDoc(RuleKey.of("xoo", "removed")).setStatus(RuleStatus.REMOVED.name()) - ); + RuleDocTesting.newDoc(RuleKey.of("xoo", "removed")).setStatus(RuleStatus.REMOVED.name())); indexActiveRules( ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY1, RULE_KEY_1)), @@ -168,8 +165,7 @@ public class ActiveRuleIndexTest { // Removed rule can still be activated for instance when removing the checkstyle plugin, active rules related on checkstyle are not // removed // because if the plugin is re-install, quality profiles using these rule are not changed. - ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RuleKey.of("xoo", "removed"))) - ); + ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RuleKey.of("xoo", "removed")))); // 1. find by rule key diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java index 2f0fb5e6f5b..d63c14fe102 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java @@ -443,12 +443,9 @@ public class RuleIndexTest { ActiveRuleDocTesting.newDoc(activeRuleKey2), ActiveRuleDocTesting.newDoc(activeRuleKey3), // Profile 2 is a child a profile 1 - ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_1)) - .setParentKey(activeRuleKey1.toString()).setInheritance(INHERITED.name()), - ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_2)) - .setParentKey(activeRuleKey2.toString()).setInheritance(OVERRIDES.name()), - ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_3)) - .setParentKey(activeRuleKey3.toString()).setInheritance(INHERITED.name())); + ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_1)).setInheritance(INHERITED.name()), + ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_2)).setInheritance(OVERRIDES.name()), + ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_3)).setInheritance(INHERITED.name())); // 0. get all rules assertThat(index.search(new RuleQuery(), new SearchOptions()).getIds())