From b1d5e0b3bb757d215b2b12feea0c06b97db1d665 Mon Sep 17 00:00:00 2001 From: Pierre Guillot Date: Thu, 17 Oct 2019 10:25:22 +0200 Subject: [PATCH] SONAR-12512 Decorate PR using configuration from new ALM_SETTINGS tables --- .../org/sonar/db/alm/setting/AlmSettingDao.java | 5 +++++ .../sonar/db/alm/setting/AlmSettingMapper.java | 2 ++ .../db/alm/setting/ProjectAlmSettingDao.java | 6 +++++- .../sonar/db/alm/setting/AlmSettingMapper.xml | 8 ++++++++ .../sonar/db/alm/setting/AlmSettingDaoTest.java | 17 ++++++++++++++++- 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/AlmSettingDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/AlmSettingDao.java index d416dcb72f7..db743855005 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/AlmSettingDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/AlmSettingDao.java @@ -57,6 +57,11 @@ public class AlmSettingDao implements Dao { return Optional.ofNullable(getMapper(dbSession).selectByKey(key)); } + public List selectByAlm(DbSession dbSession, ALM alm) { + return getMapper(dbSession).selectByAlm(alm.getId()); + } + + public List selectAll(DbSession dbSession) { return getMapper(dbSession).selectAll(); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/AlmSettingMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/AlmSettingMapper.java index 584cd4a648c..7686c99b9e8 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/AlmSettingMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/AlmSettingMapper.java @@ -31,6 +31,8 @@ public interface AlmSettingMapper { @CheckForNull AlmSettingDto selectByKey(@Param("key") String key); + List selectByAlm(String alm); + List selectAll(); void insert(@Param("dto") AlmSettingDto almSettingDto, @Param("uuid") String uuid, @Param("now") long now); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/ProjectAlmSettingDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/ProjectAlmSettingDao.java index d809f549b36..6926e1cb85b 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/ProjectAlmSettingDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/ProjectAlmSettingDao.java @@ -62,7 +62,11 @@ public class ProjectAlmSettingDao implements Dao { } public Optional selectByProject(DbSession dbSession, ComponentDto project) { - return Optional.ofNullable(getMapper(dbSession).selectByProjectUuid(project.uuid())); + return selectByProject(dbSession, project.uuid()); + } + + public Optional selectByProject(DbSession dbSession, String projectUuid) { + return Optional.ofNullable(getMapper(dbSession).selectByProjectUuid(projectUuid)); } private static ProjectAlmSettingMapper getMapper(DbSession dbSession) { diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/setting/AlmSettingMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/setting/AlmSettingMapper.xml index bf66e2983fe..17e8c548b52 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/setting/AlmSettingMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/setting/AlmSettingMapper.xml @@ -31,6 +31,14 @@ a.kee = #{key, jdbcType=VARCHAR} + +