From e537ea6120df8eb20ba04da66811c21161f6ec6d Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Wed, 1 Dec 2010 11:30:48 +0000 Subject: SONAR-2007 Remove the useless ISO Categories + fix components page --- .../src/main/java/org/sonar/jpa/dao/RulesDao.java | 40 ++++------------------ .../java/org/sonar/jpa/entity/SchemaMigration.java | 2 +- sonar-core/src/main/resources/ehcache.xml | 2 +- .../test/java/org/sonar/jpa/dao/RulesDaoTest.java | 14 +------- .../core/components/CacheRuleFinderTest/shared.xml | 8 ++--- .../components/DefaultRuleFinderTest/shared.xml | 8 ++--- .../shouldAddActiveRulesToProfile-result.xml | 2 +- .../RulesDaoTest/shouldAddActiveRulesToProfile.xml | 2 +- ...ountNumberOfRulesOfACategoryForGivenPlugins.xml | 8 ++--- ...tiveRuleParametersFromARuleParameter-result.xml | 2 +- ...eleteActiveRuleParametersFromARuleParameter.xml | 2 +- .../shouldDeleteActiveRules-result.xml | 6 ++-- .../dao/RulesDaoTest/shouldDeleteActiveRules.xml | 6 ++-- .../jpa/dao/RulesDaoTest/shouldGetActiveRules.xml | 6 ++-- .../jpa/dao/RulesDaoTest/shouldGetRuleParams.xml | 4 +-- .../shouldGetRuleWithRuleKeyAndPluginKey.xml | 2 +- .../sonar/jpa/dao/RulesDaoTest/shouldGetRules.xml | 4 +-- .../shouldSynchronizeRuleOfActiveRule.xml | 4 +-- 18 files changed, 41 insertions(+), 81 deletions(-) (limited to 'sonar-core/src') diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java index 3f5788bae6c..736d977ac30 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java @@ -23,16 +23,16 @@ import org.sonar.api.database.DatabaseSession; import org.sonar.api.database.model.RuleFailureModel; import org.sonar.api.database.model.Snapshot; import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.*; +import org.sonar.api.rules.ActiveRule; +import org.sonar.api.rules.ActiveRuleParam; +import org.sonar.api.rules.Rule; +import org.sonar.api.rules.RuleParam; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class RulesDao extends BaseDao { - private List rulesCategories; - public RulesDao(DatabaseSession session) { super(session); } @@ -45,39 +45,18 @@ public class RulesDao extends BaseDao { return getSession().getResults(Rule.class, "pluginName", pluginKey, "enabled", true); } - public List getRulesByCategory(RulesCategory categ) { - List result = new ArrayList(); - for (Rule rule : getRules()) { - if (rule.getRulesCategory().equals(categ)) { - result.add(rule); - } - } - return result; - } public Rule getRuleByKey(String pluginKey, String ruleKey) { return getSession().getSingleResult(Rule.class, "key", ruleKey, "pluginName", pluginKey, "enabled", true); } - public Long countRules(List plugins, String categoryName) { + public Long countRules(List plugins) { return (Long) getSession().createQuery( - "SELECT COUNT(r) FROM Rule r WHERE r.pluginName IN (:pluginNames) AND r.rulesCategory=:rulesCategory AND r.enabled=true"). + "SELECT COUNT(r) FROM Rule r WHERE r.pluginName IN (:pluginNames) AND r.enabled=true"). setParameter("pluginNames", plugins). - setParameter("rulesCategory", getCategory(categoryName)). getSingleResult(); } - public List getCategories() { - if (rulesCategories == null) { - rulesCategories = getSession().getResults(RulesCategory.class); - } - return rulesCategories; - } - - public RulesCategory getCategory(String key) { - return getSession().getSingleResult(RulesCategory.class, "name", key); - } - public List getRuleParams() { return getSession().getResults(RuleParam.class); @@ -96,13 +75,6 @@ public class RulesDao extends BaseDao { } } - public void deleteActiveRuleParameters(RuleParam ruleParam) { - getSession().createQuery( - "DELETE FROM ActiveRuleParam arp WHERE ruleParam=:param") - .setParameter("param", ruleParam) - .executeUpdate(); - } - public List getViolations(Snapshot snapshot) { return getSession().getResults(RuleFailureModel.class, "snapshotId", snapshot.getId()); } diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java index 5d9eb70c3bc..0be085d8be8 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java +++ b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java @@ -30,7 +30,7 @@ import java.sql.Statement; public class SchemaMigration { public final static int VERSION_UNKNOWN = -1; - public static final int LAST_VERSION = 161; + public static final int LAST_VERSION = 162; public final static String TABLE_NAME = "schema_migrations"; diff --git a/sonar-core/src/main/resources/ehcache.xml b/sonar-core/src/main/resources/ehcache.xml index 99e2597c98e..9385f272c34 100644 --- a/sonar-core/src/main/resources/ehcache.xml +++ b/sonar-core/src/main/resources/ehcache.xml @@ -70,7 +70,7 @@ overflowToDisk="false"/> \ No newline at end of file diff --git a/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java b/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java index 30dc9fc0602..4656c20bb1b 100644 --- a/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java @@ -51,7 +51,6 @@ public class RulesDaoTest extends AbstractDbUnitTestCase { assertEquals("rule_one", rules.get(0).getKey()); assertEquals(1, rules.get(0).getParams().size()); - assertEquals("category one", rules.get(0).getRulesCategory().getName()); } @Test @@ -66,17 +65,6 @@ public class RulesDaoTest extends AbstractDbUnitTestCase { assertThat(rule2, nullValue()); } - @Test - public void shouldCountNumberOfRulesOfACategoryForGivenPlugins() { - setupData("shouldCountNumberOfRulesOfACategoryForGivenPlugins"); - - Long result = rulesDao.countRules(Arrays.asList("plugin1", "plugin2"), "category one"); - assertThat(result, is(3L)); - - result = rulesDao.countRules(Arrays.asList("plugin1", "plugin2"), "category two"); - assertThat(result, is(1L)); - } - @Test public void shouldGetRuleParams() { setupData("shouldGetRuleParams"); @@ -116,7 +104,7 @@ public class RulesDaoTest extends AbstractDbUnitTestCase { public void shouldAddActiveRulesToProfile() { setupData("shouldAddActiveRulesToProfile"); - Rule rule = new Rule("rule1", "key1", "config1", new RulesCategory("test"), null); + Rule rule = new Rule("rule1", "key1", "config1", null, null); RuleParam ruleParam = new RuleParam(null, "param1", null, null); rule.setParams(Arrays.asList(ruleParam)); diff --git a/sonar-core/src/test/resources/org/sonar/core/components/CacheRuleFinderTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/components/CacheRuleFinderTest/shared.xml index f6adafee0da..de08ce13d22 100644 --- a/sonar-core/src/test/resources/org/sonar/core/components/CacheRuleFinderTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/components/CacheRuleFinderTest/shared.xml @@ -3,18 +3,18 @@ - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/components/DefaultRuleFinderTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/components/DefaultRuleFinderTest/shared.xml index f6adafee0da..de08ce13d22 100644 --- a/sonar-core/src/test/resources/org/sonar/core/components/DefaultRuleFinderTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/components/DefaultRuleFinderTest/shared.xml @@ -3,18 +3,18 @@ - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml index c7059375406..6818bf4c09e 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml @@ -4,7 +4,7 @@ - diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile.xml index f30fb8d64d9..19b124c737d 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile.xml @@ -4,7 +4,7 @@ - diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldCountNumberOfRulesOfACategoryForGivenPlugins.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldCountNumberOfRulesOfACategoryForGivenPlugins.xml index edb6c8d9271..86c8d928eee 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldCountNumberOfRulesOfACategoryForGivenPlugins.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldCountNumberOfRulesOfACategoryForGivenPlugins.xml @@ -3,15 +3,15 @@ - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter-result.xml index 71c8345bb80..5f86b049240 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter-result.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter-result.xml @@ -2,7 +2,7 @@ - diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter.xml index 90456d43522..f2d17bc78be 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter.xml @@ -2,7 +2,7 @@ - diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules-result.xml index 58dc223fc1f..736de8e2412 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules-result.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules-result.xml @@ -5,11 +5,11 @@ - - - diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules.xml index ffd0336d51f..89f2fecf7cf 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules.xml @@ -5,11 +5,11 @@ - - - diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetActiveRules.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetActiveRules.xml index 58dc223fc1f..736de8e2412 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetActiveRules.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetActiveRules.xml @@ -5,11 +5,11 @@ - - - diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleParams.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleParams.xml index 2eded82f21f..7df82f67476 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleParams.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleParams.xml @@ -3,9 +3,9 @@ - - diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleWithRuleKeyAndPluginKey.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleWithRuleKeyAndPluginKey.xml index 00de02226cf..42176327e03 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleWithRuleKeyAndPluginKey.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleWithRuleKeyAndPluginKey.xml @@ -2,7 +2,7 @@ - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRules.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRules.xml index 9190f5bcdab..303865ba8fb 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRules.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRules.xml @@ -2,9 +2,9 @@ - - - - -- cgit v1.2.3