aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorJenkins CI <ci@sonarsource.com>2016-04-12 08:07:40 +0200
committerJenkins CI <ci@sonarsource.com>2016-04-12 08:07:40 +0200
commit54bed58ca48aba47636f8bc025d301e3a8523e6f (patch)
treeb2d351e98482ce754c0c30e27a7ff2065ffc52bf /sonar-db
parentbe0fa093db7176f18bf137af7246e4ec5167f0ab (diff)
parenta6f552abcf9db3361c2ad903606b3365182da76a (diff)
downloadsonarqube-54bed58ca48aba47636f8bc025d301e3a8523e6f.tar.gz
sonarqube-54bed58ca48aba47636f8bc025d301e3a8523e6f.zip
Automatic merge from branch-5.5
* origin/branch-5.5: QA: enable deploy on branch-* add l10n names for reliability_rating and security_rating Add PropertiesDao.deleteById SONAR-7533 Hide sonar.login property in analysis.log sent in the scanner report SONAR-7238 do not display identity provider details when it is "sonarqube" fix bug which prevents to add a quality gate condition for "new_" metric SONAR-7402 clicking on project bubble brings to the project page Fix javadoc errors Exclude protobuf code from SQ analysis Fix some Javadoc warnings Improve javadoc Change return type of Plugin#getSonarQubeVersion()
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java4
-rw-r--r--sonar-db/src/main/java/org/sonar/db/property/PropertiesMapper.java2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/property/PropertiesMapper.xml4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java10
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete-result.xml14
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete.xml14
6 files changed, 48 insertions, 0 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java b/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java
index 111bf7ba8b0..b7325cee8a3 100644
--- a/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java
@@ -182,6 +182,10 @@ public class PropertiesDao implements Dao {
}
}
+ public void deleteById(DbSession dbSession, long id) {
+ dbSession.getMapper(PropertiesMapper.class).deleteById(id);
+ }
+
public void deleteProjectProperty(String key, Long projectId) {
DbSession session = mybatis.openSession(false);
try {
diff --git a/sonar-db/src/main/java/org/sonar/db/property/PropertiesMapper.java b/sonar-db/src/main/java/org/sonar/db/property/PropertiesMapper.java
index e4d09bd4732..a90fed439af 100644
--- a/sonar-db/src/main/java/org/sonar/db/property/PropertiesMapper.java
+++ b/sonar-db/src/main/java/org/sonar/db/property/PropertiesMapper.java
@@ -48,6 +48,8 @@ public interface PropertiesMapper {
void insert(PropertyDto property);
+ void deleteById(long id);
+
void deleteProjectProperty(@Param("key") String key, @Param("rId") Long resourceId);
void deleteProjectProperties(@Param("key") String key, @Param("value") String value);
diff --git a/sonar-db/src/main/resources/org/sonar/db/property/PropertiesMapper.xml b/sonar-db/src/main/resources/org/sonar/db/property/PropertiesMapper.xml
index d36c205772c..afb6f9d5c1d 100644
--- a/sonar-db/src/main/resources/org/sonar/db/property/PropertiesMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/property/PropertiesMapper.xml
@@ -106,6 +106,10 @@
VALUES (#{key}, #{resourceId}, #{userId}, #{value})
</insert>
+ <delete id="deleteById" parameterType="long">
+ delete from properties where id=#{id}
+ </delete>
+
<delete id="deleteProjectProperty" parameterType="map">
delete from properties where prop_key=#{key} and resource_id=#{rId} and user_id is null
</delete>
diff --git a/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java b/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
index 0071be12609..a31013ac096 100644
--- a/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
@@ -217,6 +217,16 @@ public class PropertiesDaoTest {
}
@Test
+ public void delete_property_by_id() {
+ dbTester.prepareDbUnit(getClass(), "delete.xml");
+
+ dao.deleteById(dbTester.getSession(), 1L);
+ dbTester.getSession().commit();
+
+ dbTester.assertDbUnit(getClass(), "delete-result.xml", "properties");
+ }
+
+ @Test
public void delete_project_property() {
dbTester.prepareDbUnit(getClass(), "delete_project_property.xml");
diff --git a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete-result.xml b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete-result.xml
new file mode 100644
index 00000000000..ef4ec2a18b2
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete-result.xml
@@ -0,0 +1,14 @@
+<dataset>
+
+ <!-- global -->
+ <!--<properties id="1" prop_key="global.key" text_value="global" resource_id="[null]" user_id="[null]"/>-->
+
+ <!-- project -->
+ <properties id="2" prop_key="project.key" text_value="project" resource_id="10" user_id="[null]"/>
+
+ <!-- user -->
+ <properties id="3" prop_key="user.key" text_value="user" resource_id="[null]" user_id="100"/>
+
+ <!-- null value -->
+ <properties id="4" prop_key="null.value" text_value="not null" resource_id="[null]" user_id="[null]"/>
+</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete.xml b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete.xml
new file mode 100644
index 00000000000..5229a2b791a
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete.xml
@@ -0,0 +1,14 @@
+<dataset>
+
+ <!-- global -->
+ <properties id="1" prop_key="global.key" text_value="global" resource_id="[null]" user_id="[null]"/>
+
+ <!-- project -->
+ <properties id="2" prop_key="project.key" text_value="project" resource_id="10" user_id="[null]"/>
+
+ <!-- user -->
+ <properties id="3" prop_key="user.key" text_value="user" resource_id="[null]" user_id="100"/>
+
+ <!-- null value -->
+ <properties id="4" prop_key="null.value" text_value="not null" resource_id="[null]" user_id="[null]"/>
+</dataset>