summaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-23 14:45:43 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-23 14:45:43 +0100
commite71efcfbf8ccd836133fd623d04373347a0f384d (patch)
tree47e9b94b14e5f8303fae4b17a4a149fea2b18631 /sonar-core
parent676932e588e925e22da9f5b83313607258f392df (diff)
downloadsonarqube-e71efcfbf8ccd836133fd623d04373347a0f384d.tar.gz
sonarqube-e71efcfbf8ccd836133fd623d04373347a0f384d.zip
SONAR-4535 Correctly display active rule and active rule params when profile is inhereted
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java9
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java3
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml6
-rw-r--r--sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java8
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/parent.xml9
5 files changed, 35 insertions, 0 deletions
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 bcfcaeba288..f8a313b7aed 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
@@ -72,6 +72,15 @@ public class QualityProfileDao implements ServerComponent {
}
}
+ public QualityProfileDto selectParent(Integer childId) {
+ SqlSession session = mybatis.openSession();
+ try {
+ return session.getMapper(QualityProfileMapper.class).selectParent(childId);
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
public QualityProfileDto selectByNameAndLanguage(String name, String language) {
SqlSession session = mybatis.openSession();
try {
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 bcedfddc03d..f101e1036be 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
@@ -40,6 +40,9 @@ public interface QualityProfileMapper {
@CheckForNull
QualityProfileDto selectById(@Param("id") Integer id);
+ @CheckForNull
+ QualityProfileDto selectParent(@Param("childId") Integer childId);
+
List<ComponentDto> selectProjects(@Param("value") String propertyValue, @Param("key") String propertyKey);
List<QualityProfileDto> selectByProject(@Param("projectId") Long projectId, @Param("key") String propertyKeyPrefix);
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 b4b78d81fa1..a08c9aa888b 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
@@ -34,6 +34,12 @@
</where>
</select>
+ <select id="selectParent" parameterType="Integer" resultType="QualityProfile">
+ SELECT <include refid="profilesColumns"/>
+ FROM rules_profiles p
+ INNER JOIN rules_profiles child ON child.parent_name=p.name and child.language=p.language and child.id=#{childId}
+ </select>
+
<select id="selectDefaultProfile" parameterType="Integer" resultType="QualityProfile">
SELECT <include refid="profilesColumns"/>
FROM rules_profiles p
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 f64d63be7c0..28e09e5d59b 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
@@ -102,6 +102,14 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase {
}
@Test
+ public void select_parent() {
+ setupData("parent");
+
+ QualityProfileDto dto = dao.selectParent(1);
+ assertThat(dto.getId()).isEqualTo(2);
+ }
+
+ @Test
public void select_projects() {
setupData("projects");
diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/parent.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/parent.xml
new file mode 100644
index 00000000000..2c978506b6d
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/parent.xml
@@ -0,0 +1,9 @@
+<dataset>
+
+ <rules_profiles id="1" name="Child" language="java" parent_name="Parent" version="1"
+ used_profile="[false]"/>
+
+ <rules_profiles id="2" name="Parent" language="java" parent_name="[null]" version="1"
+ used_profile="[false]"/>
+
+</dataset>