From: Jacek Date: Fri, 20 Aug 2021 14:58:53 +0000 (+0200) Subject: SONAR-15259 Use portfolios realted tables in DefineAction WS X-Git-Tag: 9.1.0.47736~56 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a79ac0071eb12dc0ac595d7faa374c620891ff27;p=sonarqube.git SONAR-15259 Use portfolios realted tables in DefineAction WS --- diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDao.java index d9c49ae2178..d779c6845fa 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDao.java @@ -64,9 +64,6 @@ public class PortfolioDao implements Dao { } public void insert(DbSession dbSession, PortfolioDto portfolio) { - if (portfolio.getUuid() == null) { - portfolio.setUuid(uuidFactory.create()); - } mapper(dbSession).insert(portfolio); } @@ -160,4 +157,22 @@ public class PortfolioDao implements Dao { return executeLargeInputs(uuids, uuids1 -> mapper(dbSession).selectByUuids(uuids1)).stream() .collect(Collectors.toMap(PortfolioDto::getUuid, PortfolioDto::getKey)); } + + public void deleteAllDescendantPortfolios(DbSession dbSession, String rootUuid) { + mapper(dbSession).deleteAllDescendantPortfolios(rootUuid); + } + + public void deleteAllReferences(DbSession dbSession) { + mapper(dbSession).deleteAllReferences(); + + } + + public void deleteAllProjects(DbSession dbSession) { + mapper(dbSession).deleteAllProjects(); + } + + public List selectAllProjectsOfPortfolios(DbSession dbSession) { + return mapper(dbSession).selectAllProjectsOfPortfolios(); + } + } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioMapper.java index f019dbaed05..6587896849b 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioMapper.java @@ -76,4 +76,15 @@ public interface PortfolioMapper { void deleteProjects(String portfolioUuid); void deleteProject(@Param("portfolioUuid") String portfolioUuid, @Param("projectUuid") String projectUuid); + + void deleteAllDescendantPortfolios(String rootUuid); + + void deleteAllReferences(); + + void deleteAllProjects(); + + List selectAllProjectsOfPortfolios(); + + List selectAllReferencesOfPortfolios(); + } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml index 3e581205004..938e314e129 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml @@ -55,18 +55,18 @@ p.kee=#{kee,jdbcType=VARCHAR} - SELECT - + FROM portfolios p - where - p.parent_uuid is null - SELECT FROM portfolios p + where + p.parent_uuid is null + +