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);
}
/*
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);
private String portfolioKey;
private String projectUuid;
private String projectKey;
- private Set<String> branchKeys;
+ private Set<String> branchUuids;
private long createdAt;
public String getUuid() {
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;
}
}
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>
</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>
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>
(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">
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");
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");
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
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();
}
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();
}
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);
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());
}