aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml')
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml113
1 files changed, 113 insertions, 0 deletions
diff --git a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
new file mode 100644
index 00000000000..7d83e993e05
--- /dev/null
+++ b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
@@ -0,0 +1,113 @@
+<?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.db.measure.MeasureMapper">
+
+ <sql id="measureColumns">
+ pm.id,
+ pm.snapshot_id as snapshotId,
+ pm.value as value,
+ pm.text_value as textValue,
+ pm.alert_status as alertStatus,
+ pm.alert_text as alertText,
+ pm.measure_data as dataValue,
+ pm.variation_value_1 as variation1,
+ pm.variation_value_2 as variation2,
+ pm.variation_value_3 as variation3,
+ pm.variation_value_4 as variation4,
+ pm.variation_value_5 as variation5,
+ p.kee as componentKey,
+ metric.name as metricKey
+ </sql>
+
+ <select id="selectByComponentAndMetric" parameterType="map" resultType="Measure">
+ SELECT metric.name as metric_name,
+ <include refid="measureColumns"/>
+ FROM project_measures pm
+ INNER JOIN snapshots s ON s.id=pm.snapshot_id AND s.islast=${_true}
+ INNER JOIN projects p ON p.id=s.project_id AND p.enabled=${_true}
+ INNER JOIN metrics metric ON metric.id=pm.metric_id
+ <where>
+ AND p.kee = #{componentKey}
+ AND metric.name=#{metricKey}
+ AND pm.rule_id IS NULL
+ AND pm.characteristic_id IS NULL
+ AND pm.person_id IS NULL
+ </where>
+ </select>
+
+ <select id="selectByComponentAndMetrics" parameterType="map" resultType="Measure">
+ SELECT metric.name as metric_name,
+ <include refid="measureColumns"/>
+ FROM project_measures pm
+ INNER JOIN snapshots s ON s.id=pm.snapshot_id AND s.islast=${_true}
+ INNER JOIN projects p ON p.id=s.project_id AND p.enabled=${_true}
+ INNER JOIN metrics metric ON metric.id=pm.metric_id
+ <where>
+ AND p.kee = #{componentKey}
+ AND
+ <foreach item="metricKey" index="index" collection="metricKeys" open="(" separator=" or " close=")">
+ metric.name=#{metricKey}
+ </foreach>
+ AND pm.rule_id IS NULL
+ AND pm.characteristic_id IS NULL
+ AND pm.person_id IS NULL
+ </where>
+ </select>
+
+ <select id="countByComponentAndMetric" parameterType="map" resultType="long">
+ SELECT count(pm.id)
+ FROM project_measures pm
+ INNER JOIN snapshots s ON s.id=pm.snapshot_id AND s.islast=${_true}
+ INNER JOIN metrics metric ON metric.id=pm.metric_id
+ INNER JOIN projects p ON p.id=s.project_id AND p.enabled=${_true}
+ <where>
+ AND p.kee = #{componentKey}
+ AND metric.name = #{metricKey}
+ AND pm.rule_id IS NULL
+ AND pm.characteristic_id IS NULL
+ AND pm.person_id IS NULL
+ </where>
+ </select>
+
+ <select id="selectByComponentUuidAndProjectSnapshotIdAndStatusAndMetricIds" parameterType="map"
+ resultType="org.sonar.db.measure.PastMeasureDto">
+ SELECT pm.id as id, pm.metric_id as metricId, pm.rule_id as ruleId, pm.characteristic_id as characteristicId,
+ pm.person_id as personId, pm.value as value
+ FROM project_measures pm
+ INNER JOIN snapshots s ON s.id=pm.snapshot_id AND s.status=#{status}
+ INNER JOIN projects p ON p.id=s.project_id AND p.enabled=${_true}
+ <where>
+ AND p.uuid = #{componentUuid}
+ AND (s.root_snapshot_id=#{rootSnapshotId} OR s.id=#{rootSnapshotId})
+ AND
+ <foreach item="metricId" index="index" collection="metricIds" open="(" separator=" or " close=")">
+ pm.metric_id=#{metricId}
+ </foreach>
+ </where>
+ </select>
+
+ <insert id="insert" parameterType="Measure" useGeneratedKeys="false">
+ INSERT INTO project_measures (
+ value, metric_id, snapshot_id, rule_id, text_value, project_id, alert_status, alert_text, description,
+ characteristic_id, person_id, variation_value_1, variation_value_2, variation_value_3, variation_value_4,
+ variation_value_5, measure_data)
+ VALUES (
+ #{value, jdbcType=DOUBLE}, #{metricId, jdbcType=INTEGER}, #{snapshotId, jdbcType=INTEGER},
+ #{ruleId, jdbcType=INTEGER}, #{textValue, jdbcType=VARCHAR},
+ #{componentId, jdbcType=INTEGER}, #{alertStatus, jdbcType=VARCHAR}, #{alertText, jdbcType=VARCHAR},
+ #{description, jdbcType=VARCHAR}, #{characteristicId, jdbcType=INTEGER},
+ #{personId, jdbcType=INTEGER}, #{variation1, jdbcType=DOUBLE}, #{variation2, jdbcType=DOUBLE},
+ #{variation3, jdbcType=DOUBLE},
+ #{variation4, jdbcType=DOUBLE}, #{variation5, jdbcType=DOUBLE}, #{dataValue, jdbcType=BINARY}
+ )
+ </insert>
+
+ <select id="selectMetricKeysForSnapshot" parameterType="long" resultType="string">
+ SELECT DISTINCT m.name
+ FROM project_measures pm
+ INNER JOIN metrics m ON m.id=pm.metric_id
+ WHERE pm.snapshot_id=#{snapshotId}
+ </select>
+
+</mapper>