From a0d5da0279568f7c91b924ce8a3e67ee3acebef0 Mon Sep 17 00:00:00 2001 From: Zipeng WU Date: Wed, 8 Dec 2021 12:19:43 +0100 Subject: SONAR-15808 api/views/applications must provide new info --- .../java/org/sonar/db/portfolio/PortfolioDao.java | 5 +++++ .../org/sonar/db/portfolio/PortfolioMapper.java | 5 ++++- .../org/sonar/db/portfolio/PortfolioMapper.xml | 8 +++++++ .../org/sonar/db/portfolio/PortfolioDaoTest.java | 26 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) (limited to 'server/sonar-db-dao') 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 d69f36e8c1a..5a4739fd23d 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 @@ -31,6 +31,7 @@ import org.sonar.db.DbSession; import org.sonar.db.audit.AuditPersister; import org.sonar.db.audit.model.ComponentNewValue; import org.sonar.db.project.ApplicationProjectDto; +import org.sonar.db.project.ProjectDto; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; @@ -143,6 +144,10 @@ public class PortfolioDao implements Dao { return mapper(dbSession).selectAllReferencesToApplications(); } + public List selectAllDirectChildApplications(DbSession dbSession, String portfolioUuid) { + return mapper(dbSession).selectAllDirectChildApplications(portfolioUuid); + } + public Set selectReferenceUuids(DbSession dbSession, String portfolioUuid) { return mapper(dbSession).selectReferenceUuids(portfolioUuid); } 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 fe77eabae7a..57aa1060d8b 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 @@ -25,6 +25,7 @@ import java.util.Set; import javax.annotation.CheckForNull; import org.apache.ibatis.annotations.Param; import org.sonar.db.project.ApplicationProjectDto; +import org.sonar.db.project.ProjectDto; public interface PortfolioMapper { @CheckForNull @@ -98,5 +99,7 @@ public interface PortfolioMapper { void deleteBranch(@Param("portfolioUuid") String portfolioUuid, @Param("projectUuid") String projectUuid, @Param("branchUuid") String branchUuid); void insertBranch(@Param("uuid") String uuid, @Param("portfolioProjectUuid") String portfolioProjectUuid, @Param("branchUuid") String branchUuid, - @Param("createdAt") long createdAt); + @Param("createdAt") long createdAt); + + List selectAllDirectChildApplications(@Param("portfolioUuid") String portfolioUuid); } 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 e894c7afecd..16b8d7c9904 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 @@ -288,6 +288,14 @@ INNER JOIN projects target ON pr.reference_uuid = target.uuid where target.qualifier = 'APP' + +