]> source.dussan.org Git - sonarqube.git/commitdiff
Drop unused methods in SnapshotDao
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 23 Jan 2017 22:49:22 +0000 (23:49 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 24 Jan 2017 08:39:43 +0000 (09:39 +0100)
sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java
sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java
sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java

index bde593592a53b274f8d96deae19e0842e7e0cfa7..236b1459866d8212ac0058bbece1733f4bde50ec 100644 (file)
@@ -29,7 +29,6 @@ import javax.annotation.Nullable;
 import org.apache.ibatis.session.RowBounds;
 import org.sonar.db.Dao;
 import org.sonar.db.DbSession;
-import org.sonar.db.RowNotFoundException;
 
 import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.collect.FluentIterable.from;
@@ -50,22 +49,6 @@ public class SnapshotDao implements Dao {
     return mapper(session).selectByKey(id);
   }
 
-  /**
-   * @deprecated use {@link #selectByUuid(DbSession, String)}
-   */
-  @Deprecated
-  public SnapshotDto selectOrFailById(DbSession session, long id) {
-    SnapshotDto value = selectById(session, id);
-    if (value == null) {
-      throw new RowNotFoundException(String.format("Snapshot id does not exist: %d", id));
-    }
-    return value;
-  }
-
-  public List<SnapshotDto> selectByIds(DbSession dbSession, Collection<Long> snapshotIds) {
-    return executeLargeInputs(snapshotIds, mapper(dbSession)::selectByIds);
-  }
-
   public Optional<SnapshotDto> selectByUuid(DbSession dbSession, String analysisUuid) {
     List<SnapshotDto> dtos = mapper(dbSession).selectByUuids(Collections.singletonList(analysisUuid));
     if (dtos.isEmpty()) {
index 56c4b28bd38642da5c8a7a69aff0b63699ae7cc0..4abd2972eae90a6b62df669aa5a6d719c5b83c96 100644 (file)
@@ -30,8 +30,6 @@ public interface SnapshotMapper {
   @CheckForNull
   SnapshotDto selectByKey(long id);
 
-  List<SnapshotDto> selectByIds(@Param("ids") List<Long> ids);
-
   List<SnapshotDto> selectByUuids(@Param("uuids") List<String> uuids);
 
   void insert(SnapshotDto snapshot);
index 1a2fa61ff2e88d65ca69fa1dbea1b06dc058cd7e..79051c4042e5f0e096b5868c14056ebddcacc628 100644 (file)
     where s.id=#{key,jdbcType=BIGINT}
   </select>
 
-  <select id="selectByIds" parameterType="Long" resultType="Snapshot">
-    SELECT
-      <include refid="snapshotColumns" />
-    FROM
-      snapshots s
-    WHERE
-      s.id in
-      <foreach collection="ids" item="id" separator="," open="(" close=")">
-        #{id,jdbcType=BIGINT}
-      </foreach>
-  </select>
-
   <select id="selectByUuids" parameterType="List" resultType="Snapshot">
     SELECT
       <include refid="snapshotColumns"/>
index f7d622198befcfd34b15d3f93125f3051b4e76d5..faf2c5e4d2aa4d62751b53d27ad1122c521cf3bf 100644 (file)
@@ -30,7 +30,6 @@ import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
-import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.organization.OrganizationTesting;
 
 import static com.google.common.collect.Lists.newArrayList;
@@ -103,19 +102,6 @@ public class SnapshotDaoTest {
     assertThat(underTest.selectById(db.getSession(), 999L)).isNull();
   }
 
-  @Test
-  public void test_selectByIds() {
-    OrganizationDto organizationDto = db.organizations().insert();
-    SnapshotDto snapshot1 = componentDb.insertProjectAndSnapshot(newProjectDto(organizationDto));
-    SnapshotDto snapshot2 = componentDb.insertProjectAndSnapshot(newProjectDto(organizationDto));
-    SnapshotDto snapshot3 = componentDb.insertProjectAndSnapshot(newProjectDto(organizationDto));
-
-    List<SnapshotDto> result = underTest.selectByIds(dbSession, newArrayList(snapshot1.getId(), snapshot2.getId(), snapshot3.getId(), 42L));
-
-    assertThat(result).hasSize(3);
-    assertThat(result).extracting("id").containsOnly(snapshot1.getId(), snapshot2.getId(), snapshot3.getId());
-  }
-
   @Test
   public void selectLastSnapshotByRootComponentUuid_returns_absent_when_no_last_snapshot() {
     Optional<SnapshotDto> snapshot = underTest.selectLastAnalysisByRootComponentUuid(db.getSession(), "uuid_123");