profiler.stop();
}
+ void deleteComponentsByMainBranchProjectUuid(String uuid) {
+ profiler.start("deleteComponentsByMainBranchProjectUuid (projects)");
+ purgeMapper.deleteComponentsByMainBranchProjectUuid(uuid);
+ session.commit();
+ profiler.stop();
+ }
+
void deleteProject(String projectUuid) {
profiler.start("deleteProject (projects)");
purgeMapper.deleteProjectsByProjectUuid(projectUuid);
void deleteComponentsByProjectUuid(@Param("rootUuid") String rootUuid);
+ void deleteComponentsByMainBranchProjectUuid(@Param("uuid") String uuid);
+
void deleteProjectsByProjectUuid(@Param("projectUuid") String projectUuid);
void deleteComponentsByUuids(@Param("componentUuids") List<String> componentUuids);
project_uuid = #{rootUuid,jdbcType=VARCHAR}
</delete>
+ <delete id="deleteComponentsByMainBranchProjectUuid" parameterType="map">
+ delete from components
+ where
+ main_branch_project_uuid = #{uuid,jdbcType=VARCHAR}
+ </delete>
+
<delete id="deleteProjectsByProjectUuid" parameterType="map">
delete from projects
where
assertThat(countComponentOfRoot(otherProject)).isEqualTo(8);
}
+ @Test
+ @UseDataProvider("projects")
+ public void deleteComponentsByMainBranchProjectUuid_deletes_all_branches_of_a_project(OrganizationDto organizationDto, ComponentDto project) {
+ dbTester.organizations().insert(organizationDto);
+ dbTester.components().insertComponent(project);
+ ComponentDto branch = dbTester.components().insertProjectBranch(project);
+ Stream.of(project, branch).forEach(prj -> {
+ ComponentDto module = dbTester.components().insertComponent(ComponentTesting.newModuleDto(prj));
+ ComponentDto directory1 = dbTester.components().insertComponent(ComponentTesting.newDirectory(module, "a"));
+ ComponentDto directory2 = dbTester.components().insertComponent(ComponentTesting.newDirectory(prj, "b"));
+ dbTester.components().insertComponent(newFileDto(prj));
+ dbTester.components().insertComponent(newFileDto(module));
+ dbTester.components().insertComponent(newFileDto(directory1));
+ dbTester.components().insertComponent(newFileDto(directory2));
+ });
+
+ underTest.deleteComponentsByMainBranchProjectUuid(project.uuid());
+
+ assertThat(countComponentOfRoot(project)).isEqualTo(8);
+ assertThat(countComponentOfRoot(branch)).isZero();
+ }
+
@Test
@UseDataProvider("views")
public void deleteComponents_delete_tree_of_components_of_a_view(OrganizationDto organizationDto, ComponentDto view) {