diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2023-01-23 15:29:16 -0600 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-02-02 20:03:39 +0000 |
commit | 2a867fa579517222177bd14eb6e2d8d0b5cf287e (patch) | |
tree | c6d91cd3a653a8aae5a98682d8100598c189cdb9 /server/sonar-db-dao | |
parent | bbf23d6ad4ee140edbc02825d699a849ab47305a (diff) | |
download | sonarqube-2a867fa579517222177bd14eb6e2d8d0b5cf287e.tar.gz sonarqube-2a867fa579517222177bd14eb6e2d8d0b5cf287e.zip |
SONAR-17706 Drop support for projects still using modules in SonarQube server
Diffstat (limited to 'server/sonar-db-dao')
5 files changed, 0 insertions, 128 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java index dc6070aa9e7..4823fa8cfab 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java @@ -52,7 +52,6 @@ import org.sonar.db.component.BranchMapper; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentKeyUpdaterMapper; import org.sonar.db.component.ComponentMapper; -import org.sonar.db.component.ComponentWithModuleUuidDto; import org.sonar.db.component.FilePathWithHashDto; import org.sonar.db.component.KeyWithUuidDto; import org.sonar.db.component.PrBranchAnalyzedLanguageCountByProjectDto; @@ -192,7 +191,6 @@ public class MyBatis { confBuilder.loadAlias("ApplicationProject", ApplicationProjectDto.class); confBuilder.loadAlias("CeTaskCharacteristic", CeTaskCharacteristicDto.class); confBuilder.loadAlias("Component", ComponentDto.class); - confBuilder.loadAlias("ComponentWithModuleUuid", ComponentWithModuleUuidDto.class); confBuilder.loadAlias("DuplicationUnit", DuplicationUnitDto.class); confBuilder.loadAlias("Event", EventDto.class); confBuilder.loadAlias("FilePathWithHash", FilePathWithHashDto.class); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java index aea15fb93a6..a73c55936ca 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java @@ -105,10 +105,6 @@ public class ComponentDao implements Dao { return mapper(dbSession).selectByBranchUuid(branchUuid); } - public int countEnabledModulesByBranchUuid(DbSession session, String branchUuid) { - return mapper(session).countEnabledModulesByBranchUuid(branchUuid); - } - /* SELECT BY QUERY */ @@ -175,13 +171,6 @@ public class ComponentDao implements Dao { return mapper(session).selectComponentsFromProjectKeyAndScope(projectKey, Scopes.PROJECT, excludeDisabled, branch, pullRequest); } - /** - * If no branch or pull request is provided, returns components in the main branch - */ - public List<ComponentDto> selectEnabledModulesFromProjectKey(DbSession session, String projectKey, @Nullable String branch, @Nullable String pullRequest) { - return selectProjectAndModulesFromProjectKey(session, projectKey, true, branch, pullRequest); - } - public List<ComponentDto> selectByKeys(DbSession session, Collection<String> keys) { return selectByKeys(session, keys, null, null); } @@ -301,10 +290,6 @@ public class ComponentDao implements Dao { return new HashSet<>(mapper(dbSession).selectComponentsByQualifiers(qualifiers)); } - public List<ComponentWithModuleUuidDto> selectEnabledComponentsWithModuleUuidFromProjectKey(DbSession dbSession, String projectKey) { - return mapper(dbSession).selectEnabledComponentsWithModuleUuidFromProjectKey(projectKey); - } - /** * Returns components with open issues from P/Rs that use a certain branch as reference (reference branch). * Excludes components from the current branch. diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java index d16cad7608a..48d934d15c1 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java @@ -54,8 +54,6 @@ public interface ComponentMapper { List<ComponentDto> selectComponentsByQualifiers(@Param("qualifiers") Collection<String> qualifiers); - int countEnabledModulesByBranchUuid(@Param("branchUuid") String branchUuid); - List<ComponentDto> selectByQuery(@Param("query") ComponentQuery query, RowBounds rowBounds); int countByQuery(@Param("query") ComponentQuery query); @@ -139,7 +137,5 @@ public interface ComponentMapper { List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc(); - List<ComponentWithModuleUuidDto> selectEnabledComponentsWithModuleUuidFromProjectKey(String projectKey); - short checkIfAnyOfComponentsWithQualifiers(@Param("componentKeys") Collection<String> componentKeys, @Param("qualifiers") Set<String> qualifiers); } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml index 5605626e4b8..a10a3051773 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml @@ -257,16 +257,6 @@ </foreach> </select> - <select id="countEnabledModulesByBranchUuid" resultType="int"> - select - count(1) - from components p - where - p.enabled=${_true} - and p.branch_uuid = #{branchUuid,jdbcType=VARCHAR} - and p.qualifier = 'BRC' - </select> - <select id="selectByQuery" resultType="Component"> select <include refid="componentColumns"/> @@ -541,15 +531,6 @@ p.branch_uuid = #{branchUuid,jdbcType=VARCHAR} </select> - <select id="selectEnabledComponentsWithModuleUuidFromProjectKey" resultType="ComponentWithModuleUuid"> - SELECT - p.uuid as uuid, p.module_uuid as moduleUuid, p.path as path, p.scope as scope - FROM - components p - INNER JOIN - components root ON root.uuid=p.branch_uuid AND p.enabled = ${_true} AND root.kee=#{projectKey,jdbcType=VARCHAR} - </select> - <select id="selectUuidsByKeyFromProjectKeyAndBranchOrPr" parameterType="string" resultType="KeyWithUuid"> SELECT p.kee, p.uuid diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java index 79a16f640d7..5d48d654a7e 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -408,20 +408,6 @@ public class ComponentDaoTest { } @Test - public void count_enabled_modules_by_project_uuid() { - ComponentDto project = db.components().insertPrivateProject(); - ComponentDto module = db.components().insertComponent(newModuleDto(project)); - db.components().insertComponent(newModuleDto(module)); - ComponentDto subModule2 = newModuleDto(module); - subModule2.setEnabled(false); - db.components().insertComponent(subModule2); - - int result = underTest.countEnabledModulesByBranchUuid(dbSession, project.uuid()); - - assertThat(result).isEqualTo(2); - } - - @Test public void find_sub_projects_by_component_keys() { ComponentDto project = db.components().insertPrivateProject(); ComponentDto removedProject = db.components().insertPrivateProject(p -> p.setEnabled(false)); @@ -505,29 +491,6 @@ public class ComponentDaoTest { } @Test - public void select_enabled_components_with_module_dto() { - ComponentDto project = db.components().insertPrivateProject(); - ComponentDto module = db.components().insertComponent(newModuleDto(project)); - ComponentDto removedModule = db.components().insertComponent(newModuleDto(project).setEnabled(false)); - ComponentDto subModule = db.components().insertComponent(newModuleDto(module)); - ComponentDto removedSubModule = db.components().insertComponent(newModuleDto(module).setEnabled(false)); - ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src")); - ComponentDto removedDirectory = db.components().insertComponent(newDirectory(subModule, "src2").setEnabled(false)); - ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory)); - ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false)); - - // From root project - assertThat(underTest.selectEnabledComponentsWithModuleUuidFromProjectKey(dbSession, project.getKey())) - .extracting(ComponentWithModuleUuidDto::uuid) - .containsExactlyInAnyOrder( - project.uuid(), - module.uuid(), - subModule.uuid(), - directory.uuid(), - file.uuid()); - } - - @Test public void select_all_modules_tree() { ComponentDto project = db.components().insertPrivateProject(); ComponentDto removedProject = db.components().insertPrivateProject(p -> p.setEnabled(false)); @@ -719,57 +682,6 @@ public class ComponentDaoTest { } @Test - public void select_enabled_modules_from_project() { - ComponentDto project = db.components().insertPrivateProject(); - ComponentDto removedProject = db.components().insertPrivateProject(p -> p.setEnabled(false)); - ComponentDto module = db.components().insertComponent(newModuleDto(project)); - ComponentDto removedModule = db.components().insertComponent(newModuleDto(project).setEnabled(false)); - ComponentDto subModule = db.components().insertComponent(newModuleDto(module)); - ComponentDto removedSubModule = db.components().insertComponent(newModuleDto(module).setEnabled(false)); - ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src")); - ComponentDto removedDirectory = db.components().insertComponent(newDirectory(subModule, "src2").setEnabled(false)); - ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory)); - ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false)); - - // Removed modules are not included - assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getKey(), null, null)) - .extracting(ComponentDto::getKey) - .containsExactlyInAnyOrder(project.getKey(), module.getKey(), subModule.getKey()); - - assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, "UNKNOWN", null, null)).isEmpty(); - } - - @Test - public void select_enabled_modules_from_branch() { - ComponentDto project = db.components().insertPrivateProject(); - ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("branch1")); - ComponentDto module = db.components().insertComponent(newModuleDto(branch)); - ComponentDto subModule = db.components().insertComponent(newModuleDto(module)); - ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src")); - ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory)); - - // Removed modules are not included - assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getKey(), "branch1", null)) - .extracting(ComponentDto::getKey) - .containsExactlyInAnyOrder(project.getKey(), module.getKey(), subModule.getKey()); - } - - @Test - public void select_enabled_modules_from_pr() { - ComponentDto project = db.components().insertPrivateProject(); - ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(PULL_REQUEST).setKey("pr1")); - ComponentDto module = db.components().insertComponent(newModuleDto(branch)); - ComponentDto subModule = db.components().insertComponent(newModuleDto(module)); - ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src")); - ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory)); - - // Removed modules are not included - assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getKey(), null, "pr1")) - .extracting(ComponentDto::getKey) - .containsExactlyInAnyOrder(project.getKey(), module.getKey(), subModule.getKey()); - } - - @Test public void select_views_and_sub_views_and_applications() { db.components().insertPublicPortfolio("ABCD", p -> { }); |