diff options
Diffstat (limited to 'sonar-plugin-api')
6 files changed, 15 insertions, 87 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureMapper.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureMapper.java deleted file mode 100644 index 42b7afc9b70..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.database.model; - -public interface MeasureMapper { - void insert(MeasureModel measure); - - void update(MeasureModel measure); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java index 68615082e24..33dc4b35b71 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java @@ -1998,7 +1998,7 @@ public final class CoreMetrics { /** * @since 4.5 */ - public static final Metric<String> SQALE_RATING = new Metric.Builder(SQALE_RATING_KEY, "SQALE Rating", Metric.ValueType.RATING) + public static final Metric<Integer> SQALE_RATING = new Metric.Builder(SQALE_RATING_KEY, "SQALE Rating", Metric.ValueType.RATING) .setDomain(DOMAIN_TECHNICAL_DEBT) .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java index c3f56101a18..1901863576a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java @@ -248,26 +248,26 @@ public class Measure<G extends Serializable> implements Serializable { public G value() { switch (getMetric().getType()) { case BOOL: - return (G) Boolean.valueOf(Double.doubleToRawLongBits(value) != 0L); + return value == null ? null : (G) Boolean.valueOf(Double.doubleToRawLongBits(value) != 0L); case INT: case MILLISEC: - return (G) Integer.valueOf(value.intValue()); + case RATING: + return value == null ? null : (G) Integer.valueOf(value.intValue()); case FLOAT: case PERCENT: - case RATING: - return (G) value; + return value == null ? null : (G) value; case STRING: case LEVEL: case DATA: case DISTRIB: - return (G) getData(); + return data == null ? null : (G) data; case WORK_DUR: - return (G) Long.valueOf(value.longValue()); + return value == null ? null : (G) Long.valueOf(value.longValue()); default: if (getMetric().isNumericType()) { - return (G) getValue(); + return value == null ? null : (G) value; } else if (getMetric().isDataType()) { - return (G) getData(); + return data == null ? null : (G) data; } else { throw new UnsupportedOperationException("Unsupported type :" + getMetric().getType()); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java index af8af470cd1..111581d2f75 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java @@ -28,14 +28,7 @@ import org.sonar.api.batch.InstantiationStrategy; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -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.Transient; +import javax.persistence.*; import java.io.Serializable; @@ -72,7 +65,7 @@ public class Metric<G extends Serializable> implements ServerExtension, BatchExt DATA(String.class), LEVEL(Metric.Level.class), DISTRIB(String.class), - RATING(String.class), + RATING(Integer.class), WORK_DUR(Long.class); private final Class valueClass; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java index 13f642867e3..6c507bcb34f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java @@ -26,6 +26,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; +import javax.annotation.CheckForNull; import javax.annotation.Nullable; /** @@ -54,6 +55,7 @@ public class RuleMeasure extends Measure { this.rulePriority = rulePriority; } + @CheckForNull public RuleKey ruleKey() { return ruleKey; } @@ -84,6 +86,7 @@ public class RuleMeasure extends Measure { * @deprecated since 2.14 use {@link #getSeverity()} instead. See SONAR-1829. */ @Deprecated + @CheckForNull public RulePriority getRulePriority() { return rulePriority; } @@ -91,6 +94,7 @@ public class RuleMeasure extends Measure { /** * @since 2.14 */ + @CheckForNull public RulePriority getSeverity() { return rulePriority; } 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 deleted file mode 100644 index 1bf6e453f64..00000000000 --- a/sonar-plugin-api/src/main/resources/org/sonar/api/database/model/MeasureMapper.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - -<mapper namespace="org.sonar.api.database.model.MeasureMapper"> - - <insert id="insert" parameterType="MeasureModel" useGeneratedKeys="false"> - INSERT INTO project_measures ( - value, metric_id, snapshot_id, rule_id, text_value, tendency, - project_id, alert_status, alert_text, url, description, rule_priority, characteristic_id, variation_value_1, - 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}, - #{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} - ) - </insert> - - <update id="update" parameterType="MeasureModel"> - UPDATE project_measures - SET - value = #{value}, - metric_id = #{metricId}, - rule_id = #{ruleId}, - text_value = #{textValue}, - tendency = #{tendency}, - alert_status = #{alertStatus}, - alert_text = #{alertText}, - url = #{url}, - description = #{description}, - rule_priority = #{rulePriority.ordinal}, - characteristic_id = #{characteristicId}, - variation_value_1 = #{variationValue1}, - variation_value_2 = #{variationValue2}, - variation_value_3 = #{variationValue3}, - variation_value_4 = #{variationValue4}, - variation_value_5 = #{variationValue5}, - person_id = #{personId}, - measure_data = #{data} - WHERE id = #{id} - </update> - -</mapper> |