diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2017-07-26 17:49:45 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2017-07-26 17:49:45 +0200 |
commit | acdecb5ce3d6ce8aebc8685bf7bda8e7a218245c (patch) | |
tree | b290aa3f2f218d59f8a1847130c9a34fd51db99d /server/sonar-db-dao | |
parent | f4c2e0eb9afe66f5e71e9f1447f059dd15b143ff (diff) | |
download | sonarqube-acdecb5ce3d6ce8aebc8685bf7bda8e7a218245c.tar.gz sonarqube-acdecb5ce3d6ce8aebc8685bf7bda8e7a218245c.zip |
Revert "SONAR-9584 Add root project key to response of api/components/search"
This reverts commit f4c2e0eb9afe66f5e71e9f1447f059dd15b143ff.
Diffstat (limited to 'server/sonar-db-dao')
3 files changed, 3 insertions, 42 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java index 797dfb1f57a..215a248c0c4 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java @@ -61,11 +61,6 @@ public class ComponentDto implements Component { private String kee; /** - * Key of the root component this component belongs to. Consistent with projectUUid. - */ - private String projectKey; - - /** * Not empty . Max size is 50 (note that effective UUID values are 40 characters with * the current algorithm in use). Obviously it is unique. * It is generated by Compute Engine. @@ -226,18 +221,6 @@ public class ComponentDto implements Component { return this; } - /** - * Return the root project key. On a root project, return itself - */ - public String projectKey() { - return projectKey; - } - - public ComponentDto setProjectKey(String projectKey) { - this.projectKey = projectKey; - return this; - } - public boolean isRoot() { return UUID_PATH_OF_ROOT.equals(uuidPath); } 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 b9939aabb1c..fecf8cf8715 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 @@ -238,21 +238,18 @@ <select id="selectByQuery" resultType="Component"> select - <include refid="componentColumns"/>, - root.kee as projectKey - from projects p - inner join projects root on p.project_uuid=root.uuid and p.organization_uuid=root.organization_uuid + <include refid="componentColumns"/> <include refid="sqlSelectByQuery"/> ORDER BY LOWER(p.name), p.name, p.id </select> <select id="countByQuery" resultType="int"> select count(p.id) - from projects p <include refid="sqlSelectByQuery"/> </select> <sql id="sqlSelectByQuery"> + from projects p where p.enabled=${_true} AND p.copy_component_uuid is null 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 997131fb86b..c9c83436a8e 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 @@ -47,7 +47,6 @@ import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; import static org.assertj.guava.api.Assertions.assertThat; import static org.sonar.db.component.ComponentTesting.newDirectory; import static org.sonar.db.component.ComponentTesting.newFileDto; @@ -548,8 +547,7 @@ public class ComponentDaoTest { @Test public void select_provisioned() { OrganizationDto organization = db.organizations().insert(); - ComponentDto provisionedProject = db.components() - .insertComponent(ComponentTesting.newPrivateProjectDto(organization).setKey("provisioned.project").setName("Provisioned Project")); + ComponentDto provisionedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organization).setKey("provisioned.project").setName("Provisioned Project")); ComponentDto provisionedView = db.components().insertView(organization); String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization)).getComponentUuid(); String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization).setEnabled(false)).getComponentUuid(); @@ -969,23 +967,6 @@ public class ComponentDaoTest { } @Test - public void selectByQuery_returns_projectKey() { - ComponentDto project = ComponentTesting.newPublicProjectDto(db.getDefaultOrganization()).setKey("project-key"); - db.components().insertComponent(project); - ComponentDto module = ComponentTesting.newModuleDto(project).setKey("module-key"); - db.components().insertComponent(module); - ComponentDto file = ComponentTesting.newFileDto(module).setKey("file-key"); - db.components().insertComponent(file); - - ComponentQuery allQuery = ComponentQuery.builder().setQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE, Qualifiers.FILE).build(); - - assertThat(underTest.selectByQuery(dbSession, allQuery, 0, 10)).extracting(ComponentDto::getKey, ComponentDto::projectKey) - .containsOnly(tuple("project-key", "project-key"), - tuple("module-key", "project-key"), - tuple("file-key", "project-key")); - } - - @Test public void selectByQuery_on_empty_list_of_component_id() { ComponentQuery dbQuery = ComponentQuery.builder().setQualifiers(Qualifiers.PROJECT).setComponentIds(emptySet()).build(); List<ComponentDto> result = underTest.selectByQuery(dbSession, dbQuery, 0, 10); |