diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-01 22:08:15 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-01 22:08:15 +0100 |
commit | af8cbb165e10a9bcd5ccef57ec7813645bfaf5d4 (patch) | |
tree | 838a3e4b76f4a9359968e3b0906c17de02d88e5e /sonar-core | |
parent | 86d1d2abb3ffbd31a2dde9d32f58643a06934680 (diff) | |
download | sonarqube-af8cbb165e10a9bcd5ccef57ec7813645bfaf5d4.tar.gz sonarqube-af8cbb165e10a9bcd5ccef57ec7813645bfaf5d4.zip |
SONAR-2094 Add the column RULES_PROFILES.ENABLED
Diffstat (limited to 'sonar-core')
11 files changed, 21 insertions, 53 deletions
diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/ProfilesDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/ProfilesDao.java index 65944ab720b..ba1eb21cf80 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/ProfilesDao.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dao/ProfilesDao.java @@ -23,44 +23,22 @@ import org.sonar.api.database.DatabaseSession; import org.sonar.api.database.model.ResourceModel; import org.sonar.api.profiles.RulesProfile; -import java.util.List; - public class ProfilesDao extends BaseDao { public ProfilesDao(DatabaseSession session) { super(session); } - public List<RulesProfile> getActiveProfiles() { - return getSession().getResults(RulesProfile.class, "defaultProfile", true); - } - public RulesProfile getActiveProfile(String languageKey, String projectResourceKey) { ResourceModel projectResource = getSession().getSingleResult(ResourceModel.class, "key", projectResourceKey, "scope", ResourceModel.SCOPE_PROJECT); - if (projectResource != null && projectResource.getRulesProfile() != null) { + if (projectResource != null && projectResource.getRulesProfile() != null && projectResource.getRulesProfile().isEnabled()) { return projectResource.getRulesProfile(); } - return getSession().getSingleResult(RulesProfile.class, "defaultProfile", true, "language", languageKey); - } - - public List<RulesProfile> getProfiles(String languageKey) { - return getSession().getResults(RulesProfile.class, "language", languageKey); - } - - public List<RulesProfile> getProfiles() { - return getSession().getResults(RulesProfile.class); - } - - public List<RulesProfile> getProvidedProfiles() { - return getSession().getResults(RulesProfile.class, "provided", true); + return getSession().getSingleResult(RulesProfile.class, "defaultProfile", true, "language", languageKey, "enabled", true); } public RulesProfile getProfile(String languageKey, String profileName) { - return getSession().getSingleResult(RulesProfile.class, "language", languageKey, "name", profileName); - } - - public RulesProfile getProfileById(int profileId) { - return getSession().getEntityManager().getReference(RulesProfile.class, profileId); + return getSession().getSingleResult(RulesProfile.class, "language", languageKey, "name", profileName, "enabled", true); } } 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 a80961ba4ce..921cbcab6d3 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 @@ -31,7 +31,7 @@ import javax.persistence.*; public class SchemaMigration { public final static int VERSION_UNKNOWN = -1; - public static final int LAST_VERSION = 170; + public static final int LAST_VERSION = 180; public final static String TABLE_NAME = "schema_migrations"; diff --git a/sonar-core/src/test/java/org/sonar/jpa/dao/ProfilesDaoTest.java b/sonar-core/src/test/java/org/sonar/jpa/dao/ProfilesDaoTest.java index 796435c5dab..0b821d51dc2 100644 --- a/sonar-core/src/test/java/org/sonar/jpa/dao/ProfilesDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/jpa/dao/ProfilesDaoTest.java @@ -25,10 +25,8 @@ import org.sonar.api.database.model.ResourceModel; import org.sonar.api.profiles.RulesProfile;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
public class ProfilesDaoTest extends AbstractDbUnitTestCase {
@@ -39,14 +37,6 @@ public class ProfilesDaoTest extends AbstractDbUnitTestCase { profilesDao = new ProfilesDao(getSession());
}
- @Test
- public void shouldGetProfiles() {
- setupData("shouldGetProfiles");
-
- List<RulesProfile> profiles = profilesDao.getProfiles("java");
-
- assertThat(profiles.size(), is(2));
- }
@Test
public void testGetActiveProfile() {
diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/ProfilesDaoTest/shouldGetProfiles.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/ProfilesDaoTest/shouldGetProfiles.xml index f1e87d6dcb5..3325d8baf74 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/ProfilesDaoTest/shouldGetProfiles.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/ProfilesDaoTest/shouldGetProfiles.xml @@ -1,7 +1,7 @@ <dataset>
- <rules_profiles id="1" provided="true" name="profile one" default_profile="0" language="java"/>
- <rules_profiles id="2" provided="true" name="profile two" default_profile="0" language="java"/>
- <rules_profiles id="3" provided="true" name="profile three" default_profile="0" language="plsql"/>
+ <rules_profiles id="1" provided="true" name="profile one" default_profile="0" language="java" enabled="true"/>
+ <rules_profiles id="2" provided="true" name="profile two" default_profile="0" language="java" enabled="true"/>
+ <rules_profiles id="3" provided="true" name="profile three" default_profile="0" language="plsql" enabled="true"/>
</dataset>
\ 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 cd31402ceb1..cecf13ba8e1 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 @@ -1,6 +1,6 @@ <dataset> - <rules_profiles id="1" parent_name="[null]" provided="true" name="profile" default_profile="1" language="java"/> + <rules_profiles id="1" parent_name="[null]" provided="true" name="profile" default_profile="1" language="java" enabled="true"/> <rules_categories id="1" name="category one" description="[null]"/> 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 19b124c737d..0851c7441a0 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 @@ -1,6 +1,6 @@ <dataset> - <rules_profiles id="1" provided="true" name="profile" default_profile="1" language="java"/> + <rules_profiles id="1" provided="true" name="profile" default_profile="1" language="java" enabled="true"/> <rules_categories id="1" name="category one" description="[null]"/> 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 5f86b049240..be6be226a56 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 @@ -8,8 +8,8 @@ <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="r"/> <rules_parameters id="2" rule_id="1" name="param2" description="[null]" param_type="r"/> - <rules_profiles id="1" provided="true" name="profile1" default_profile="1" language="java"/> - <rules_profiles id="2" provided="true" name="profile2" default_profile="1" language="OTHER"/> + <rules_profiles id="1" provided="true" name="profile1" default_profile="1" language="java" enabled="true"/> + <rules_profiles id="2" provided="true" name="profile2" default_profile="1" language="OTHER" enabled="true"/> <active_rules id="1" profile_id="1" rule_id="1" failure_level="2"/> <active_rules id="2" profile_id="2" rule_id="1" failure_level="2"/> 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 f2d17bc78be..f19937676d1 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 @@ -8,8 +8,8 @@ <rules_parameters id="1" rule_id="1" name="param1" description="foo" param_type="r"/> <rules_parameters id="2" rule_id="1" name="param2" description="foo" param_type="r"/> - <rules_profiles id="1" provided="true" name="profile1" default_profile="1" language="java"/> - <rules_profiles id="2" provided="true" name="profile2" default_profile="1" language="OTHER"/> + <rules_profiles id="1" provided="true" name="profile1" default_profile="1" language="java" enabled="true"/> + <rules_profiles id="2" provided="true" name="profile2" default_profile="1" language="OTHER" enabled="true"/> <active_rules id="1" profile_id="1" rule_id="1" failure_level="2"/> <active_rules id="2" profile_id="2" rule_id="1" failure_level="2"/> 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 736de8e2412..94757dbf118 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 @@ -2,8 +2,8 @@ <rules_categories id="1" name="category one" description="[null]"/>
- <rules_profiles id="1" provided="true" name="profile one" default_profile="1" language="java"/>
- <rules_profiles id="2" provided="true" name="profile two" default_profile="0" language="java"/>
+ <rules_profiles id="1" provided="true" name="profile one" default_profile="1" language="java" enabled="true"/>
+ <rules_profiles id="2" provided="true" name="profile two" default_profile="0" language="java" enabled="true"/>
<rules id="1" name="foo" description="test" plugin_config_key="checker/foo"
plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
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 89f2fecf7cf..de59da7e6e7 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 @@ -2,8 +2,8 @@ <rules_categories id="1" name="category one" description="[null]"/>
- <rules_profiles id="1" provided="true" name="profile one" default_profile="1" language="java"/>
- <rules_profiles id="2" provided="true" name="profile two" default_profile="0" language="java"/>
+ <rules_profiles id="1" provided="true" name="profile one" default_profile="1" language="java" enabled="true"/>
+ <rules_profiles id="2" provided="true" name="profile two" default_profile="0" language="java" enabled="true"/>
<rules id="1" name="foo" description="test" plugin_config_key="checker/foo"
plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
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 736de8e2412..94757dbf118 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 @@ -2,8 +2,8 @@ <rules_categories id="1" name="category one" description="[null]"/>
- <rules_profiles id="1" provided="true" name="profile one" default_profile="1" language="java"/>
- <rules_profiles id="2" provided="true" name="profile two" default_profile="0" language="java"/>
+ <rules_profiles id="1" provided="true" name="profile one" default_profile="1" language="java" enabled="true"/>
+ <rules_profiles id="2" provided="true" name="profile two" default_profile="0" language="java" enabled="true"/>
<rules id="1" name="foo" description="test" plugin_config_key="checker/foo"
plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
|