From: Julien Lancelot Date: Mon, 6 Feb 2017 13:47:25 +0000 (+0100) Subject: SONAR-8744 Remove usage of periods 2 to 5 in Daos X-Git-Tag: 6.3-RC1~98 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=249770f0db06b31d1da4bc1f0f418aebffeb7c82;p=sonarqube.git SONAR-8744 Remove usage of periods 2 to 5 in Daos --- diff --git a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java index 236b1459866..7d528160290 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java @@ -40,15 +40,6 @@ public class SnapshotDao implements Dao { return previousLastSnapshot == null || previousLastSnapshot.getCreatedAt() < snapshotTested.getCreatedAt(); } - /** - * @deprecated use {@link #selectByUuid(DbSession, String)} - */ - @Deprecated - @CheckForNull - public SnapshotDto selectById(DbSession session, long id) { - return mapper(session).selectByKey(id); - } - public Optional selectByUuid(DbSession dbSession, String analysisUuid) { List dtos = mapper(dbSession).selectByUuids(Collections.singletonList(analysisUuid)); if (dtos.isEmpty()) { @@ -135,7 +126,6 @@ public class SnapshotDao implements Dao { .orNull(); } - private static SnapshotMapper mapper(DbSession session) { return session.getMapper(SnapshotMapper.class); } diff --git a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDto.java b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDto.java index 635b9118496..e3e0d3be819 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDto.java +++ b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDto.java @@ -30,8 +30,6 @@ public final class SnapshotDto { public static final String STATUS_UNPROCESSED = "U"; public static final String STATUS_PROCESSED = "P"; - private static final String INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5 = "Index should be in range from 1 to 5"; - private Long id; private String uuid; private String componentUuid; @@ -41,24 +39,9 @@ public final class SnapshotDto { private Integer purgeStatus; private Boolean last; private String version; - - private String period1Mode; - private String period2Mode; - private String period3Mode; - private String period4Mode; - private String period5Mode; - - private String period1Param; - private String period2Param; - private String period3Param; - private String period4Param; - private String period5Param; - - private Long period1Date; - private Long period2Date; - private Long period3Date; - private Long period4Date; - private Long period5Date; + private String periodMode; + private String periodParam; + private Long periodDate; public Long getId() { return id; @@ -137,127 +120,88 @@ public final class SnapshotDto { return this; } + public SnapshotDto setPeriodMode(@Nullable String p) { + periodMode = p; + return this; + } + + /** + * @deprecated use {@link #setPeriodMode(String)} instead + */ + @Deprecated public SnapshotDto setPeriodMode(int index, @Nullable String p) { - switch (index) { - case 1: - period1Mode = p; - break; - case 2: - period2Mode = p; - break; - case 3: - period3Mode = p; - break; - case 4: - period4Mode = p; - break; - case 5: - period5Mode = p; - break; - default: - throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5); - } + setPeriodMode(p); return this; } + @CheckForNull + public String getPeriodMode() { + return periodMode; + } + + /** + * @deprecated use {@link #getPeriodMode()} instead + */ + @Deprecated @CheckForNull public String getPeriodMode(int index) { - switch (index) { - case 1: - return period1Mode; - case 2: - return period2Mode; - case 3: - return period3Mode; - case 4: - return period4Mode; - case 5: - return period5Mode; - default: - throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5); - } + return getPeriodMode(); + } + + public SnapshotDto setPeriodParam(@Nullable String p) { + periodParam = p; + return this; } + /** + * @deprecated use {@link #setPeriodParam(String)}} instead + */ + @Deprecated public SnapshotDto setPeriodParam(int index, @Nullable String p) { - switch (index) { - case 1: - period1Param = p; - break; - case 2: - period2Param = p; - break; - case 3: - period3Param = p; - break; - case 4: - period4Param = p; - break; - case 5: - period5Param = p; - break; - default: - throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5); - } + setPeriodParam(p); return this; } + @CheckForNull + public String getPeriodModeParameter() { + return periodParam; + } + + /** + * @deprecated use {@link #getPeriodModeParameter()}} instead + */ + @Deprecated @CheckForNull public String getPeriodModeParameter(int periodIndex) { - switch (periodIndex) { - case 1: - return period1Param; - case 2: - return period2Param; - case 3: - return period3Param; - case 4: - return period4Param; - case 5: - return period5Param; - default: - throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5); - } + return getPeriodModeParameter(); } + public SnapshotDto setPeriodDate(@Nullable Long date) { + periodDate = date; + return this; + } + + /** + * @deprecated use {@link #setPeriodDate(Long)}} instead + */ + @Deprecated public SnapshotDto setPeriodDate(int index, @Nullable Long date) { - switch (index) { - case 1: - period1Date = date; - break; - case 2: - period2Date = date; - break; - case 3: - period3Date = date; - break; - case 4: - period4Date = date; - break; - case 5: - period5Date = date; - break; - default: - throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5); - } + setPeriodDate(date); return this; } + @CheckForNull + public Long getPeriodDate() { + return periodDate; + } + + /** + * @deprecated use {@link #getPeriodDate()}} instead + */ + @Deprecated @CheckForNull public Long getPeriodDate(int periodIndex) { - switch (periodIndex) { - case 1: - return period1Date; - case 2: - return period2Date; - case 3: - return period3Date; - case 4: - return period4Date; - case 5: - return period5Date; - default: - throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5); - } + return getPeriodDate(); } public SnapshotDto setCreatedAt(Long createdAt) { diff --git a/sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java b/sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java index 4abd2972eae..6ec95ddfa95 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java @@ -27,9 +27,6 @@ import org.apache.ibatis.session.RowBounds; public interface SnapshotMapper { - @CheckForNull - SnapshotDto selectByKey(long id); - List selectByUuids(@Param("uuids") List uuids); void insert(SnapshotDto snapshot); diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java index 9e41defc058..2b951e52aea 100644 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java +++ b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java @@ -25,17 +25,12 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; public class MeasureDto { - private static final String INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5 = "Index should be in range from 1 to 5"; private static final int MAX_TEXT_VALUE_LENGTH = 4000; private Double value; private String textValue; private byte[] dataValue; - private Double variation1; - private Double variation2; - private Double variation3; - private Double variation4; - private Double variation5; + private Double variation; private String alertStatus; private String alertText; private String description; @@ -86,47 +81,32 @@ public class MeasureDto { return this; } + @CheckForNull + public Double getVariation() { + return variation; + } + /** * @param index starts at 1 + * @deprecated use {@link #getVariation()} instead */ @CheckForNull + @Deprecated public Double getVariation(int index) { - switch (index) { - case 1: - return variation1; - case 2: - return variation2; - case 3: - return variation3; - case 4: - return variation4; - case 5: - return variation5; - default: - throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5); - } + return getVariation(); + } + + public MeasureDto setVariation(@Nullable Double d) { + variation = d; + return this; } + /** + * @deprecated use {@link #setVariation(Double)} instead + */ + @Deprecated public MeasureDto setVariation(int index, @Nullable Double d) { - switch (index) { - case 1: - variation1 = d; - break; - case 2: - variation2 = d; - break; - case 3: - variation3 = d; - break; - case 4: - variation4 = d; - break; - case 5: - variation5 = d; - break; - default: - throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5); - } + setVariation(d); return this; } @@ -194,11 +174,7 @@ public class MeasureDto { .add("value", value) .add("textValue", textValue) .add("dataValue", dataValue) - .add("variation1", variation1) - .add("variation2", variation2) - .add("variation3", variation3) - .add("variation4", variation4) - .add("variation5", variation5) + .add("variation", variation) .add("alertStatus", alertStatus) .add("alertText", alertText) .add("description", description) diff --git a/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml index 79051c4042e..4e00d6ac39c 100644 --- a/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml @@ -12,21 +12,9 @@ s.purge_status as purgeStatus, s.islast as last, s.version as version, - s.period1_mode as period1Mode, - s.period2_mode as period2Mode, - s.period3_mode as period3Mode, - s.period4_mode as period4Mode, - s.period5_mode as period5Mode, - s.period1_param as period1Param, - s.period2_param as period2Param, - s.period3_param as period3Param, - s.period4_param as period4Param, - s.period5_param as period5Param, - s.period1_date as period1Date, - s.period2_date as period2Date, - s.period3_date as period3Date, - s.period4_date as period4Date, - s.period5_date as period5Date + s.period1_mode as periodMode, + s.period1_param as periodParam, + s.period1_date as periodDate @@ -34,13 +22,6 @@ s.created_at as createdAt - -