diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-02-10 15:23:30 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-02-11 16:43:24 +0100 |
commit | 6136a7a313d5253ee6443eff52d602bac022ad14 (patch) | |
tree | 37b9d87c39f56a75339fadc1b1b59d9e30fbefcd /sonar-plugin-api/src | |
parent | 4d8fbfb4f1be2d2333d1cb051626a29c9442cc6e (diff) | |
download | sonarqube-6136a7a313d5253ee6443eff52d602bac022ad14.tar.gz sonarqube-6136a7a313d5253ee6443eff52d602bac022ad14.zip |
SONAR-5183 timezones - project_measures and manual_measures migrations
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java | 91 | ||||
-rw-r--r-- | sonar-plugin-api/src/main/resources/org/sonar/api/database/model/MeasureMapper.xml | 2 |
2 files changed, 52 insertions, 41 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java index b7ec1155b86..dc5847f7564 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java @@ -27,19 +27,14 @@ import org.sonar.api.database.DatabaseSession; import org.sonar.api.measures.Metric; import org.sonar.api.rules.RulePriority; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import javax.persistence.*; import java.io.UnsupportedEncodingException; import java.util.Date; +import static org.sonar.api.utils.DateUtils.dateToLong; +import static org.sonar.api.utils.DateUtils.longToDate; + /** * This class is the Hibernate model to store a measure in the DB */ @@ -75,9 +70,8 @@ public class MeasureModel implements Cloneable { @Column(name = "description", updatable = true, nullable = true, length = 4000) private String description; - @Temporal(TemporalType.TIMESTAMP) @Column(name = "measure_date", updatable = true, nullable = true) - private Date measureDate; + private Long measureDate; @Column(name = "rule_id", updatable = true, nullable = true) private Integer ruleId; @@ -119,14 +113,6 @@ public class MeasureModel implements Cloneable { @Column(name = "measure_data", updatable = true, nullable = true, length = 167772150) private byte[] data; - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - /** * Creates a measure based on a metric and a double value */ @@ -162,25 +148,19 @@ public class MeasureModel implements Cloneable { public MeasureModel() { } - /** - * @return the measure double value - */ - public Double getValue() { - return value; + public Long getId() { + return id; } - /** - * @return the measure description - */ - public String getDescription() { - return description; + public void setId(Long id) { + this.id = id; } /** - * Sets the measure description + * @return the measure double value */ - public void setDescription(String description) { - this.description = description; + public Double getValue() { + return value; } /** @@ -197,6 +177,20 @@ public class MeasureModel implements Cloneable { } /** + * @return the measure description + */ + public String getDescription() { + return description; + } + + /** + * Sets the measure description + */ + public void setDescription(String description) { + this.description = description; + } + + /** * @return the measure alert level */ public Metric.Level getLevelValue() { @@ -228,13 +222,6 @@ public class MeasureModel implements Cloneable { } /** - * @return whether the measure is about rule - */ - public boolean isRuleMeasure() { - return ruleId != null || rulePriority != null; - } - - /** * Sets the measure tendency * * @return the current object @@ -244,6 +231,13 @@ public class MeasureModel implements Cloneable { return this; } + /** + * @return whether the measure is about rule + */ + public boolean isRuleMeasure() { + return ruleId != null || rulePriority != null; + } + public Integer getMetricId() { return metricId; } @@ -315,7 +309,7 @@ public class MeasureModel implements Cloneable { * @return the date of the measure */ public Date getMeasureDate() { - return measureDate; + return longToDate(measureDate); } /** @@ -324,6 +318,23 @@ public class MeasureModel implements Cloneable { * @return the current object */ public MeasureModel setMeasureDate(Date measureDate) { + this.measureDate = dateToLong(measureDate); + return this; + } + + /** + * @return the date of the measure + */ + public Long getMeasureDateMs() { + return measureDate; + } + + /** + * Sets the date for the measure + * + * @return the current object + */ + public MeasureModel setMeasureDateMs(Long measureDate) { this.measureDate = measureDate; return this; } diff --git a/sonar-plugin-api/src/main/resources/org/sonar/api/database/model/MeasureMapper.xml b/sonar-plugin-api/src/main/resources/org/sonar/api/database/model/MeasureMapper.xml index b9a64536e19..66b00baacae 100644 --- a/sonar-plugin-api/src/main/resources/org/sonar/api/database/model/MeasureMapper.xml +++ b/sonar-plugin-api/src/main/resources/org/sonar/api/database/model/MeasureMapper.xml @@ -10,7 +10,7 @@ variation_value_2, variation_value_3, variation_value_4, variation_value_5, person_id, measure_data) VALUES ( #{value, jdbcType=DOUBLE}, #{metricId, jdbcType=INTEGER}, #{snapshotId, jdbcType=INTEGER}, #{ruleId, jdbcType=INTEGER}, #{textValue, jdbcType=VARCHAR}, #{tendency, jdbcType=INTEGER}, - #{measureDate, jdbcType=TIMESTAMP}, #{projectId, jdbcType=INTEGER}, #{alertStatus, jdbcType=VARCHAR}, #{alertText, jdbcType=VARCHAR}, + #{measureDateMs, jdbcType=BIGINT}, #{projectId, jdbcType=INTEGER}, #{alertStatus, jdbcType=VARCHAR}, #{alertText, jdbcType=VARCHAR}, #{url, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, #{rulePriority.ordinal, jdbcType=INTEGER}, #{characteristicId, jdbcType=INTEGER}, #{variationValue1, jdbcType=DOUBLE}, #{variationValue2, jdbcType=DOUBLE}, #{variationValue3, jdbcType=DOUBLE}, #{variationValue4, jdbcType=DOUBLE}, #{variationValue5, jdbcType=DOUBLE}, #{personId, jdbcType=INTEGER}, #{data} ) |