diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-01-27 00:35:35 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-01-27 07:57:21 +0100 |
commit | 04bc6b52d79e9d357078b28a083e63d267f33d8b (patch) | |
tree | 62dd77c9a40e83229f18dce8cd459d72e0820ccf /sonar-core | |
parent | d9115e8f8bc07048bc0cabb9c6b0ee7f0eb43877 (diff) | |
download | sonarqube-04bc6b52d79e9d357078b28a083e63d267f33d8b.tar.gz sonarqube-04bc6b52d79e9d357078b28a083e63d267f33d8b.zip |
SONAR-926 feed ModuleRules
Diffstat (limited to 'sonar-core')
10 files changed, 61 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java index bdc607fef25..e41c91c708c 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java @@ -347,4 +347,13 @@ public class ActiveRuleDao implements ServerComponent { public List<ActiveRuleParamDto> selectAllParams(SqlSession session) { return session.getMapper(ActiveRuleMapper.class).selectAllParams(); } + + public List<ActiveRuleParamDto> selectParamsByProfileId(int profileId) { + SqlSession session = mybatis.openSession(); + try { + return session.getMapper(ActiveRuleMapper.class).selectParamsByProfileId(profileId); + } finally { + MyBatis.closeQuietly(session); + } + } } diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java index aae23290ee5..4c974f09e33 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java @@ -70,6 +70,8 @@ public interface ActiveRuleMapper { List<ActiveRuleParamDto> selectParamsByActiveRuleId(int activeRuleId); + List<ActiveRuleParamDto> selectParamsByProfileId(int profileId); + List<ActiveRuleParamDto> selectAllParams(); diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java index e736686264f..2f8ab8a38b5 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java @@ -211,4 +211,13 @@ public class QualityProfileDao implements ServerComponent { } } + public void updateUsedColumn(int profileId, boolean used) { + SqlSession session = mybatis.openSession(); + try { + session.getMapper(QualityProfileMapper.class).updatedUsedColumn(profileId, used); + session.commit(); + } finally { + MyBatis.closeQuietly(session); + } + } } diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java index 8338ab6c885..5ddf7e3b98f 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java @@ -65,4 +65,5 @@ public interface QualityProfileMapper { List<QualityProfileDto> selectByProject(@Param("projectId") Long projectId, @Param("key") String propertyKeyPrefix); + void updatedUsedColumn(@Param("id") int profileId, @Param("used") boolean used); } diff --git a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml index cf389856b45..a41353bf019 100644 --- a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml @@ -185,6 +185,14 @@ </where> </select> + <select id="selectParamsByProfileId" parameterType="int" resultType="ActiveRuleParam"> + select + <include refid="activeRuleParamColumns"/> + from active_rule_parameters p + inner join active_rules ar on ar.id=p.active_rule_id + where ar.profile_id=#{profileId} + </select> + <select id="selectAllParams" parameterType="map" resultType="ActiveRuleParam"> SELECT <include refid="activeRuleParamColumns"/> FROM active_rule_parameters p diff --git a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml index 9bf019e41d6..876fc40df5c 100644 --- a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml @@ -129,5 +129,11 @@ AND prop.text_value LIKE p.name </select> + <update id="updatedUsedColumn" parameterType="map"> + UPDATE rules_profiles SET + used_profile=#{used} + WHERE id=#{id} + </update> + </mapper> diff --git a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java index 9b3ba405b71..165dd319dee 100644 --- a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java @@ -271,6 +271,13 @@ public class ActiveRuleDaoTest extends AbstractDaoTestCase { } @Test + public void select_params_by_profile_id() { + setupData("shared"); + + assertThat(dao.selectParamsByProfileId(1)).hasSize(2); + } + + @Test public void select_all_params() { setupData("shared"); diff --git a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java index 863471257c9..f01091d9963 100644 --- a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java @@ -223,5 +223,12 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase { assertThat(dao.selectByProject(1L, "sonar.profile.%")).hasSize(2); } + @Test + public void update_used_column() { + setupData("update_used_column"); + + dao.updateUsedColumn(123, true); + checkTables("update_used_column", "rules_profiles"); + } } diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column-result.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column-result.xml new file mode 100644 index 00000000000..8d050e782ee --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column-result.xml @@ -0,0 +1,6 @@ +<dataset> + + <rules_profiles id="123" name="Sonar Way" language="java" parent_name="[null]" version="1" + used_profile="[true]"/> + +</dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column.xml new file mode 100644 index 00000000000..8b135112f5a --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column.xml @@ -0,0 +1,6 @@ +<dataset> + + <rules_profiles id="123" name="Sonar Way" language="java" parent_name="[null]" version="1" + used_profile="[false]"/> + +</dataset> |