diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-05-04 15:47:32 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-05-25 20:03:16 +0000 |
commit | 89448847c08173c261453fc4aa3cf7fca23b6c8f (patch) | |
tree | 6cc95fb05ddbd1f0552d35a0630013ae7dab78fa /server/sonar-db-dao/src | |
parent | 26c54237c1c3eb870b19c0a38176229a24c2cfe1 (diff) | |
download | sonarqube-89448847c08173c261453fc4aa3cf7fca23b6c8f.tar.gz sonarqube-89448847c08173c261453fc4aa3cf7fca23b6c8f.zip |
SONAR-16316 Fill report data
Diffstat (limited to 'server/sonar-db-dao/src')
6 files changed, 35 insertions, 14 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java index 3b1659aaa95..7bbdd0c44e6 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java @@ -52,8 +52,7 @@ public class LiveMeasureDao implements Dao { componentUuids -> mapper(dbSession).selectByComponentUuidsAndMetricUuids(componentUuids, metricUuis)); } - public void scrollSelectByComponentUuidAndMetricKeys(DbSession dbSession, String componentUuid, Collection<String> metricKeys, - ResultHandler<LiveMeasureDto> handler) { + public void scrollSelectByComponentUuidAndMetricKeys(DbSession dbSession, String componentUuid, Collection<String> metricKeys, ResultHandler<LiveMeasureDto> handler) { if (metricKeys.isEmpty()) { return; } 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 e51ee8e4ff3..d05ce597cb0 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 @@ -56,6 +56,11 @@ public class QualityGateDao implements Dao { return mapper(session).selectByUuid(uuid); } + @CheckForNull + public QualityGateDto selectDefault(DbSession session) { + return mapper(session).selectDefault(); + } + public void delete(QualityGateDto qGate, DbSession session) { mapper(session).delete(qGate.getUuid()); } @@ -81,6 +86,7 @@ public class QualityGateDao implements Dao { return session.getMapper(QualityGateMapper.class); } + @CheckForNull public QualityGateDto selectByProjectUuid(DbSession dbSession, String projectUuid) { return mapper(dbSession).selectByProjectUuid(projectUuid); } 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 5bb80ba9467..ec4901e102b 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 @@ -43,5 +43,7 @@ public interface QualityGateMapper { QualityGateDto selectByUuid(String uuid); + QualityGateDto selectDefault(); + QualityGateDto selectByProjectUuid(@Param("projectUuid") String projectUuid); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java index 315027c18e6..b692d37f315 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java @@ -159,8 +159,12 @@ public class QualityProfileDao implements Dao { return mapper(dbSession).selectAssociatedToProjectUuidAndLanguage(project.getUuid(), language); } - public List<QProfileDto> selectAssociatedToProjectUuidAndLanguages(DbSession dbSession, ProjectDto project, Collection<String> languages) { - return executeLargeInputs(languages, partition -> mapper(dbSession).selectAssociatedToProjectUuidAndLanguages(project.getUuid(), partition)); + public List<QProfileDto> selectAssociatedToProjectUuidAndLanguages(DbSession dbSession, String projectUuid, Collection<String> languages) { + return executeLargeInputs(languages, partition -> mapper(dbSession).selectAssociatedToProjectUuidAndLanguages(projectUuid, partition)); + } + + public List<QProfileDto> selectAssociatedToProjectAndLanguages(DbSession dbSession, ProjectDto project, Collection<String> languages) { + return selectAssociatedToProjectUuidAndLanguages(dbSession, project.getUuid(), languages); } public List<QProfileDto> selectByLanguage(DbSession dbSession, String language) { 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 494bccb3f6d..0b52c10da77 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 @@ -4,7 +4,7 @@ <mapper namespace="org.sonar.db.qualitygate.QualityGateMapper"> <sql id="gateColumns"> - uuid, name, is_built_in as isBuiltIn, created_at as createdAt, updated_at as updatedAt + qg.uuid, qg.name, qg.is_built_in as isBuiltIn, qg.created_at as createdAt, qg.updated_at as updatedAt </sql> <insert id="insertQualityGate" parameterType="QualityGate" useGeneratedKeys="false"> @@ -22,14 +22,14 @@ <select id="selectByName" parameterType="String" resultType="QualityGate"> select <include refid="gateColumns"/> - from quality_gates + from quality_gates qg where name=#{name, jdbcType=VARCHAR} </select> <select id="selectByUuid" parameterType="String" resultType="QualityGate"> select <include refid="gateColumns"/> - from quality_gates + from quality_gates qg where uuid=#{uuid, jdbcType=VARCHAR} </select> @@ -45,11 +45,21 @@ <select id="selectBuiltIn" resultType="org.sonar.db.qualitygate.QualityGateDto"> SELECT <include refid="gateColumns"/> - FROM quality_gates + FROM quality_gates qg WHERE is_built_in = ${_true} </select> + <select id="selectDefault" resultType="org.sonar.db.qualitygate.QualityGateDto"> + SELECT + <include refid="gateColumns"/> + FROM quality_gates qg INNER JOIN properties p ON qg.uuid = p.text_value + WHERE + p.prop_key = 'qualitygate.default' + and p.component_uuid is null + and p.user_uuid is null + </select> + <update id="delete" parameterType="String"> delete from quality_gates where uuid=#{uuid} </update> diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java index 45d0290e2dd..026fb17668e 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java @@ -656,17 +656,17 @@ public class QualityProfileDaoTest { QProfileDto jsProfile = db.qualityProfiles().insert(p -> p.setLanguage("js")); db.qualityProfiles().associateWithProject(project1, javaProfile, jsProfile); - assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbSession, project1, singletonList("java"))) + assertThat(underTest.selectAssociatedToProjectAndLanguages(dbSession, project1, singletonList("java"))) .extracting(QProfileDto::getKee).containsOnly(javaProfile.getKee()); - assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbSession, project1, singletonList("unknown"))) + assertThat(underTest.selectAssociatedToProjectAndLanguages(dbSession, project1, singletonList("unknown"))) .isEmpty(); - assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbSession, project1, of("java", "unknown"))) + assertThat(underTest.selectAssociatedToProjectAndLanguages(dbSession, project1, of("java", "unknown"))) .extracting(QProfileDto::getKee).containsExactly(javaProfile.getKee()); - assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbSession, project1, of("java", "js"))) + assertThat(underTest.selectAssociatedToProjectAndLanguages(dbSession, project1, of("java", "js"))) .extracting(QProfileDto::getKee).containsExactlyInAnyOrder(javaProfile.getKee(), jsProfile.getKee()); - assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbSession, project2, singletonList("java"))) + assertThat(underTest.selectAssociatedToProjectAndLanguages(dbSession, project2, singletonList("java"))) .isEmpty(); - assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbSession, project2, Collections.emptyList())) + assertThat(underTest.selectAssociatedToProjectAndLanguages(dbSession, project2, Collections.emptyList())) .isEmpty(); } |