aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/main/java
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2020-10-14 16:43:30 -0500
committersonartech <sonartech@sonarsource.com>2020-11-28 20:06:15 +0000
commit37587a03da2ea2289e2c2c6b0ca213e8274fe5c7 (patch)
tree3968c8afe017835b1f5853a1ba3b63882f056713 /server/sonar-db-dao/src/main/java
parente24f1b14536dc7268d03495f6ef281698ff09184 (diff)
downloadsonarqube-37587a03da2ea2289e2c2c6b0ca213e8274fe5c7.tar.gz
sonarqube-37587a03da2ea2289e2c2c6b0ca213e8274fe5c7.zip
SONAR-14033 Refactor storage of applications
Diffstat (limited to 'server/sonar-db-dao/src/main/java')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java7
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ApplicationProjectsDao.java108
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ApplicationProjectsMapper.java69
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java13
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java1
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/SelectionMode.java27
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDao.java5
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java12
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java1
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java17
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java8
15 files changed, 270 insertions, 8 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java
index 205d02d18e2..a76ef07ffc6 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java
@@ -35,6 +35,7 @@ import org.sonar.db.ce.CeTaskCharacteristicDao;
import org.sonar.db.ce.CeTaskInputDao;
import org.sonar.db.ce.CeTaskMessageDao;
import org.sonar.db.component.AnalysisPropertiesDao;
+import org.sonar.db.component.ApplicationProjectsDao;
import org.sonar.db.component.BranchDao;
import org.sonar.db.component.ComponentDao;
import org.sonar.db.component.ComponentKeyUpdaterDao;
@@ -101,6 +102,7 @@ public class DaoModule extends Module {
ActiveRuleDao.class,
AnalysisPropertiesDao.class,
AuthorizationDao.class,
+ ApplicationProjectsDao.class,
BranchDao.class,
CeActivityDao.class,
CeQueueDao.class,
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java
index 78d717373ed..bd6c3c878d6 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java
@@ -33,6 +33,7 @@ import org.sonar.db.ce.CeTaskCharacteristicDao;
import org.sonar.db.ce.CeTaskInputDao;
import org.sonar.db.ce.CeTaskMessageDao;
import org.sonar.db.component.AnalysisPropertiesDao;
+import org.sonar.db.component.ApplicationProjectsDao;
import org.sonar.db.component.BranchDao;
import org.sonar.db.component.ComponentDao;
import org.sonar.db.component.ComponentKeyUpdaterDao;
@@ -166,6 +167,7 @@ public class DbClient {
private final SessionTokensDao sessionTokensDao;
private final SamlMessageIdDao samlMessageIdDao;
private final UserDismissedMessagesDao userDismissedMessagesDao;
+ private final ApplicationProjectsDao applicationProjectsDao;
public DbClient(Database database, MyBatis myBatis, DBSessions dbSessions, Dao... daos) {
this.database = database;
@@ -245,6 +247,7 @@ public class DbClient {
sessionTokensDao = getDao(map, SessionTokensDao.class);
samlMessageIdDao = getDao(map, SamlMessageIdDao.class);
userDismissedMessagesDao = getDao(map, UserDismissedMessagesDao.class);
+ applicationProjectsDao = getDao(map, ApplicationProjectsDao.class);
}
public DbSession openSession(boolean batch) {
@@ -267,6 +270,10 @@ public class DbClient {
return almPatDao;
}
+ public ApplicationProjectsDao applicationProjectsDao() {
+ return applicationProjectsDao;
+ }
+
public ProjectAlmSettingDao projectAlmSettingDao() {
return projectAlmSettingDao;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
index 8c1f4a3b487..77205277bb5 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
@@ -47,6 +47,7 @@ import org.sonar.db.ce.CeTaskCharacteristicMapper;
import org.sonar.db.ce.CeTaskInputMapper;
import org.sonar.db.ce.CeTaskMessageMapper;
import org.sonar.db.component.AnalysisPropertiesMapper;
+import org.sonar.db.component.ApplicationProjectsMapper;
import org.sonar.db.component.BranchMapper;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentDtoWithSnapshotId;
@@ -231,6 +232,7 @@ public class MyBatis implements Startable {
AlmPatMapper.class,
AlmSettingMapper.class,
AnalysisPropertiesMapper.class,
+ ApplicationProjectsMapper.class,
AuthorizationMapper.class,
BranchMapper.class,
CeActivityMapper.class,
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ApplicationProjectsDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ApplicationProjectsDao.java
new file mode 100644
index 00000000000..713d67dd5dd
--- /dev/null
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ApplicationProjectsDao.java
@@ -0,0 +1,108 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.component;
+
+import java.util.Collection;
+import java.util.Set;
+import org.sonar.api.utils.System2;
+import org.sonar.core.util.UuidFactory;
+import org.sonar.db.Dao;
+import org.sonar.db.DbSession;
+import org.sonar.db.project.ProjectDto;
+
+public class ApplicationProjectsDao implements Dao {
+ private final System2 system2;
+ private final UuidFactory uuidFactory;
+
+ public ApplicationProjectsDao(System2 system2, UuidFactory uuidFactory) {
+ this.system2 = system2;
+ this.uuidFactory = uuidFactory;
+ }
+
+ public void addProject(DbSession dbSession, String applicationUuid, String projectUuid) {
+ getMapper(dbSession).addProject(uuidFactory.create(), applicationUuid, projectUuid, system2.now());
+ }
+
+ public void removeApplicationProjectsByApplicationAndProject(DbSession dbSession, String applicationUuid, String projectUuid) {
+ getMapper(dbSession).removeApplicationBranchProjectBranchesByApplicationAndProject(applicationUuid, projectUuid);
+ getMapper(dbSession).removeApplicationProjectsByApplicationAndProject(applicationUuid, projectUuid);
+ }
+
+ public int countApplicationProjects(DbSession dbSession, String applicationUuid) {
+ return getMapper(dbSession).countApplicationProjects(applicationUuid);
+ }
+
+ public Set<ProjectDto> selectProjects(DbSession dbSession, String applicationUuid) {
+ return getMapper(dbSession).selectProjects(applicationUuid);
+ }
+
+ public void remove(DbSession dbSession, String applicationUuid) {
+ getMapper(dbSession).removeApplicationBranchProjectBranchesByApplication(applicationUuid);
+ getMapper(dbSession).removeApplicationProjectsByApplication(applicationUuid);
+ }
+
+ public void addProjectBranchToAppBranch(DbSession dbSession, BranchDto applicationBranch, BranchDto projectBranch) {
+ getMapper(dbSession).addProjectBranchToAppBranch(
+ uuidFactory.create(),
+ applicationBranch.getProjectUuid(),
+ applicationBranch.getUuid(),
+ projectBranch.getProjectUuid(),
+ projectBranch.getUuid(),
+ system2.now());
+ }
+
+ public void addProjectBranchToAppBranch(DbSession dbSession, String applicationUuid, String applicationBranchUuid, String projectUuid, String projectBranchUuid) {
+ getMapper(dbSession).addProjectBranchToAppBranch(
+ uuidFactory.create(),
+ applicationUuid,
+ applicationBranchUuid,
+ projectUuid,
+ projectBranchUuid,
+ system2.now());
+ }
+
+ public void removeProjectBranchFromAppBranch(DbSession dbSession, String applicationBranchUuid, String projectBranchUuid) {
+ getMapper(dbSession).removeProjectBranchFromAppBranch(applicationBranchUuid, projectBranchUuid);
+ }
+
+ public Set<BranchDto> selectProjectBranchesFromAppBranch(DbSession dbSession, String applicationBranchUuid) {
+ return getMapper(dbSession).selectProjectBranchesFromAppBranch(applicationBranchUuid);
+ }
+
+ public Set<ProjectDto> selectApplicationsFromProjectBranch(DbSession dbSession, String projectUuid, String branchKey) {
+ return getMapper(dbSession).selectApplicationsFromProjectBranch(projectUuid, branchKey);
+ }
+
+ public Set<ProjectDto> selectApplicationsFromProjects(DbSession dbSession, Collection<String> projectUuids) {
+ return getMapper(dbSession).selectApplicationsFromProjects(projectUuids);
+ }
+
+ private static ApplicationProjectsMapper getMapper(DbSession session) {
+ return session.getMapper(ApplicationProjectsMapper.class);
+ }
+
+ public void updateApplicationBranchName(DbSession dbSession, String applicationBranchUuid, String newName) {
+ getMapper(dbSession).updateApplicationBranchName(applicationBranchUuid, newName);
+ }
+
+ public void removeAllProjectBranchesOfAppBranch(DbSession dbSession, String applicationBranchUuid) {
+ getMapper(dbSession).removeAllProjectBranchesOfAppBranch(applicationBranchUuid);
+ }
+}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ApplicationProjectsMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ApplicationProjectsMapper.java
new file mode 100644
index 00000000000..a45cb6529bc
--- /dev/null
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ApplicationProjectsMapper.java
@@ -0,0 +1,69 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.component;
+
+import java.util.Collection;
+import java.util.Set;
+import org.apache.ibatis.annotations.Param;
+import org.sonar.db.project.ProjectDto;
+
+public interface ApplicationProjectsMapper {
+ void addProject(
+ @Param("uuid") String uuid,
+ @Param("applicationUuid") String applicationUuid,
+ @Param("projectUuid") String projectUuid,
+ @Param("now") long now);
+
+ void removeApplicationBranchProjectBranchesByApplicationAndProject(
+ @Param("applicationUuid") String applicationUuid,
+ @Param("projectUuid") String projectUuid);
+
+ void removeApplicationProjectsByApplicationAndProject(
+ @Param("applicationUuid") String applicationUuid,
+ @Param("projectUuid") String projectUuid);
+
+ Set<ProjectDto> selectProjects(@Param("applicationUuid") String applicationUuid);
+
+ void removeApplicationProjectsByApplication(String applicationUuid);
+
+ void removeApplicationBranchProjectBranchesByApplication(String applicationUuid);
+
+ void addProjectBranchToAppBranch(
+ @Param("uuid") String uuid,
+ @Param("applicationUuid") String applicationUuid,
+ @Param("applicationBranchUuid") String applicationBranchUuid,
+ @Param("projectUuid") String projectUuid,
+ @Param("projectBranchUuid") String projectBranchUuid,
+ @Param("now") long now);
+
+ void removeProjectBranchFromAppBranch(@Param("applicationBranchUuid") String applicationBranchUuid, @Param("projectBranchUuid") String projectBranchUuid);
+
+ Set<BranchDto> selectProjectBranchesFromAppBranch(@Param("applicationBranchUuid") String applicationBranchUuid);
+
+ int countApplicationProjects(@Param("applicationUuid") String applicationUuid);
+
+ void updateApplicationBranchName(@Param("uuid") String uuid, @Param("newName") String newName);
+
+ Set<ProjectDto> selectApplicationsFromProjectBranch(@Param("projectUuid") String projectUuid, @Param("branchKey") String branchKey);
+
+ Set<ProjectDto> selectApplicationsFromProjects(@Param("projectUuids") Collection<String> projectUuids);
+
+ void removeAllProjectBranchesOfAppBranch(@Param("applicationBranchUuid") String applicationBranchUuid);
+}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java
index eea97147e49..3abeac13c01 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java
@@ -20,7 +20,6 @@
package org.sonar.db.component;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -30,6 +29,7 @@ import org.sonar.db.Dao;
import org.sonar.db.DbSession;
import org.sonar.db.project.ProjectDto;
+import static java.util.Collections.emptyList;
import static org.sonar.db.DatabaseUtils.executeLargeInputs;
public class BranchDao implements Dao {
@@ -68,7 +68,7 @@ public class BranchDao implements Dao {
public List<BranchDto> selectByBranchKeys(DbSession dbSession, Map<String, String> branchKeyByProjectUuid) {
if (branchKeyByProjectUuid.isEmpty()) {
- return Collections.emptyList();
+ return emptyList();
}
return mapper(dbSession).selectByBranchKeys(branchKeyByProjectUuid);
}
@@ -94,6 +94,9 @@ public class BranchDao implements Dao {
}
public List<BranchDto> selectByUuids(DbSession session, Collection<String> uuids) {
+ if (uuids.isEmpty()) {
+ return emptyList();
+ }
return executeLargeInputs(uuids, mapper(session)::selectByUuids);
}
@@ -103,7 +106,7 @@ public class BranchDao implements Dao {
public List<String> selectProjectUuidsWithIssuesNeedSync(DbSession session, Collection<String> uuids) {
if (uuids.isEmpty()) {
- return Collections.emptyList();
+ return emptyList();
}
return executeLargeInputs(uuids, mapper(session)::selectProjectUuidsWithIssuesNeedSync);
@@ -146,6 +149,10 @@ public class BranchDao implements Dao {
return mapper(dbSession).updateNeedIssueSync(branchUuid, needIssueSync, now);
}
+ public void deleteBranch(DbSession dbSession, String projectUuid, String branchKey) {
+ mapper(dbSession).deleteBranch(projectUuid, branchKey);
+ }
+
public boolean doAnyOfComponentsNeedIssueSync(DbSession session, List<String> components) {
if (!components.isEmpty()) {
List<Boolean> result = new LinkedList<>();
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java
index c44507015fd..db9667426f7 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java
@@ -68,4 +68,5 @@ public interface BranchMapper {
short doAnyOfComponentsNeedIssueSync(@Param("componentKeys") List<String> components);
+ void deleteBranch(@Param("projectUuid") String projectUuid, @Param("branchKey") String branchKey);
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SelectionMode.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SelectionMode.java
new file mode 100644
index 00000000000..6a636de8542
--- /dev/null
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SelectionMode.java
@@ -0,0 +1,27 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.component;
+
+public enum SelectionMode {
+ MANUAL_MEASURE,
+ REGEXP,
+ TAGS,
+ REMAINING_PROJECTS
+}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDao.java
index f70760d6541..0f62ef98e7d 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDao.java
@@ -34,7 +34,6 @@ import org.sonar.db.Dao;
import org.sonar.db.DbSession;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.FluentIterable.from;
import static java.util.Objects.requireNonNull;
import static org.sonar.db.DatabaseUtils.executeLargeInputs;
@@ -125,9 +124,7 @@ public class SnapshotDao implements Dao {
*/
@CheckForNull
public ViewsSnapshotDto selectSnapshotBefore(String componentUuid, long date, DbSession dbSession) {
- return from(mapper(dbSession).selectSnapshotBefore(componentUuid, date))
- .first()
- .orNull();
+ return mapper(dbSession).selectSnapshotBefore(componentUuid, date).stream().findFirst().orElse(null);
}
private static SnapshotMapper mapper(DbSession session) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java
index 46dd8218e9a..8d2509cf449 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java
@@ -50,6 +50,10 @@ public class ProjectDao implements Dao {
return Optional.ofNullable(mapper(session).selectProjectOrAppByKey(key));
}
+ public List<ProjectDto> selectAllApplications(DbSession session){
+ return mapper(session).selectAllApplications();
+ }
+
public List<ProjectDto> selectProjectsByKeys(DbSession session, Set<String> keys) {
if (keys.isEmpty()) {
return Collections.emptyList();
@@ -57,6 +61,13 @@ public class ProjectDao implements Dao {
return mapper(session).selectProjectsByKeys(keys);
}
+ public List<ProjectDto> selectApplicationsByKeys(DbSession session, Set<String> keys) {
+ if (keys.isEmpty()) {
+ return Collections.emptyList();
+ }
+ return mapper(session).selectApplicationsByKeys(keys);
+ }
+
public List<ProjectDto> selectProjects(DbSession session) {
return mapper(session).selectProjects();
}
@@ -99,4 +110,5 @@ public class ProjectDao implements Dao {
private static ProjectMapper mapper(DbSession session) {
return session.getMapper(ProjectMapper.class);
}
+
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java
index e01902c2eb5..656fe8e67ae 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java
@@ -181,4 +181,5 @@ public class ProjectDto {
public int hashCode() {
return uuid != null ? uuid.hashCode() : 0;
}
+
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java
index 01ff1c11e97..c2fafe6a8f3 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java
@@ -57,4 +57,8 @@ public interface ProjectMapper {
List<ProjectDto> selectProjectsByOrganizationUuid(String organizationUuid);
void updateVisibility(@Param("uuid") String uuid, @Param("isPrivate") boolean isPrivate, @Param("updatedAt") long updatedAt);
+
+ List<ProjectDto> selectAllApplications();
+
+ List<ProjectDto> selectApplicationsByKeys(@Param("kees") Collection<String> kees);
}
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 b11c7febd7f..6ab82d82e1b 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
@@ -49,7 +49,6 @@ class PurgeCommands {
this.system2 = system2;
}
- @VisibleForTesting
PurgeCommands(DbSession session, PurgeProfiler profiler, System2 system2) {
this(session, session.getMapper(PurgeMapper.class), profiler, system2);
}
@@ -406,6 +405,21 @@ class PurgeCommands {
profiler.stop();
}
+ void deleteApplicationProjects(String applicationUuid) {
+ profiler.start("deleteApplicationProjects (app_projects)");
+ purgeMapper.deleteApplicationBranchProjectBranchesByApplicationUuid(applicationUuid);
+ purgeMapper.deleteApplicationProjectsByApplicationUuid(applicationUuid);
+ session.commit();
+ profiler.stop();
+ }
+
+ void deleteApplicationBranchProjects(String applicationBranchUuid) {
+ profiler.start("deleteApplicationBranchProjects (app_branch_project_branch)");
+ purgeMapper.deleteApplicationBranchProjects(applicationBranchUuid);
+ session.commit();
+ profiler.stop();
+ }
+
public void deleteProjectAlmSettings(String rootUuid) {
profiler.start("deleteProjectAlmSettings (project_alm_settings)");
purgeMapper.deleteProjectAlmSettingsByProjectUuid(rootUuid);
@@ -415,6 +429,7 @@ class PurgeCommands {
void deleteBranch(String rootUuid) {
profiler.start("deleteBranch (project_branches)");
+ purgeMapper.deleteApplicationBranchProjectBranchesByProjectBranchUuid(rootUuid);
purgeMapper.deleteBranchByUuid(rootUuid);
session.commit();
profiler.stop();
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 bb39d91a389..3498ad1f49d 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
@@ -221,6 +221,8 @@ public class PurgeDao implements Dao {
commands.deletePermissions(rootUuid);
commands.deleteNewCodePeriods(rootUuid);
commands.deleteBranch(rootUuid);
+ commands.deleteApplicationBranchProjects(rootUuid);
+ commands.deleteApplicationProjects(rootUuid);
commands.deleteComponents(rootUuid);
commands.deleteComponentsByMainBranchProjectUuid(rootUuid);
commands.deleteProject(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 840533516f9..57ca6f26a3e 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
@@ -141,6 +141,14 @@ public interface PurgeMapper {
void deleteProjectMappingsByProjectUuid(@Param("projectUuid") String projectUuid);
+ void deleteApplicationProjectsByApplicationUuid(@Param("applicationUuid") String applicationUuid);
+
+ void deleteApplicationBranchProjectBranchesByApplicationUuid(@Param("applicationUuid") String applicationUuid);
+
+ void deleteApplicationBranchProjects(@Param("branchUuid") String applicationBranchUuid);
+
+ void deleteApplicationBranchProjectBranchesByProjectBranchUuid(@Param("projectBranchUuid") String projectBranchUuid);
+
void deleteBranchByUuid(@Param("uuid") String uuid);
void deleteLiveMeasuresByProjectUuid(@Param("projectUuid") String projectUuid);