try (DbSession dbSession = dbClient.openSession(false)) {
Component project = treeRootHolder.getRoot();
dbClient.snapshotDao().switchIsLastFlagAndSetProcessedStatus(dbSession, project.getUuid(), analysisMetadataHolder.getUuid());
- dbClient.componentDao().applyBChangesForRootComponentUuid(dbSession, project.getUuid());
+ dbClient.componentDao().applyBChangesForBranchUuid(dbSession, project.getUuid());
dbSession.commit();
}
}
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
String projectUuid = treeRootHolder.getRoot().getUuid();
// safeguard, reset all rows to b-changed=false
- dbClient.componentDao().resetBChangedForRootComponentUuid(dbSession, projectUuid);
+ dbClient.componentDao().resetBChangedForBranchUuid(dbSession, projectUuid);
Map<String, ComponentDto> existingDtosByUuids = indexExistingDtosByUuids(dbSession);
boolean isRootPrivate = isRootPrivate(treeRootHolder.getRoot(), existingDtosByUuids);
.visit(treeRootHolder.getRoot());
disableRemainingComponents(dbSession, existingDtosByUuids.values());
- dbClient.componentDao().setPrivateForRootComponentUuidWithoutAudit(dbSession, projectUuid, isRootPrivate);
+ dbClient.componentDao().setPrivateForBranchUuidWithoutAudit(dbSession, projectUuid, isRootPrivate);
dbSession.commit();
}
}
res.setDescription(project.getDescription());
res.setBranchUuid(res.uuid());
- res.setRootUuid(res.uuid());
res.setUuidPath(UUID_PATH_OF_ROOT);
return res;
res.setLongName(directory.getName());
res.setPath(directory.getName());
- setParentProperties(res, path);
+ setUuids(res, path);
return res;
}
res.setPath(file.getName());
res.setLanguage(file.getFileAttributes().getLanguageKey());
- setParentProperties(res, path);
+ setUuids(res, path);
return res;
}
res.setLongName(res.name());
res.setBranchUuid(res.uuid());
- res.setRootUuid(res.uuid());
res.setUuidPath(UUID_PATH_OF_ROOT);
return res;
*/
private void setRootAndParentModule(ComponentDto res, PathAwareVisitor.Path<ComponentDtoHolder> path) {
ComponentDto rootDto = path.root().getDto();
- res.setRootUuid(rootDto.uuid());
res.setBranchUuid(rootDto.uuid());
ComponentDto parent = path.parent().getDto();
/**
* Applies to a node of type either DIRECTORY or FILE
*/
- private static void setParentProperties(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
+ private static void setUuids(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
componentDto.setBranchUuid(path.root().getDto().uuid());
-
- ComponentDto parent = StreamSupport.stream(path.getCurrentPath().spliterator(), false)
- .filter(p -> p.component().getType() == Component.Type.PROJECT)
- .findFirst()
- .get()
- .element().getDto();
componentDto.setUuidPath(formatUuidPathFromParent(path.parent().getDto()));
- componentDto.setRootUuid(parent.uuid());
-
}
private static Optional<ComponentUpdateDto> compareForUpdate(ComponentDto existing, ComponentDto target) {
.setKey(key)
.setUuid(uuid)
.setUuidPath(uuid + ".")
- .setRootUuid(uuid)
.setBranchUuid(uuid);
db.components().insertComponent(componentDto);
return componentDto;
.setKey(key)
.setUuid(uuid)
.setUuidPath(uuid + ".")
- .setRootUuid(uuid)
.setBranchUuid(uuid);
db.components().insertComponent(componentDto);
return componentDto;
.setKey(key)
.setUuid(uuid)
.setUuidPath(uuid + ".")
- .setRootUuid(uuid)
.setBranchUuid(uuid);
db.components().insertComponent(componentDto);
return componentDto;
assertThat(directoryDto.branchUuid()).isEqualTo(projectDto.uuid());
assertThat(directoryDto.qualifier()).isEqualTo("DIR");
assertThat(directoryDto.scope()).isEqualTo("DIR");
- assertThat(directoryDto.getRootUuid()).isEqualTo(projectDto.uuid());
assertThat(directoryDto.getCreatedAt()).isEqualTo(now);
ComponentDto fileDto = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
assertThat(fileDto.branchUuid()).isEqualTo(projectDto.uuid());
assertThat(fileDto.qualifier()).isEqualTo("FIL");
assertThat(fileDto.scope()).isEqualTo("FIL");
- assertThat(fileDto.getRootUuid()).isEqualTo(projectDto.uuid());
assertThat(fileDto.getCreatedAt()).isEqualTo(now);
}
assertThat(directoryDto.branchUuid()).isEqualTo(branch.uuid());
assertThat(directoryDto.qualifier()).isEqualTo("DIR");
assertThat(directoryDto.scope()).isEqualTo("DIR");
- assertThat(directoryDto.getRootUuid()).isEqualTo(branch.uuid());
assertThat(directoryDto.getCreatedAt()).isEqualTo(now);
ComponentDto fileDto = dbClient.componentDao().selectByKeyAndBranch(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java", "feature/foo").get();
assertThat(fileDto.branchUuid()).isEqualTo(branch.uuid());
assertThat(fileDto.qualifier()).isEqualTo("FIL");
assertThat(fileDto.scope()).isEqualTo("FIL");
- assertThat(fileDto.getRootUuid()).isEqualTo(branch.uuid());
assertThat(fileDto.getCreatedAt()).isEqualTo(now);
}
underTest.execute(new TestComputationStepContext());
// commit the functional transaction
- dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
+ dbClient.componentDao().applyBChangesForBranchUuid(db.getSession(), project.uuid());
db.commit();
assertThat(dbClient.componentDao().selectByKey(db.getSession(), PROJECT_KEY + ":src/foo").get().scope()).isEqualTo("DIR");
ComponentDto directory = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
assertThat(directory.getUuidPath()).isEqualTo(directory.getUuidPath());
assertThat(directory.branchUuid()).isEqualTo(project.uuid());
- assertThat(directory.getRootUuid()).isEqualTo(project.uuid());
assertThat(directory.getMainBranchProjectUuid()).isNull();
ComponentDto file = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
assertThat(file.getUuidPath()).isEqualTo(file.getUuidPath());
assertThat(file.branchUuid()).isEqualTo(project.uuid());
- assertThat(file.getRootUuid()).isEqualTo(project.uuid());
assertThat(file.getMainBranchProjectUuid()).isNull();
}
ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getKey()).get();
assertThat(projectReloaded.uuid()).isEqualTo(project.uuid());
assertThat(projectReloaded.branchUuid()).isEqualTo(project.branchUuid());
- assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid());
assertThat(directoryReloaded.getUuidPath()).isEqualTo(directory.getUuidPath());
assertThat(directoryReloaded.branchUuid()).isEqualTo(directory.branchUuid());
- assertThat(directoryReloaded.getRootUuid()).isEqualTo(directory.getRootUuid());
assertThat(directoryReloaded.name()).isEqualTo(directory.name());
assertThat(directoryReloaded.path()).isEqualTo(directory.path());
assertThat(fileReloaded.uuid()).isEqualTo(file.uuid());
assertThat(fileReloaded.getUuidPath()).isEqualTo(file.getUuidPath());
assertThat(fileReloaded.branchUuid()).isEqualTo(file.branchUuid());
- assertThat(fileReloaded.getRootUuid()).isEqualTo(file.getRootUuid());
assertThat(fileReloaded.name()).isEqualTo(file.name());
assertThat(fileReloaded.path()).isEqualTo(file.path());
}
assertExistButDisabled(removedDirectory.getKey(), removedFile.getKey());
// commit the functional transaction
- dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
+ dbClient.componentDao().applyBChangesForBranchUuid(db.getSession(), project.uuid());
ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getKey()).get();
assertThat(projectReloaded.uuid()).isEqualTo(project.uuid());
assertThat(projectReloaded.getUuidPath()).isEqualTo(project.getUuidPath());
assertThat(projectReloaded.branchUuid()).isEqualTo(project.branchUuid());
- assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
assertThat(projectReloaded.isEnabled()).isTrue();
ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
assertThat(directoryReloaded.uuid()).isEqualTo(removedDirectory.uuid());
assertThat(directoryReloaded.getUuidPath()).isEqualTo(removedDirectory.getUuidPath());
assertThat(directoryReloaded.branchUuid()).isEqualTo(removedDirectory.branchUuid());
- assertThat(directoryReloaded.getRootUuid()).isEqualTo(removedDirectory.getRootUuid());
assertThat(directoryReloaded.name()).isEqualTo(removedDirectory.name());
assertThat(directoryReloaded.longName()).isEqualTo(removedDirectory.longName());
assertThat(directoryReloaded.path()).isEqualTo(removedDirectory.path());
assertThat(fileReloaded.uuid()).isEqualTo(removedFile.uuid());
assertThat(fileReloaded.getUuidPath()).isEqualTo(removedFile.getUuidPath());
assertThat(fileReloaded.branchUuid()).isEqualTo(removedFile.branchUuid());
- assertThat(fileReloaded.getRootUuid()).isEqualTo(removedFile.getRootUuid());
assertThat(fileReloaded.name()).isEqualTo(removedFile.name());
assertThat(fileReloaded.path()).isEqualTo(removedFile.path());
assertThat(fileReloaded.isEnabled()).isTrue();
underTest.execute(new TestComputationStepContext());
// commit functional transaction -> copies B-fields to A-fields
- dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), viewDto.uuid());
+ dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), viewDto.uuid());
dbTester.commit();
assertRowsCountInTableProjects(1);
underTest.execute(new TestComputationStepContext());
// commit functional transaction -> copies B-fields to A-fields
- dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid());
+ dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
dbTester.commit();
assertRowsCountInTableProjects(3);
underTest.execute(new TestComputationStepContext());
// commit functional transaction -> copies B-fields to A-fields
- dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid());
+ dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
dbTester.commit();
ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
underTest.execute(new TestComputationStepContext());
// commit functional transaction -> copies B-fields to A-fields
- dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid());
+ dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
dbTester.commit();
ComponentDto subViewReloaded = getComponentFromDb(SUBVIEW_1_KEY);
assertThat(dto.path()).isNull();
assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
- assertThat(dto.getRootUuid()).isEqualTo(VIEW_UUID);
assertThat(dto.qualifier()).isEqualTo(Qualifiers.VIEW);
assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
assertThat(dto.getCopyComponentUuid()).isNull();
assertThat(dto.path()).isNull();
assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
- assertThat(dto.getRootUuid()).isEqualTo(VIEW_UUID);
assertThat(dto.qualifier()).isEqualTo(Qualifiers.APP);
assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
assertThat(dto.getCopyComponentUuid()).isNull();
assertThat(sv1Dto.path()).isNull();
assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID);
assertThat(sv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
- assertThat(sv1Dto.getRootUuid()).isEqualTo(viewDto.uuid());
assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW);
assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT);
assertThat(sv1Dto.getCopyComponentUuid()).isNull();
assertThat(pv1Dto.path()).isNull();
assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID);
assertThat(pv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
- assertThat(pv1Dto.getRootUuid()).isEqualTo(viewDto.uuid());
assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT);
assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE);
assertThat(pv1Dto.getCopyComponentUuid()).isEqualTo(project.uuid());
.setEnabled(true)
.setUuid(PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
- .setRootUuid(PROJECT_UUID)
.setBranchUuid(PROJECT_UUID);
private static final String DIR_UUID = "DIR_UUID";
.setEnabled(true)
.setUuid(DIR_UUID)
.setUuidPath(UUID_PATH)
- .setRootUuid(PROJECT_UUID)
.setBranchUuid(PROJECT_UUID);
private static final String FILE_UUID = "FILE_UUID";
.setName("The File")
.setUuid(FILE_UUID)
.setUuidPath(UUID_PATH + UUID_PATH_SEPARATOR + FILE_UUID)
- .setRootUuid(PROJECT_UUID)
.setEnabled(true)
.setBranchUuid(PROJECT_UUID);
.setEnabled(true)
.setUuid(PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
- .setRootUuid(PROJECT_UUID)
.setBranchUuid(PROJECT_UUID);
@Rule
.setDescription("The project description")
.setEnabled(true)
.setUuid(PROJECT_UUID)
- .setRootUuid(PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
.setCreatedAt(new Date(1596749115856L))
.setBranchUuid(PROJECT_UUID);
.setKey("the_file")
.setName("The File")
.setUuid(FILE_UUID)
- .setRootUuid(PROJECT_UUID)
.setUuidPath(FILE_UUID_PATH)
.setEnabled(true)
.setCreatedAt(new Date(1596749148406L))
.setEnabled(true)
.setUuid(PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
- .setRootUuid(PROJECT_UUID)
.setBranchUuid(PROJECT_UUID);
private static final List<BranchDto> BRANCHES = ImmutableList.of(
private static final ComponentDto PROJECT = new ComponentDto()
.setUuid(PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
- .setRootUuid(PROJECT_UUID)
.setBranchUuid(PROJECT_UUID)
.setScope(Scopes.PROJECT)
.setQualifier(Qualifiers.PROJECT)
.setDescription("The project description")
.setEnabled(true)
.setUuid(PROJECT_UUID)
- .setRootUuid(PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
.setBranchUuid(PROJECT_UUID);
private static final ComponentDto PROJECT = new ComponentDto()
.setKey("project_key")
.setUuid("project_uuid")
- .setRootUuid("project_uuid")
.setBranchUuid("project_uuid")
.setUuidPath(UUID_PATH_OF_ROOT)
.setEnabled(true);
private static final ComponentDto FILE = new ComponentDto()
.setKey("file_key")
.setUuid("file_uuid")
- .setRootUuid("project_uuid")
.setBranchUuid("project_uuid")
.setUuidPath(UUID_PATH_OF_ROOT + PROJECT.uuid() + UUID_PATH_SEPARATOR)
.setEnabled(true);
private static final ComponentDto ANOTHER_PROJECT = new ComponentDto()
.setKey("another_project_key")
.setUuid("another_project_uuid")
- .setRootUuid("another_project_uuid")
.setBranchUuid("another_project_uuid")
.setUuidPath(UUID_PATH_OF_ROOT)
.setEnabled(true);
private static final ComponentDto PROJECT = new ComponentDto()
.setUuid(PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
- .setRootUuid(PROJECT_UUID)
.setBranchUuid(PROJECT_UUID)
.setQualifier(Qualifiers.PROJECT)
.setName("project")
private static final ComponentDto ANOTHER_PROJECT = new ComponentDto()
.setUuid(ANOTHER_PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
- .setRootUuid(ANOTHER_PROJECT_UUID)
.setBranchUuid(ANOTHER_PROJECT_UUID)
.setQualifier(Qualifiers.PROJECT)
.setName("another_project")
private static final ComponentDto PROJECT = new ComponentDto()
.setUuid("project_uuid")
.setUuidPath(UUID_PATH_OF_ROOT)
- .setRootUuid("project_uuid")
.setBranchUuid("project_uuid")
.setKey("the_project");
private static final ComponentDto ANOTHER_PROJECT = new ComponentDto()
.setUuid("another_project_uuid")
.setUuidPath(UUID_PATH_OF_ROOT)
- .setRootUuid("another_project_uuid")
.setBranchUuid("another_project_uuid")
.setKey("another_project");
view.setKey(view_uuid + "_key");
view.setUuid(view_uuid);
view.setPrivate(false);
- view.setRootUuid(view_uuid);
view.setUuidPath("uuid_path");
view.setBranchUuid(view_uuid);
db.components().insertPortfolioAndSnapshot(view);
branch.setKey(uuid + "_key");
branch.setUuid(uuid);
branch.setPrivate(false);
- branch.setRootUuid(uuid);
branch.setUuidPath("uuid_path");
branch.setBranchUuid(uuid);
db.components().insertComponent(branch);
executeLargeUpdates(uuids, mapper(session)::updateBEnabledToFalse);
}
- public void applyBChangesForRootComponentUuid(DbSession session, String branchUuid) {
- mapper(session).applyBChangesForRootComponentUuid(branchUuid);
+ public void applyBChangesForBranchUuid(DbSession session, String branchUuid) {
+ mapper(session).applyBChangesForBranchUuid(branchUuid);
}
- public void resetBChangedForRootComponentUuid(DbSession session, String branchUuid) {
- mapper(session).resetBChangedForRootComponentUuid(branchUuid);
+ public void resetBChangedForBranchUuid(DbSession session, String branchUuid) {
+ mapper(session).resetBChangedForBranchUuid(branchUuid);
}
- public void setPrivateForRootComponentUuidWithoutAudit(DbSession session, String branchUuid, boolean isPrivate) {
- mapper(session).setPrivateForRootComponentUuid(branchUuid, isPrivate);
+ public void setPrivateForBranchUuidWithoutAudit(DbSession session, String branchUuid, boolean isPrivate) {
+ mapper(session).setPrivateForBranchUuid(branchUuid, isPrivate);
}
- public void setPrivateForRootComponentUuid(DbSession session, String branchUuid, boolean isPrivate, String qualifier, String componentKey, String componentName) {
+ public void setPrivateForBranchUuid(DbSession session, String branchUuid, boolean isPrivate, String qualifier, String componentKey, String componentName) {
ComponentNewValue componentNewValue = new ComponentNewValue(branchUuid, componentName, componentKey, isPrivate, qualifier);
auditPersister.updateComponentVisibility(session, componentNewValue);
- mapper(session).setPrivateForRootComponentUuid(branchUuid, isPrivate);
+ mapper(session).setPrivateForBranchUuid(branchUuid, isPrivate);
}
/*
*/
private String branchUuid;
- /**
- * Badly named, it is not the root !
- * - on root: UUID="1" ROOT_UUID="1"
- * - on directory, value is the closest module: UUID="3" ROOT_UUID="2"
- * - on file, value is the closest module: UUID="4" ROOT_UUID="2"
- * - on view: UUID="5" ROOT_UUID="5"
- * - on sub-view: UUID="6" ROOT_UUID="5"
- *
- * @since 6.0
- */
- private String rootUuid;
-
/**
* On non-main branches only, {@link #uuid} of the main branch that represents
* the project ({@link #qualifier}="TRK").
return this;
}
- /**
- * Use {@link #branchUuid()}
- */
- @Deprecated
- public String getRootUuid() {
- return rootUuid;
- }
-
- public ComponentDto setRootUuid(String rootUuid) {
- this.rootUuid = rootUuid;
- return this;
- }
-
@Nullable
public String getMainBranchProjectUuid() {
return mainBranchProjectUuid;
.append("scope", scope)
.append("qualifier", qualifier)
.append("branchUuid", branchUuid)
- .append("rootUuid", rootUuid)
.append("mainBranchProjectUuid", mainBranchProjectUuid)
.append("copyComponentUuid", copyComponentUuid)
.append("path", path)
copy.uuid = uuid;
copy.uuidPath = uuidPath;
copy.branchUuid = branchUuid;
- copy.rootUuid = rootUuid;
copy.mainBranchProjectUuid = mainBranchProjectUuid;
copy.copyComponentUuid = copyComponentUuid;
copy.scope = scope;
ResourceDto selectComponentByUuid(@Param("uuid") String uuid);
- List<ResourceDto> selectBranchResources(@Param("rootUuid") String rootUuid);
+ List<ResourceDto> selectBranchResources(@Param("branchUuid") String branchUuid);
void updateComponent(ResourceDto resource);
void updateBEnabledToFalse(@Param("uuids") List<String> uuids);
- void applyBChangesForRootComponentUuid(@Param("branchUuid") String branchUuid);
+ void applyBChangesForBranchUuid(@Param("branchUuid") String branchUuid);
- void resetBChangedForRootComponentUuid(@Param("branchUuid") String branchUuid);
+ void resetBChangedForBranchUuid(@Param("branchUuid") String branchUuid);
- void setPrivateForRootComponentUuid(@Param("branchUuid") String branchUuid, @Param("isPrivate") boolean isPrivate);
+ void setPrivateForBranchUuid(@Param("branchUuid") String branchUuid, @Param("isPrivate") boolean isPrivate);
List<KeyWithUuidDto> selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues(@Param("referenceBranchUuid") String referenceBranchUuid,
@Param("currentBranchUuid") String currentBranchUuid);
private String deprecatedKey;
private String name;
private String longName;
- private String rootUuid;
private String path;
private String scope;
private String qualifier;
return this;
}
- public String getRootUuid() {
- return rootUuid;
- }
-
- public ResourceDto setRootUuid(String rootUuid) {
- this.rootUuid = rootUuid;
- return this;
- }
-
public String getPath() {
return path;
}
<result property="key" column="kee"/>
<result property="uuid" column="uuid"/>
<result property="deprecatedKey" column="deprecated_kee"/>
- <result property="rootUuid" column="root_uuid"/>
<result property="scope" column="scope"/>
<result property="enabled" column="enabled"/>
</resultMap>
<select id="selectBranchResources" parameterType="String" resultMap="resourceResultMap">
select * from components
where
- root_uuid = #{rootUuid,jdbcType=VARCHAR}
+ branch_uuid = #{branchUuid,jdbcType=VARCHAR}
and scope != 'PRJ'
</select>
p.qualifier as qualifier,
p.scope as scope,
p.language as language,
- p.root_uuid as rootUuid,
p.path as path,
p.enabled as enabled,
p.copy_component_uuid as copyComponentUuid,
p.qualifier as qualifier,
p.scope as scope,
p.language as language,
- p.root_uuid as rootUuid,
p.path as path,
p.enabled as enabled,
p.copy_component_uuid as copyComponentUuid,
<include refid="componentColumns"/>
FROM components p
INNER JOIN components child ON
- child.root_uuid=p.uuid
+ child.branch_uuid=p.uuid
and child.enabled=${_true}
where
p.enabled=${_true}
language,
description,
private,
- root_uuid,
path,
copy_component_uuid,
enabled,
#{language,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},
#{isPrivate,jdbcType=BOOLEAN},
- #{rootUuid,jdbcType=VARCHAR},
#{path,jdbcType=VARCHAR},
#{copyComponentUuid,jdbcType=VARCHAR},
#{enabled,jdbcType=BOOLEAN},
uuid in <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">#{uuid,jdbcType=VARCHAR}</foreach>
</update>
- <update id="applyBChangesForRootComponentUuid" parameterType="string" useGeneratedKeys="false">
+ <update id="applyBChangesForBranchUuid" parameterType="string" useGeneratedKeys="false">
update components set
<!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
kee = deprecated_kee,
b_changed = ${_true}
</update>
- <update id="resetBChangedForRootComponentUuid" parameterType="map" >
+ <update id="resetBChangedForBranchUuid" parameterType="map" >
update components
set b_changed = ${_false},
<!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
b_changed = ${_true}
</update>
- <update id="setPrivateForRootComponentUuid" parameterType="map" >
+ <update id="setPrivateForBranchUuid" parameterType="map" >
update components set
private = #{isPrivate,jdbcType=BOOLEAN}
where
"SCOPE" CHARACTER VARYING(3),
"QUALIFIER" CHARACTER VARYING(10),
"PRIVATE" BOOLEAN NOT NULL,
- "ROOT_UUID" CHARACTER VARYING(50) NOT NULL,
"LANGUAGE" CHARACTER VARYING(20),
"COPY_COMPONENT_UUID" CHARACTER VARYING(50),
"PATH" CHARACTER VARYING(2000),
"CREATED_AT" TIMESTAMP
);
CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
-CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
CREATE UNIQUE INDEX "COMPONENTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
CREATE INDEX "COMPONENTS_BRANCH_UUID" ON "COMPONENTS"("BRANCH_UUID" NULLS FIRST);
assertThat(result.getKey()).isEqualTo(project.getKey());
assertThat(result.uuid()).isEqualTo(project.uuid());
assertThat(result.getUuidPath()).isEqualTo(project.getUuidPath());
- assertThat(result.getRootUuid()).isEqualTo(project.uuid());
assertThat(result.branchUuid()).isEqualTo(project.uuid());
}
}
@Test
- public void setPrivateForRootComponentUuid_updates_private_column_to_specified_value_for_all_rows_with_specified_projectUuid() {
+ public void setPrivateForBranchUuid_updates_private_column_to_specified_value_for_all_rows_with_specified_projectUuid() {
String uuid1 = "uuid1";
String uuid2 = "uuid2";
db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid1).setPrivate(false)).uuid(),
db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid2).setPrivate(true)).uuid(),
db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid2).setPrivate(false)).uuid(),
- db.components().insertComponent(newPrivateProjectDto().setRootUuid(uuid1).setBranchUuid("foo").setPrivate(false)).uuid(),
+ db.components().insertComponent(newPrivateProjectDto().setBranchUuid("foo").setPrivate(false)).uuid(),
};
- underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid1, true);
+ underTest.setPrivateForBranchUuidWithoutAudit(db.getSession(), uuid1, true);
assertThat(privateFlagOfUuid(uuids[0])).isTrue();
assertThat(privateFlagOfUuid(uuids[1])).isTrue();
assertThat(privateFlagOfUuid(uuids[3])).isFalse();
assertThat(privateFlagOfUuid(uuids[4])).isFalse();
- underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid1, false);
+ underTest.setPrivateForBranchUuidWithoutAudit(db.getSession(), uuid1, false);
assertThat(privateFlagOfUuid(uuids[0])).isFalse();
assertThat(privateFlagOfUuid(uuids[1])).isFalse();
assertThat(privateFlagOfUuid(uuids[3])).isFalse();
assertThat(privateFlagOfUuid(uuids[4])).isFalse();
- underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid2, false);
+ underTest.setPrivateForBranchUuidWithoutAudit(db.getSession(), uuid2, false);
assertThat(privateFlagOfUuid(uuids[0])).isFalse();
assertThat(privateFlagOfUuid(uuids[1])).isFalse();
assertThat(privateFlagOfUuid(uuids[3])).isFalse();
assertThat(privateFlagOfUuid(uuids[4])).isFalse();
- underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid2, true);
+ underTest.setPrivateForBranchUuidWithoutAudit(db.getSession(), uuid2, true);
assertThat(privateFlagOfUuid(uuids[0])).isFalse();
assertThat(privateFlagOfUuid(uuids[1])).isFalse();
}
@Test
- public void setPrivateForRootComponentUuid_auditPersisterIsCalled() {
- underTestWithAuditPersister.setPrivateForRootComponentUuid(dbSession, "anyUuid", false, "key", APP, "appName");
+ public void setPrivateForBranchUuid_auditPersisterIsCalled() {
+ underTestWithAuditPersister.setPrivateForBranchUuid(dbSession, "anyUuid", false, "key", APP, "appName");
verify(auditPersister).updateComponentVisibility(any(DbSession.class), any(ComponentNewValue.class));
}
@Test
- public void setPrivateForRootComponentUuidWithoutAudit_auditPersisterIsNotCalled() {
- underTestWithAuditPersister.setPrivateForRootComponentUuidWithoutAudit(dbSession, "anyUuid", false);
+ public void setPrivateForBranchUuidWithoutAudit_auditPersisterIsNotCalled() {
+ underTestWithAuditPersister.setPrivateForBranchUuidWithoutAudit(dbSession, "anyUuid", false);
verifyNoInteractions(auditPersister);
}
.setLanguage("java")
.setDescription("desc")
.setPath("src/org/struts/RequestContext.java")
- .setCopyComponentUuid("uuid_5")
- .setRootUuid("uuid_3");
+ .setCopyComponentUuid("uuid_5");
assertThat(componentDto.getKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(componentDto.name()).isEqualTo("RequestContext.java");
assertThat(componentDto.path()).isEqualTo("src/org/struts/RequestContext.java");
assertThat(componentDto.language()).isEqualTo("java");
assertThat(componentDto.description()).isEqualTo("desc");
- assertThat(componentDto.getRootUuid()).isEqualTo("uuid_3");
assertThat(componentDto.getCopyComponentUuid()).isEqualTo("uuid_5");
assertThat(componentDto.isPrivate()).isFalse();
}
}
private void populateSomeData() {
- ComponentDto project1 = db.components().insertPrivateProject(t -> t.setKey("org.struts:struts").setUuid("A"));
+ ComponentDto project1 = db.components().insertPrivateProject(t -> t.setKey("org.struts:struts").setUuid("A").setBranchUuid("A"));
ComponentDto directory1 = db.components().insertComponent(newDirectory(project1, "/src/org/struts").setUuid("B"));
db.components().insertComponent(ComponentTesting.newFileDto(project1, directory1).setKey("org.struts:struts:/src/org/struts/RequestContext.java").setUuid("C"));
ComponentDto project2 = db.components().insertPublicProject(t -> t.setKey("foo:struts-core").setUuid("D"));
<projects organization_uuid="org1"
id="1"
- root_uuid="uuid_200"
uuid="ABCD"
uuid_path="NOT_USED"
project_uuid="ABCD"
- module_uuid="[null]"
- module_uuid_path="."
main_branch_project_uuid="[null]"
scope="PRJ"
qualifier="TRK"
b_uuid_path="[null]"
b_language="[null]"
b_long_name="[null]"
- b_module_uuid="[null]"
- b_module_uuid_path="[null]"
b_name="[null]"
b_path="[null]"
b_qualifier="[null]"
<projects organization_uuid="org1"
id="1"
- root_uuid="uuid_200"
uuid="ABCD"
uuid_path="NOT_USED"
project_uuid="ABCD"
- module_uuid="[null]"
- module_uuid_path="."
main_branch_project_uuid="[null]"
scope="PRJ"
qualifier="TRK"
b_uuid_path="[null]"
b_language="[null]"
b_long_name="[null]"
- b_module_uuid="[null]"
- b_module_uuid_path="[null]"
b_name="[null]"
b_path="[null]"
b_qualifier="[null]"
<projects organization_uuid="org1"
uuid="ABCD"
uuid_path="NOT_USED"
- root_uuid="ABCD"
project_uuid="ABCD"
- module_uuid="[null]"
- module_uuid_path="."
kee="struts"
qualifier="TRK"
scope="PRJ"
<projects organization_uuid="org1"
uuid="BCDE"
uuid_path="NOT_USED"
- root_uuid="ABCD"
project_uuid="ABCD"
- module_uuid="[null]"
- module_uuid_path=".ABCD."
kee="struts-core"
qualifier="BRC"
scope="PRJ"
<projects organization_uuid="org1"
uuid="CDEF"
uuid_path="NOT_USED"
- root_uuid="BCDE"
project_uuid="ABCD"
- module_uuid="BCDE"
- module_uuid_path=".ABCD.BCDE."
kee="Action.java"
qualifier="CLA"
scope="PRJ"
<projects organization_uuid="org1"
uuid="DEFG"
uuid_path="NOT_USED"
- root_uuid="CDEF"
project_uuid="ABCD"
- module_uuid="BCDE"
- module_uuid_path=".ABCD.BCDE."
kee="Filter.java"
qualifier="CLA"
scope="PRJ"
uuid="ABCD"
uuid_path="NOT_USED"
project_uuid="ABCD"
- module_uuid="[null]"
- module_uuid_path=".ABCD."
enabled="[true]"
long_name="[null]"
id="1"
scope="PRJ"
qualifier="TRK"
kee="project"
- name="project"
- root_uuid="ABCD"/>
+ name="project"/>
<!-- package -->
<projects organization_uuid="org1"
uuid="BCDE"
uuid_path="NOT_USED"
project_uuid="ABCD"
- module_uuid="ABCD"
- module_uuid_path=".ABCD."
enabled="[true]"
long_name="[null]"
id="2"
scope="DIR"
qualifier="PAC"
kee="project:org.foo"
- name="org.foo"
- root_uuid="ABCD"/>
+ name="org.foo"/>
<!-- file -->
<projects organization_uuid="org1"
uuid="CDEF"
uuid_path="NOT_USED"
project_uuid="ABCD"
- module_uuid="ABCD"
- module_uuid_path=".ABCD."
enabled="[true]"
long_name="org.foo.Bar"
id="3"
scope="FIL"
qualifier="CLA"
kee="project:org.foo.Bar"
- name="Bar"
- root_uuid="ABCD"/>
+ name="Bar"/>
<!-- snapshots -->
<projects organization_uuid="org1"
uuid="FILE1"
uuid_path="NOT_USED"
- root_uuid="ABCD"
id="1"
kee="org.struts:struts-core:src/org/struts/RequestContext.java"
enabled="[true]"/>
<projects organization_uuid="org1"
uuid="ABCD"
uuid_path="NOT_USED"
- root_uuid="ABCD"
id="1"
kee="org.struts:struts-core:src/org/struts/RequestContext.java"
enabled="[true]"/>
id="300"
uuid="ABCD"
uuid_path="NOT_USED"
- root_uuid="ABCD"
project_uuid="ABCD"
- module_uuid="[null]"
kee="pj-w-snapshot"
scope="PRJ"
qualifier="TRK"
id="301"
uuid="BCDE"
uuid_path="NOT_USED"
- root_uuid="BCDE"
project_uuid="BCDE"
- module_uuid="[null]"
kee="pj-w-snapshot1"
scope="PRJ"
qualifier="TRK"
id="302"
uuid="CDEF"
uuid_path="NOT_USED"
- root_uuid="CDEF"
project_uuid="CDEF"
- module_uuid="[null]"
kee="pj-w-snapshot2"
scope="PRJ"
qualifier="TRK"
id="303"
uuid="DEFG"
uuid_path="NOT_USED"
- root_uuid="DEFG"
project_uuid="DEFG"
- module_uuid="[null]"
kee="pj-w-snapshot3"
scope="PRJ"
qualifier="TRK"
id="300"
uuid="ABCD"
uuid_path="NOT_USED"
- root_uuid="ABCD"
project_uuid="ABCD"
- module_uuid="[null]"
kee="pj-w-snapshot"
scope="PRJ"
qualifier="TRK"
id="301"
uuid="BCDE"
uuid_path="NOT_USED"
- root_uuid="BCDE"
project_uuid="BCDE"
- module_uuid="[null]"
kee="pj-w-snapshot1"
scope="PRJ"
qualifier="TRK"
id="302"
uuid="CDEF"
uuid_path="NOT_USED"
- root_uuid="CDEF"
project_uuid="CDEF"
- module_uuid="[null]"
kee="pj-w-snapshot2"
scope="PRJ"
qualifier="TRK"
id="303"
uuid="DEFG"
uuid_path="NOT_USED"
- root_uuid="DEFG"
project_uuid="DEFG"
- module_uuid="[null]"
kee="pj-w-snapshot3"
scope="PRJ"
qualifier="TRK"
id="300"
uuid="ABCD"
uuid_path="NOT_USED"
- root_uuid="ABCD"
project_uuid="ABCD"
- module_uuid="[null]"
kee="pj-w-snapshot"
scope="PRJ"
qualifier="TRK"
id="301"
uuid="BCDE"
uuid_path="NOT_USED"
- root_uuid="BCDE"
project_uuid="BCDE"
- module_uuid="[null]"
kee="pj-w-snapshot1"
scope="PRJ"
qualifier="TRK"
id="302"
uuid="CDEF"
uuid_path="NOT_USED"
- root_uuid="CDEF"
project_uuid="CDEF"
- module_uuid="[null]"
kee="pj-w-snapshot2"
scope="PRJ"
qualifier="TRK"
id="303"
uuid="DEFG"
uuid_path="NOT_USED"
- root_uuid="DEFG"
project_uuid="DEFG"
- module_uuid="[null]"
kee="pj-w-snapshot3"
scope="PRJ"
qualifier="TRK"
.setName(filename)
.setLongName(path)
.setScope(Scopes.FILE)
+ .setBranchUuid(project.branchUuid())
.setQualifier(Qualifiers.FILE)
.setPath(path)
.setCreatedAt(new Date())
.setKey(key)
.setName(path)
.setLongName(path)
+ .setBranchUuid(project.branchUuid())
.setPath(path)
.setScope(Scopes.DIRECTORY)
.setQualifier(Qualifiers.DIRECTORY);
.setUuid(uuid)
.setUuidPath(UUID_PATH_OF_ROOT)
.setBranchUuid(uuid)
- .setRootUuid(uuid)
.setKey("KEY_" + uuid)
.setName("NAME_" + uuid)
.setLongName("LONG_NAME_" + uuid)
.setUuidPath(formatUuidPathFromParent(parent))
.setKey(uuid)
.setBranchUuid(project.branchUuid())
- .setRootUuid(project.uuid())
.setMainBranchProjectUuid(project.getMainBranchProjectUuid())
.setCreatedAt(new Date())
.setEnabled(true)
.setUuid(uuid)
.setUuidPath(UUID_PATH_OF_ROOT)
.setBranchUuid(uuid)
- .setRootUuid(uuid)
.setKey(project.getKey())
.setMainBranchProjectUuid(project.getUuid())
.setName(project.getName())
.setUuid(uuid)
.setUuidPath(UUID_PATH_OF_ROOT)
.setBranchUuid(uuid)
- .setRootUuid(uuid)
.setKey(project.getKey())
.setMainBranchProjectUuid(project.uuid())
.setName(project.name())
.add(10_0_003, "Drop column 'module_uuid_path' in the 'Components' table", DropModuleUuidPathInComponents.class)
.add(10_0_004, "Drop column 'b_module_uuid' in the 'Components' table", DropBModuleUuidInComponents.class)
.add(10_0_005, "Drop column 'b_module_uuid_path' in the 'Components' table", DropBModuleUuidPathInComponents.class)
+ .add(10_0_006, "Drop index 'projects_root_uuid' in the 'Components' table", DropIndexProjectsRootUuidInComponents.class)
+ .add(10_0_007, "Drop column 'root_uuid' in the 'Components' table", DropRootUuidInComponents.class)
+
+
;
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v100;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropIndexChange;
+
+public class DropIndexProjectsRootUuidInComponents extends DropIndexChange {
+ private static final String INDEX_NAME = "projects_root_uuid";
+ private static final String TABLE_NAME = "components";
+
+ public DropIndexProjectsRootUuidInComponents(Database db) {
+ super(db, INDEX_NAME, TABLE_NAME);
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v100;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropRootUuidInComponents extends DropColumnChange {
+ private static final String COLUMN_NAME = "root_uuid";
+ private static final String TABLE_NAME = "components";
+
+ protected DropRootUuidInComponents(Database db) {
+ super(db, TABLE_NAME, COLUMN_NAME);
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v100;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropIndexProjectsRootUuidInComponentsTest {
+ private static final String TABLE_NAME = "components";
+ private static final String COLUMN_NAME = "root_uuid";
+ private static final String INDEX_NAME = "projects_root_uuid";
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexProjectsRootUuidInComponentsTest.class, "schema.sql");
+ private final DdlChange underTest = new DropIndexProjectsRootUuidInComponents(db.database());
+
+ @Test
+ public void drops_index() throws SQLException {
+ db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+ underTest.execute();
+ db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
+ }
+
+ @Test
+ public void migration_is_reentrant() throws SQLException {
+ db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+ underTest.execute();
+ underTest.execute();
+ db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v100;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropRootUuidInComponentsTest {
+ private static final String TABLE_NAME = "components";
+ private static final String COLUMN_NAME = "root_uuid";
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropRootUuidInComponentsTest.class, "schema.sql");
+ private final DdlChange underTest = new DropRootUuidInComponents(db.database());
+
+ @Test
+ public void drops_column() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, false);
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+ @Test
+ public void migration_is_reentrant() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, false);
+ underTest.execute();
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+}
--- /dev/null
+
+CREATE TABLE "COMPONENTS"(
+ "UUID" CHARACTER VARYING(50) NOT NULL,
+ "KEE" CHARACTER VARYING(1000),
+ "DEPRECATED_KEE" CHARACTER VARYING(400),
+ "NAME" CHARACTER VARYING(2000),
+ "LONG_NAME" CHARACTER VARYING(2000),
+ "DESCRIPTION" CHARACTER VARYING(2000),
+ "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL,
+ "SCOPE" CHARACTER VARYING(3),
+ "QUALIFIER" CHARACTER VARYING(10),
+ "PRIVATE" BOOLEAN NOT NULL,
+ "ROOT_UUID" CHARACTER VARYING(50) NOT NULL,
+ "LANGUAGE" CHARACTER VARYING(20),
+ "COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+ "PATH" CHARACTER VARYING(2000),
+ "UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
+ "BRANCH_UUID" CHARACTER VARYING(50) NOT NULL,
+ "MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
+ "B_CHANGED" BOOLEAN,
+ "B_NAME" CHARACTER VARYING(500),
+ "B_LONG_NAME" CHARACTER VARYING(500),
+ "B_DESCRIPTION" CHARACTER VARYING(2000),
+ "B_ENABLED" BOOLEAN,
+ "B_QUALIFIER" CHARACTER VARYING(10),
+ "B_LANGUAGE" CHARACTER VARYING(20),
+ "B_COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+ "B_PATH" CHARACTER VARYING(2000),
+ "B_UUID_PATH" CHARACTER VARYING(1500),
+ "CREATED_AT" TIMESTAMP
+);
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
+CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
+CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
+CREATE UNIQUE INDEX "COMPONENTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
+CREATE INDEX "COMPONENTS_BRANCH_UUID" ON "COMPONENTS"("BRANCH_UUID" NULLS FIRST);
+CREATE UNIQUE INDEX "COMPONENTS_KEE_BRANCH_UUID" ON "COMPONENTS"("KEE" NULLS FIRST, "BRANCH_UUID" NULLS FIRST);
--- /dev/null
+
+CREATE TABLE "COMPONENTS"(
+ "UUID" CHARACTER VARYING(50) NOT NULL,
+ "KEE" CHARACTER VARYING(1000),
+ "DEPRECATED_KEE" CHARACTER VARYING(400),
+ "NAME" CHARACTER VARYING(2000),
+ "LONG_NAME" CHARACTER VARYING(2000),
+ "DESCRIPTION" CHARACTER VARYING(2000),
+ "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL,
+ "SCOPE" CHARACTER VARYING(3),
+ "QUALIFIER" CHARACTER VARYING(10),
+ "PRIVATE" BOOLEAN NOT NULL,
+ "ROOT_UUID" CHARACTER VARYING(50) NOT NULL,
+ "LANGUAGE" CHARACTER VARYING(20),
+ "COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+ "PATH" CHARACTER VARYING(2000),
+ "UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
+ "BRANCH_UUID" CHARACTER VARYING(50) NOT NULL,
+ "MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
+ "B_CHANGED" BOOLEAN,
+ "B_NAME" CHARACTER VARYING(500),
+ "B_LONG_NAME" CHARACTER VARYING(500),
+ "B_DESCRIPTION" CHARACTER VARYING(2000),
+ "B_ENABLED" BOOLEAN,
+ "B_QUALIFIER" CHARACTER VARYING(10),
+ "B_LANGUAGE" CHARACTER VARYING(20),
+ "B_COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+ "B_PATH" CHARACTER VARYING(2000),
+ "B_UUID_PATH" CHARACTER VARYING(1500),
+ "CREATED_AT" TIMESTAMP
+);
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
+CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
+CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
+CREATE UNIQUE INDEX "COMPONENTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
+CREATE INDEX "COMPONENTS_BRANCH_UUID" ON "COMPONENTS"("BRANCH_UUID" NULLS FIRST);
+CREATE UNIQUE INDEX "COMPONENTS_KEE_BRANCH_UUID" ON "COMPONENTS"("KEE" NULLS FIRST, "BRANCH_UUID" NULLS FIRST);
ComponentUpdateDto updateComponent = ComponentUpdateDto.copyFrom(component);
updateComponent.setBChanged(true);
dbClient.componentDao().update(dbSession, updateComponent, component.qualifier());
- dbClient.componentDao().applyBChangesForRootComponentUuid(dbSession, component.getRootUuid());
+ dbClient.componentDao().applyBChangesForBranchUuid(dbSession, component.branchUuid());
dbSession.commit();
}
<projects organization_uuid="org1"
uuid="THE_PROJECT"
uuid_path="NOT_USED"
- root_uuid="THE_PROJECT"
project_uuid="THE_PROJECT"
- module_uuid="[null]"
- module_uuid_path="."
path="[null]"
id="10"
scope="PRJ"
<projects organization_uuid="org1"
uuid="THE_FILE"
uuid_path="NOT_USED"
- root_uuid="THE_PROJECT"
project_uuid="THE_PROJECT"
- module_uuid="THE_PROJECT"
- module_uuid_path=".THE_PROJECT."
path="src/main/java/TheFile.java"
id="11"
scope="FIL"
<projects organization_uuid="org1"
uuid="THE_PROJECT_1"
uuid_path="NOT_USED"
- root_uuid="THE_PROJECT_1"
project_uuid="THE_PROJECT_1"
- module_uuid="[null]"
- module_uuid_path="."
path="[null]"
id="10"
scope="PRJ"
<projects organization_uuid="org1"
uuid="THE_FILE_1"
uuid_path="NOT_USED"
- root_uuid="THE_PROJECT_1"
project_uuid="THE_PROJECT_1"
- module_uuid="THE_PROJECT_1"
- module_uuid_path=".THE_PROJECT_1."
path="src/main/java/TheFile.java"
id="11"
scope="FIL"
<projects organization_uuid="org1"
uuid="THE_PROJECT_2"
uuid_path="NOT_USED"
- root_uuid="THE_PROJECT_2"
- module_uuid="[null]"
- module_uuid_path="."
path="[null]"
id="100"
scope="PRJ"
<projects organization_uuid="org1"
uuid="THE_FILE_2"
uuid_path="NOT_USED"
- root_uuid="THE_PROJECT_2"
- module_uuid="THE_PROJECT_2"
- module_uuid_path=".THE_PROJECT_2."
path="src/main/java/TheFile.java"
id="111"
scope="FIL"
assertThat(session.hasChildProjectsPermission(USER, application)).isTrue();
// change privacy of the project without updating the cache
- db.getDbClient().componentDao().setPrivateForRootComponentUuidWithoutAudit(db.getSession(), project.uuid(), true);
+ db.getDbClient().componentDao().setPrivateForBranchUuidWithoutAudit(db.getSession(), project.uuid(), true);
assertThat(session.hasChildProjectsPermission(USER, application)).isTrue();
}
assertThat(session.hasChildProjectsPermission(USER, portfolio)).isTrue();
// change privacy of the project without updating the cache
- db.getDbClient().componentDao().setPrivateForRootComponentUuidWithoutAudit(db.getSession(), project.uuid(), true);
+ db.getDbClient().componentDao().setPrivateForBranchUuidWithoutAudit(db.getSession(), project.uuid(), true);
assertThat(session.hasChildProjectsPermission(USER, portfolio)).isTrue();
}
ComponentDto component = new ComponentDto()
.setUuid(uuid)
.setUuidPath(ComponentDto.UUID_PATH_OF_ROOT)
- .setRootUuid(uuid)
.setBranchUuid(uuid)
.setKey(newComponent.key())
.setName(newComponent.name())
private void setPrivateForRootComponentUuid(DbSession dbSession, ComponentDto component, boolean isPrivate) {
String uuid = component.uuid();
- dbClient.componentDao().setPrivateForRootComponentUuid(dbSession, uuid, isPrivate, component.getKey(), component.qualifier(), component.name());
+ dbClient.componentDao().setPrivateForBranchUuid(dbSession, uuid, isPrivate, component.getKey(), component.qualifier(), component.name());
if (component.qualifier().equals(Qualifiers.PROJECT) || component.qualifier().equals(Qualifiers.APP)) {
dbClient.projectDao().updateVisibility(dbSession, uuid, isPrivate);
ComponentMapper mapper = dbSession.getMapper(ComponentMapper.class);
dbSession.getMapper(BranchMapper.class).selectByProjectUuid(uuid).stream()
.filter(branch -> !uuid.equals(branch.getUuid()))
- .forEach(branch -> mapper.setPrivateForRootComponentUuid(branch.getUuid(), isPrivate));
+ .forEach(branch -> mapper.setPrivateForBranchUuid(branch.getUuid(), isPrivate));
}
private boolean noPendingTask(DbSession dbSession, ComponentDto rootComponent) {
dbClient.componentDao().insert(dbSession, new ComponentDto()
.setUuid(uuid)
.setUuidPath(uuid + ".")
- .setRootUuid(uuid)
.setBranchUuid("branchUuid")
.setScope(Scopes.PROJECT)
.setKey("key"));
PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL)
.name("Server base URL")
.description(
- "HTTP(S) URL of this SonarQube server, such as <i>https://yourhost.yourdomain/sonar</i>. This value is used outside SonarQube itself, e.g. for PR decoration, emails, etc.")
+ "HTTP(S) URL of this SonarQube server, such as <i>https://yourhost.yourdomain/sonar</i>. "
+ + "This value is used outside SonarQube itself, e.g. for PR decoration, emails, etc.")
.category(CoreProperties.CATEGORY_GENERAL)
.build(),
PropertyDefinition.builder(SONAR_PROJECTCREATION_MAINBRANCHNAME)
*/
package org.sonar.core.config;
-import com.google.common.collect.ImmutableList;
import java.util.List;
import org.sonar.api.CoreProperties;
import org.sonar.api.PropertyType;
}
public static List<PropertyDefinition> all() {
- return ImmutableList.of(
+ return List.of(
// COVERAGE
PropertyDefinition.builder(CoreProperties.PROJECT_COVERAGE_EXCLUSIONS_PROPERTY)