]> source.dussan.org Git - sonarqube.git/commitdiff
Remove dead code related to ComponentDao
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 18 Jan 2017 16:48:35 +0000 (17:48 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 18 Jan 2017 19:47:59 +0000 (20:47 +0100)
sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java
sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java
sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java

index a1f114c441bd5bcebea42432169cc01306a69e25..8ec27d1c2a6c05643b9920d3a8dc4e8a7c5bd48e 100644 (file)
@@ -138,18 +138,6 @@ public class ComponentDao implements Dao {
     return mapper(session).selectComponentsHavingSameKeyOrderedById(key);
   }
 
-  /**
-   * Optional parent. It is absent if specified component is root.
-   */
-  public Optional<ComponentDto> selectParent(DbSession dbSession, ComponentDto component) {
-    if (component.isRoot()) {
-      return Optional.absent();
-    }
-    List<String> path = component.getUuidPathAsList();
-    String parentUuid = path.get(path.size() - 1);
-    return Optional.of(mapper(dbSession).selectByUuid(parentUuid));
-  }
-
   /**
    * List of ancestors, ordered from root to parent. The list is empty
    * if the component is a tree root. Disabled components are excluded by design
@@ -282,10 +270,6 @@ public class ComponentDao implements Dao {
     mapper(session).insert(item);
   }
 
-  public void insertBatch(DbSession session, ComponentDto item) {
-    mapper(session).insertBatch(item);
-  }
-
   public void insert(DbSession session, Collection<ComponentDto> items) {
     for (ComponentDto item : items) {
       insert(session, item);
index f57fc3384c1f2dc3a9421b521cd5206c53f65441..7b2e26eab243fadf0b0ee2d011f45589c2a34ecb 100644 (file)
@@ -120,8 +120,6 @@ public interface ComponentMapper {
 
   void insert(ComponentDto componentDto);
 
-  void insertBatch(ComponentDto componentDto);
-
   void update(ComponentUpdateDto component);
 
   void updateBEnabledToFalse(@Param("uuids") List<String> uuids);
index 8bbb25cad007bd435db3ce96fb06bf58b27f572c..a9d12f018718cb90bdbc712c1d59d4ad0f8335aa 100644 (file)
     where p.enabled=${_true}
   </select>
 
-  <sql id="insertSql">
+  <insert id="insert" parameterType="Component" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
     INSERT INTO projects (
     organization_uuid,
     kee,
     null,
     null
     )
-  </sql>
-
-  <insert id="insert" parameterType="Component" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
-    <include refid="insertSql"/>
-  </insert>
-
-  <insert id="insertBatch" parameterType="Component" useGeneratedKeys="false">
-    <include refid="insertSql"/>
   </insert>
 
   <update id="update" parameterType="org.sonar.db.component.ComponentUpdateDto" useGeneratedKeys="false">
index ef8b746b4978dc5ccbf9367348dd5611739ef71c..039891ac0a16142ff9361214c16eecd83602cb82 100644 (file)
@@ -597,42 +597,6 @@ public class ComponentDaoTest {
     db.assertDbUnit(getClass(), "insert-result.xml", "projects");
   }
 
-  @Test
-  public void insertBatch() {
-    try (DbSession batchSession = db.myBatis().openSession(true)) {
-      db.prepareDbUnit(getClass(), "empty.xml");
-
-      ComponentDto componentDto = new ComponentDto()
-        .setOrganizationUuid("org1")
-        .setUuid("GHIJ")
-        .setUuidPath("ABCD.EFGH.GHIJ.")
-        .setProjectUuid("ABCD")
-        .setModuleUuid("EFGH")
-        .setModuleUuidPath(".ABCD.EFGH.")
-        .setKey("org.struts:struts-core:src/org/struts/RequestContext.java")
-        .setDeprecatedKey("org.struts:struts-core:src/org/struts/RequestContext.java")
-        .setName("RequestContext.java")
-        .setLongName("org.struts.RequestContext")
-        .setQualifier("FIL")
-        .setScope("FIL")
-        .setLanguage("java")
-        .setDescription("description")
-        .setPath("src/org/struts/RequestContext.java")
-        .setRootUuid("uuid_3")
-        .setCopyComponentUuid("uuid_5")
-        .setDeveloperUuid("uuid_7")
-        .setEnabled(true)
-        .setCreatedAt(DateUtils.parseDate("2014-06-18"))
-        .setAuthorizationUpdatedAt(123456789L);
-
-      underTest.insertBatch(batchSession, componentDto);
-      batchSession.commit();
-
-      assertThat(componentDto.getId()).isNull();
-      db.assertDbUnit(getClass(), "insert-result.xml", "projects");
-    }
-  }
-
   @Test
   public void insert_disabled_component() {
     db.prepareDbUnit(getClass(), "empty.xml");
@@ -845,22 +809,6 @@ public class ComponentDaoTest {
       .doesNotContain(cLang.getId());
   }
 
-  @Test
-  public void selectParent() {
-    // project -> module -> file
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID);
-    componentDb.insertProjectAndSnapshot(project);
-    ComponentDto module = newModuleDto(MODULE_UUID, project);
-    componentDb.insertComponent(module);
-    ComponentDto file = newFileDto(module, null, FILE_1_UUID);
-    componentDb.insertComponent(file);
-    db.commit();
-
-    assertThat(underTest.selectParent(dbSession, project)).isAbsent();
-    assertThat(underTest.selectParent(dbSession, module).get().uuid()).isEqualTo(PROJECT_UUID);
-    assertThat(underTest.selectParent(dbSession, file).get().uuid()).isEqualTo(MODULE_UUID);
-  }
-
   @Test
   public void selectAncestors() {
     // organization