aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-05-30 12:18:34 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-06-01 15:18:55 +0200
commitcfa1b2e92b7cf94e661653fb1dd233e744d02da3 (patch)
tree0e4aef0eb4781714a31b4c4599cde40853465c4e /server/sonar-db-dao
parent1fcc06ab16625cf86cf44985079134d914214d9c (diff)
downloadsonarqube-cfa1b2e92b7cf94e661653fb1dd233e744d02da3.tar.gz
sonarqube-cfa1b2e92b7cf94e661653fb1dd233e744d02da3.zip
SONAR-9346 delete links by project when deleting project
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java12
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java1
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java2
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml5
4 files changed, 10 insertions, 10 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java
index d57990db4bf..d3ed34b2cdc 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java
@@ -156,6 +156,13 @@ class PurgeCommands {
profiler.stop();
}
+ void deleteLinks(String rootUuid) {
+ profiler.start("deleteLinks (project_links)");
+ purgeMapper.deleteComponentLinks(rootUuid);
+ session.commit();
+ profiler.stop();
+ }
+
void deleteComponents(List<IdUuidPair> componentIdUuids) {
List<List<Long>> componentIdPartitions = Lists.partition(IdUuidPairs.ids(componentIdUuids), MAX_RESOURCES_PER_QUERY);
List<List<String>> componentUuidsPartitions = Lists.partition(IdUuidPairs.uuids(componentIdUuids), MAX_RESOURCES_PER_QUERY);
@@ -165,11 +172,6 @@ class PurgeCommands {
// possible missing optimization: filter requests according to resource scope
- profiler.start("deleteResourceLinks (project_links)");
- componentUuidsPartitions.forEach(purgeMapper::deleteComponentLinks);
- session.commit();
- profiler.stop();
-
profiler.start("deleteResourceProperties (properties)");
componentIdPartitions.forEach(purgeMapper::deleteComponentProperties);
session.commit();
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java
index 1e804170efd..c7ee2fc5e9e 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java
@@ -160,6 +160,7 @@ public class PurgeDao implements Dao {
.findFirst()
.orElseThrow(() -> new IllegalStateException("Couldn't find component for root uuid " + rootUuid));
commands.deletePermissions(rootId);
+ commands.deleteLinks(rootUuid);
commands.deleteAnalyses(rootUuid);
commands.deleteComponents(childrenIds);
commands.deleteIssues(rootUuid);
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java
index f860348e6e8..71f4d1afc67 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java
@@ -50,7 +50,7 @@ public interface PurgeMapper {
void resolveComponentIssuesNotAlreadyResolved(@Param("componentUuids") List<String> componentUuids, @Param("dateAsLong") Long dateAsLong);
- void deleteComponentLinks(@Param("componentUuids") List<String> componentUuids);
+ void deleteComponentLinks(@Param("rootUuid") String rootUuid);
void deleteComponentProperties(@Param("componentIds") List<Long> componentIds);
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
index 7a93f7136be..a2d461853e0 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
@@ -154,10 +154,7 @@
<delete id="deleteComponentLinks" parameterType="map">
delete from project_links
where
- component_uuid in
- <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=",">
- #{componentUuid,jdbcType=VARCHAR}
- </foreach>
+ component_uuid = #{rootUuid,jdbcType=VARCHAR}
</delete>
<delete id="deleteComponentProperties" parameterType="map">