aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDao.java8
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioMapper.java6
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioProjectDto.java10
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml14
-rw-r--r--server/sonar-db-dao/src/schema/schema-sq.ddl2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java10
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java14
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/CreatePortfolioProjectBranchesTable.java4
8 files changed, 38 insertions, 30 deletions
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 4682d92edfd..6c008b9186a 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
@@ -202,12 +202,12 @@ public class PortfolioDao implements Dao {
return mapper(dbSession).selectBranches(portfolioProjectUuid);
}
- public void addBranch(DbSession dbSession, String portfolioProjectUuid, String branchKey) {
- mapper(dbSession).insertBranch(uuidFactory.create(), portfolioProjectUuid, branchKey, system2.now());
+ public void addBranch(DbSession dbSession, String portfolioProjectUuid, String branchUuid) {
+ mapper(dbSession).insertBranch(uuidFactory.create(), portfolioProjectUuid, branchUuid, system2.now());
}
- public void deleteBranch(DbSession dbSession, String portfolioUuid, String projectUuid, String branchKey) {
- mapper(dbSession).deleteBranch(portfolioUuid, projectUuid, branchKey);
+ public void deleteBranch(DbSession dbSession, String portfolioUuid, String projectUuid, String branchUuid) {
+ mapper(dbSession).deleteBranch(portfolioUuid, projectUuid, branchUuid);
}
/*
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 02052e05db8..0e848ccb50a 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
@@ -94,11 +94,11 @@ public interface PortfolioMapper {
List<ReferenceDto> selectAllReferencesInHierarchy(String rootUuid);
- void deleteBranch(@Param("portfolioProjectUuid") String portfolioProjectUuid, @Param("branchKey") String branchKey);
+ void deleteBranch(@Param("portfolioProjectUuid") String portfolioProjectUuid, @Param("branchUuid") String branchUuid);
- void deleteBranch(@Param("portfolioUuid") String portfolioUuid, @Param("projectUuid") String projectUuid, @Param("branchKey") String branchKey);
+ 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("branchKey") String branchKey,
+ void insertBranch(@Param("uuid") String uuid, @Param("portfolioProjectUuid") String portfolioProjectUuid, @Param("branchUuid") String branchUuid,
@Param("createdAt") long createdAt);
Set<String> selectBranches(String portfolioProjectUuid);
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioProjectDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioProjectDto.java
index e78de8efbe6..aa6f374ff0f 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioProjectDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioProjectDto.java
@@ -27,7 +27,7 @@ public class PortfolioProjectDto {
private String portfolioKey;
private String projectUuid;
private String projectKey;
- private Set<String> branchKeys;
+ private Set<String> branchUuids;
private long createdAt;
public String getUuid() {
@@ -84,11 +84,11 @@ public class PortfolioProjectDto {
return this;
}
- public Set<String> getBranchKeys() {
- return branchKeys;
+ public Set<String> getBranchUuids() {
+ return branchUuids;
}
- public void setBranchKeys(Set<String> branchKeys) {
- this.branchKeys = branchKeys;
+ public void setBranchUuids(Set<String> branchUuids) {
+ this.branchUuids = branchUuids;
}
}
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 519d19ea785..a07f7f293a7 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
@@ -37,13 +37,13 @@
pp.project_uuid as projectUuid,
p.kee as projectKey,
pp.created_at as createdAt,
- ppb.branch_key as branchKey
+ ppb.branch_uuid as branchUuid
</sql>
<resultMap id="portfolioProjectResult" type="PortfolioProject" autoMapping="true">
<id property="uuid" column="portfolioProject_uuid" />
- <collection property="branchKeys" ofType="string">
- <result column="branchKey" />
+ <collection property="branchUuids" ofType="string">
+ <result column="branchUuid" />
</collection>
</resultMap>
@@ -100,7 +100,7 @@
</select>
<select id="selectPortfolioProjectBranches" resultType="string">
- SELECT ppb.branch_key
+ SELECT ppb.branch_uuid
FROM portfolio_proj_branches ppb
WHERE ppb.portfolio_project_uuid = #{id}
</select>
@@ -405,13 +405,13 @@
INSERT INTO portfolio_proj_branches (
uuid,
portfolio_project_uuid,
- branch_key,
+ branch_uuid,
created_at
)
VALUES (
#{uuid,jdbcType=VARCHAR},
#{portfolioProjectUuid,jdbcType=VARCHAR},
- #{branchKey,jdbcType=VARCHAR},
+ #{branchUuid,jdbcType=VARCHAR},
#{createdAt,jdbcType=BIGINT}
)
</insert>
@@ -422,7 +422,7 @@
(select uuid from portfolio_projects
where portfolio_uuid = #{portfolioUuid,jdbcType=VARCHAR}
and project_uuid = #{projectUuid,jdbcType=VARCHAR})
- and branch_key = #{branchKey,jdbcType=VARCHAR}
+ and branch_uuid = #{branchUuid,jdbcType=VARCHAR}
</delete>
<update id="update" parameterType="Portfolio">
diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl
index 8591380930a..f2720a1e7e1 100644
--- a/server/sonar-db-dao/src/schema/schema-sq.ddl
+++ b/server/sonar-db-dao/src/schema/schema-sq.ddl
@@ -567,7 +567,7 @@ CREATE UNIQUE INDEX "PLUGINS_KEY" ON "PLUGINS"("KEE");
CREATE TABLE "PORTFOLIO_PROJ_BRANCHES"(
"UUID" VARCHAR(40) NOT NULL,
"PORTFOLIO_PROJECT_UUID" VARCHAR(40) NOT NULL,
- "BRANCH_KEY" VARCHAR(255) NOT NULL,
+ "BRANCH_UUID" VARCHAR(40) NOT NULL,
"CREATED_AT" BIGINT NOT NULL
);
ALTER TABLE "PORTFOLIO_PROJ_BRANCHES" ADD CONSTRAINT "PK_PORTFOLIO_PROJ_BRANCHES" PRIMARY KEY("UUID");
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java
index 83a30202e65..c8c086f392b 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java
@@ -173,7 +173,7 @@ public class PortfolioDaoTest {
portfolioDao.delete(session, p1);
portfolioDao.delete(session, p3);
- assertThat(db.select(session, "select branch_key from portfolio_proj_branches")).extracting(m -> m.values().iterator().next())
+ assertThat(db.select(session, "select branch_uuid from portfolio_proj_branches")).extracting(m -> m.values().iterator().next())
.containsOnly("branch2");
assertThat(db.select(session, "select uuid from portfolios")).extracting(m -> m.values().iterator().next())
.containsOnly("p2", "p4");
@@ -423,16 +423,16 @@ public class PortfolioDaoTest {
db.components().addPortfolioProject(portfolio1, project1);
assertThat(db.countRowsOfTable(db.getSession(), "portfolio_proj_branches")).isZero();
- assertThat(portfolioDao.selectPortfolioProjectOrFail(db.getSession(), portfolio1.getUuid(), project1.getUuid()).getBranchKeys()).isEmpty();
+ assertThat(portfolioDao.selectPortfolioProjectOrFail(db.getSession(), portfolio1.getUuid(), project1.getUuid()).getBranchUuids()).isEmpty();
db.components().addPortfolioProjectBranch(portfolio1, project1, "branch1");
assertThat(db.countRowsOfTable(db.getSession(), "portfolio_proj_branches")).isOne();
PortfolioProjectDto portfolioProject = portfolioDao.selectPortfolioProjectOrFail(db.getSession(), portfolio1.getUuid(), project1.getUuid());
- assertThat(portfolioProject.getBranchKeys()).containsOnly("branch1");
+ assertThat(portfolioProject.getBranchUuids()).containsOnly("branch1");
portfolioDao.deleteBranch(db.getSession(), portfolio1.getUuid(), project1.getUuid(), "branch1");
assertThat(db.countRowsOfTable(db.getSession(), "portfolio_proj_branches")).isZero();
- assertThat(portfolioDao.selectPortfolioProjectOrFail(db.getSession(), portfolio1.getUuid(), project1.getUuid()).getBranchKeys()).isEmpty();
+ assertThat(portfolioDao.selectPortfolioProjectOrFail(db.getSession(), portfolio1.getUuid(), project1.getUuid()).getBranchUuids()).isEmpty();
}
@Test
@@ -482,7 +482,7 @@ public class PortfolioDaoTest {
session.commit();
assertThat(portfolioDao.selectAllProjectsInHierarchy(session, root.getUuid()))
- .extracting(PortfolioProjectDto::getProjectUuid, PortfolioProjectDto::getBranchKeys)
+ .extracting(PortfolioProjectDto::getProjectUuid, PortfolioProjectDto::getBranchUuids)
.containsExactlyInAnyOrder(tuple("p1", Set.of("branch1")), tuple("p2", emptySet()), tuple("p3", emptySet()));
assertThat(portfolioDao.selectAllProjectsInHierarchy(session, "nonexisting")).isEmpty();
}
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
index b47fe7a9d99..a08cc4ee038 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
@@ -302,9 +302,17 @@ public class ComponentDbTester {
db.commit();
}
- public void addPortfolioProjectBranch(PortfolioDto portfolio, ProjectDto project, String branchKey) {
- PortfolioProjectDto portfolioProject = dbClient.portfolioDao().selectPortfolioProjectOrFail(dbSession, portfolio.getUuid(), project.getUuid());
- dbClient.portfolioDao().addBranch(db.getSession(), portfolioProject.getUuid(), branchKey);
+ public void addPortfolioProjectBranch(PortfolioDto portfolio, ProjectDto project, String branchUuid) {
+ addPortfolioProjectBranch(portfolio, project.getUuid(), branchUuid);
+ }
+
+ public void addPortfolioProjectBranch(PortfolioDto portfolio, String projectUuid, String branchUuid) {
+ addPortfolioProjectBranch(portfolio.getUuid(), projectUuid, branchUuid);
+ }
+
+ public void addPortfolioProjectBranch(String portfolioUuid, String projectUuid, String branchUuid) {
+ PortfolioProjectDto portfolioProject = dbClient.portfolioDao().selectPortfolioProjectOrFail(dbSession, portfolioUuid, projectUuid);
+ dbClient.portfolioDao().addBranch(db.getSession(), portfolioProject.getUuid(), branchUuid);
db.commit();
}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/CreatePortfolioProjectBranchesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/CreatePortfolioProjectBranchesTable.java
index bbb8cc5996b..2c2b98615da 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/CreatePortfolioProjectBranchesTable.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/CreatePortfolioProjectBranchesTable.java
@@ -30,7 +30,7 @@ import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_S
import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
public class CreatePortfolioProjectBranchesTable extends DdlChange {
- private final static String TABLE_NAME = "portfolio_proj_branches";
+ private static final String TABLE_NAME = "portfolio_proj_branches";
public CreatePortfolioProjectBranchesTable(Database db) {
super(db);
@@ -42,7 +42,7 @@ public class CreatePortfolioProjectBranchesTable extends DdlChange {
context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME)
.addPkColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setIsNullable(false).setLimit(UUID_SIZE).build())
.addColumn(newVarcharColumnDefBuilder().setColumnName("portfolio_project_uuid").setIsNullable(false).setLimit(UUID_SIZE).build())
- .addColumn(newVarcharColumnDefBuilder().setColumnName("branch_key").setIsNullable(false).setLimit(255).build())
+ .addColumn(newVarcharColumnDefBuilder().setColumnName("branch_uuid").setIsNullable(false).setLimit(UUID_SIZE).build())
.addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build())
.build());
}