]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8595 remove ComponentDto.organizationKey
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 13 Jan 2017 10:51:25 +0000 (11:51 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 16 Jan 2017 10:38:43 +0000 (11:38 +0100)
remove join on table ORGANIZATIONS in ComponentMapper.xml which was used to populate this field

sonar-db/src/main/java/org/sonar/db/component/ComponentDto.java
sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java

index 32e22ffc61838923970fd685c89c78b7ff219d51..a7c4576e4a788b4d12bd892fbb687793c9fb8e5a 100644 (file)
@@ -49,12 +49,6 @@ public class ComponentDto implements Component {
    */
   private String organizationUuid;
 
-  /**
-   * The key of the organization the components belongs to. Read-only and nullable as it is populated only by some
-   * requests joining on the organizations table.
-   */
-  private String organizationKey;
-
   /**
    * Non-empty and unique functional key
    */
@@ -142,10 +136,6 @@ public class ComponentDto implements Component {
     return this;
   }
 
-  public String getOrganizationKey() {
-    return organizationKey;
-  }
-
   public String uuid() {
     return uuid;
   }
index bb0d24b393e32cde2f89aaacb575f374cc742a70..13fe82a2aa35d45dca0613acfeac96c1fc4dced0 100644 (file)
 
   <select id="selectByKey" parameterType="String" resultType="Component">
     SELECT
-      <include refid="componentColumns"/>,
-      o.kee as organizationKey
+      <include refid="componentColumns"/>
     FROM projects p
-    inner join organizations o on
-      o.uuid = p.organization_uuid
     where
       p.kee=#{key}
   </select>
 
   <select id="selectByUuid" parameterType="String" resultType="Component">
     SELECT
-      <include refid="componentColumns"/>,
-      o.kee as organizationKey
+      <include refid="componentColumns"/>
     FROM projects p
-    inner join organizations o on
-      o.uuid = p.organization_uuid
     where
       p.uuid=#{uuid}
   </select>
 
   <select id="selectByUuids" parameterType="String" resultType="Component">
     select
-      <include refid="componentColumns"/>,
-      o.kee as organizationKey
+      <include refid="componentColumns"/>
     from projects p
-    inner join organizations o on
-      o.uuid = p.organization_uuid
     where
       p.uuid in
       <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
 
   <select id="selectByQuery" resultType="Component">
     select
-      <include refid="componentColumns"/>,
-      o.kee as organizationKey
+      <include refid="componentColumns"/>
     <include refid="sqlSelectByQuery"/>
     ORDER BY LOWER(p.name), p.name, p.id
   </select>
 
   <sql id="sqlSelectByQuery">
     from projects p
-    inner join organizations o on
-      o.uuid = p.organization_uuid
     where
       p.enabled=${_true}
       AND p.copy_component_uuid is null
 
   <select id="selectDescendants" resultType="Component">
     select
-      <include refid="componentColumns"/>,
-      o.kee as organizationKey
+      <include refid="componentColumns"/>
     from projects p
-    inner join organizations o on
-      o.uuid = p.organization_uuid
     <include refid="selectDescendantsJoins"/>
     <where>
       <include refid="selectDescendantsFilters"/>
index a82695097b42b6b28faa5ea70dd0ee9666682627..ef8b746b4978dc5ccbf9367348dd5611739ef71c 100644 (file)
@@ -76,7 +76,6 @@ public class ComponentDaoTest {
     ComponentDto result = underTest.selectByUuid(dbSession, "U1").get();
     assertThat(result).isNotNull();
     assertThat(result.getOrganizationUuid()).isEqualTo("org1");
-    assertThat(result.getOrganizationKey()).isEqualTo("org1_key");
     assertThat(result.uuid()).isEqualTo("U1");
     assertThat(result.getUuidPath()).isEqualTo("uuid_path_of_U1");
     assertThat(result.moduleUuid()).isEqualTo("module_uuid_of_U1");
@@ -154,7 +153,6 @@ public class ComponentDaoTest {
 
     ComponentDto result = optional.get();
     assertThat(result.getOrganizationUuid()).isEqualTo("org1");
-    assertThat(result.getOrganizationKey()).isEqualTo("org1_key");
     assertThat(result.uuid()).isEqualTo("U4");
     assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
     assertThat(result.path()).isEqualTo("path_of_U4");
@@ -256,7 +254,6 @@ public class ComponentDaoTest {
 
     ComponentDto result = results.get(0);
     assertThat(result.getOrganizationUuid()).isEqualTo("org1");
-    assertThat(result.getOrganizationKey()).isEqualTo("org1_key");
     assertThat(result.uuid()).isEqualTo("U4");
     assertThat(result.moduleUuid()).isEqualTo("module_uuid_of_U4");
     assertThat(result.moduleUuidPath()).isEqualTo("module_uuid_path_of_U4");
@@ -784,7 +781,6 @@ public class ComponentDaoTest {
     assertThat(count).isEqualTo(9);
     assertThat(result).extracting(ComponentDto::name).containsExactly("project-2", "project-3", "project-4");
     assertThat(result).extracting(ComponentDto::getOrganizationUuid).containsOnly(organizationDto.getUuid());
-    assertThat(result).extracting(ComponentDto::getOrganizationKey).containsOnly(organizationDto.getKey());
   }
 
   @Test
@@ -1000,7 +996,6 @@ public class ComponentDaoTest {
     List<ComponentDto> components = underTest.selectDescendants(dbSession, dbQuery);
     assertThat(components).extracting("uuid").containsOnly("project-copy-uuid", "subview-uuid");
     assertThat(components).extracting("organizationUuid").containsOnly(organizationDto.getUuid());
-    assertThat(components).extracting("organizationKey").containsOnly(organizationDto.getKey());
   }
 
   private static ComponentTreeQuery.Builder newTreeQuery(String baseUuid) {