aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2018-12-12 11:41:20 +0100
committersonartech <sonartech@sonarsource.com>2019-01-16 09:43:09 +0100
commit8c64cded897a94513f68899f87d5d0e37559c948 (patch)
treef025891e1324d7beac5963e9d52ddaecced91359 /server/sonar-db-dao
parent6bf996af181712c135c0bb1f52c8c9a12d1a6c9c (diff)
downloadsonarqube-8c64cded897a94513f68899f87d5d0e37559c948.tar.gz
sonarqube-8c64cded897a94513f68899f87d5d0e37559c948.zip
SONAR-11463 Don't consider disabled components during migration
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java2
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java10
4 files changed, 8 insertions, 12 deletions
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 aed5fc1138a..9ff0aa9e174 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
@@ -355,8 +355,8 @@ public class ComponentDao implements Dao {
return new HashSet<>(mapper(dbSession).selectComponentsByQualifiers(qualifiers));
}
- public List<ComponentWithModuleUuidDto> selectComponentsWithModuleUuidFromProjectKey(DbSession dbSession, String projectKey) {
- return mapper(dbSession).selectComponentsWithModuleUuidFromProjectKey(projectKey);
+ public List<ComponentWithModuleUuidDto> selectEnabledComponentsWithModuleUuidFromProjectKey(DbSession dbSession, String projectKey) {
+ return mapper(dbSession).selectEnabledComponentsWithModuleUuidFromProjectKey(projectKey);
}
public List<ComponentDto> selectProjectsByNameQuery(DbSession dbSession, @Nullable String nameQuery, boolean includeModules) {
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 7be4d074673..86cac939a71 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
@@ -167,5 +167,5 @@ public interface ComponentMapper {
List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc(@Param("organizationUuid") String organizationUuid);
- List<ComponentWithModuleUuidDto> selectComponentsWithModuleUuidFromProjectKey(String projectKey);
+ List<ComponentWithModuleUuidDto> selectEnabledComponentsWithModuleUuidFromProjectKey(String projectKey);
}
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 e5c27640043..b0aaf491f63 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
@@ -519,13 +519,13 @@
</where>
</select>
- <select id="selectComponentsWithModuleUuidFromProjectKey" resultType="ComponentWithModuleUuid">
+ <select id="selectEnabledComponentsWithModuleUuidFromProjectKey" resultType="ComponentWithModuleUuid">
SELECT
p.uuid as uuid, p.module_uuid as moduleUuid, p.path as path, p.scope as scope
FROM
projects p
INNER JOIN
- projects root ON root.uuid=p.project_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
+ projects root ON root.uuid=p.project_uuid AND p.enabled = ${_true} AND root.kee=#{projectKey,jdbcType=VARCHAR}
</select>
<select id="selectUuidsByKeyFromProjectKey" parameterType="string" resultType="KeyWithUuid">
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 a2a8964e82e..ae64c7f0d11 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
@@ -528,7 +528,7 @@ public class ComponentDaoTest {
}
@Test
- public void select_components_with_module_dto() {
+ 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));
@@ -540,18 +540,14 @@ public class ComponentDaoTest {
ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
// From root project
- assertThat(underTest.selectComponentsWithModuleUuidFromProjectKey(dbSession, project.getDbKey()))
+ assertThat(underTest.selectEnabledComponentsWithModuleUuidFromProjectKey(dbSession, project.getDbKey()))
.extracting(ComponentWithModuleUuidDto::uuid)
.containsExactlyInAnyOrder(
project.uuid(),
module.uuid(),
- removedModule.uuid(),
subModule.uuid(),
- removedSubModule.uuid(),
directory.uuid(),
- removedDirectory.uuid(),
- file.uuid(),
- removedFile.uuid()
+ file.uuid()
);
}