From dd47282089068a6db3bfbfd1391ff688e6a2fc07 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 5 Dec 2017 15:50:03 +0100 Subject: [PATCH] SONAR-10134 Add organization parameter in api/qualitygates/create_condition --- .../sonar/db/qualitygate/QualityGateDao.java | 6 + .../db/qualitygate/QualityGateMapper.java | 2 + .../db/qualitygate/QualityGateMapper.xml | 11 ++ .../db/qualitygate/QualityGateDaoTest.java | 13 ++ .../server/qualitygate/QualityGateFinder.java | 10 ++ .../qualitygate/ws/CreateConditionAction.java | 9 +- .../qualitygate/ws/QualityGatesWsSupport.java | 15 +- .../ws/CreateConditionActionTest.java | 151 +++++++++++------- 8 files changed, 157 insertions(+), 60 deletions(-) diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateDao.java index 4c109c56ba9..3d90f2a5f29 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateDao.java @@ -52,6 +52,7 @@ public class QualityGateDao implements Dao { return mapper(session).selectById(id); } + @CheckForNull public QGateWithOrgDto selectByOrganizationAndUuid(DbSession dbSession, OrganizationDto organization, String qualityGateUuid) { return mapper(dbSession).selectByUuidAndOrganization(qualityGateUuid, organization.getUuid()); } @@ -61,6 +62,11 @@ public class QualityGateDao implements Dao { return mapper(session).selectByNameAndOrganization(name, organization.getUuid()); } + @CheckForNull + public QGateWithOrgDto selectByOrganizationAndId(DbSession session, OrganizationDto organization, long id) { + return mapper(session).selectByIdAndOrganization(id, organization.getUuid()); + } + public void delete(QualityGateDto qGate, DbSession session) { mapper(session).delete(qGate.getId()); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateMapper.java index 4d2d37058a5..a6fa14c48ee 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateMapper.java @@ -38,6 +38,8 @@ public interface QualityGateMapper { QGateWithOrgDto selectByNameAndOrganization(@Param("name") String name, @Param("organizationUuid") String organizationUuid); + QGateWithOrgDto selectByIdAndOrganization(@Param("id") long id, @Param("organizationUuid") String organizationUuid); + QualityGateDto selectBuiltIn(); void delete(long id); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateMapper.xml index ef19f754d53..468ecab43e1 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateMapper.xml @@ -65,6 +65,17 @@ qg.name = #{name, jdbcType=VARCHAR} + +