]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2756 Purge measures related to quality model requirements
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 7 Feb 2012 22:18:34 +0000 (23:18 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 7 Feb 2012 22:18:34 +0000 (23:18 +0100)
sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml

index baf8fc3868096adcf67c3db9462966c94961fa31..fbf5f663e7900852801ddeb554d2b9f3ac05c856 100644 (file)
@@ -179,6 +179,7 @@ public class PurgeDao {
     mapper.deleteSnapshotSource(snapshotId);
     mapper.deleteSnapshotViolations(snapshotId);
     mapper.deleteSnapshotWastedMeasures(snapshotId);
+    mapper.deleteSnapshotMeasuresOnQualityModelRequirements(snapshotId);
     mapper.updatePurgeStatusToOne(snapshotId);
   }
 
index 4aa251a7437ae420d241ab35f5b555205623f9a2..3eb54da5b9b9184b80d58f803ec94627ec6b7986 100644 (file)
@@ -45,6 +45,8 @@ public interface PurgeMapper {
 
   void deleteSnapshotWastedMeasures(long snapshotId);
 
+  void deleteSnapshotMeasuresOnQualityModelRequirements(long snapshotId);
+
   void updatePurgeStatusToOne(long snapshotId);
 
   void disableResource(long resourceId);
index de31a05223849d5269f4b7917b1aea18d07eb1af..38ef704ed70f0a9912bc2bdc808488705e70ae07 100644 (file)
 
   <delete id="deleteSnapshotWastedMeasures" parameterType="long">
     delete from project_measures where snapshot_id=#{id} and
-    (characteristic_id is not null or rule_id is not null or metric_id in (select id from metrics where
+    (rule_id is not null or metric_id in (select id from metrics where
     delete_historical_data=${_true}))
   </delete>
 
+  <delete id="deleteSnapshotMeasuresOnQualityModelRequirements" parameterType="long">
+      delete from project_measures where snapshot_id=#{id} and
+      characteristic_id in (select id from characteristics where rule_id is not null)
+    </delete>
+
   <update id="updatePurgeStatusToOne" parameterType="long">
     update snapshots set purge_status = 1 where id = #{id}
   </update>
index b85e127f0c2d501599577666efbb0eeacd4ae9b6..3ada3c43bdd1c4a2a8450674940018bfa70e793e 100644 (file)
@@ -1,13 +1,20 @@
 <dataset>
 
   <metrics id="1" delete_historical_data="[null]"
-           name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]" worst_value="[null]" optimized_best_value="[null]" best_value="[null]"
+           name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]"
+           worst_value="[null]" optimized_best_value="[null]" best_value="[null]"
            direction="0" hidden="[false]"/>
 
   <metrics id="2" delete_historical_data="[true]"
-           name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]" worst_value="0" optimized_best_value="[true]" best_value="100"
+           name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]"
+           worst_value="0" optimized_best_value="[true]" best_value="100"
            direction="1" hidden="[false]"/>
 
+  <characteristics id="1" kee="M1C1" name="M1C1" quality_model_id="1" rule_id="[null]" characteristic_order="1"
+                   depth="1" description="[null]" enabled="true"/>
+  <characteristics id="2" kee="M1C2" name="M1C2" quality_model_id="1" rule_id="333" characteristic_order="1"
+                   depth="2" description="[null]" enabled="true"/>
+
   <snapshots id="1"
              project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
              status="P" islast="[true]" purge_status="[null]"
              period3_mode="[null]" period3_param="[null]" period3_date="[null]"
              period4_mode="[null]" period4_param="[null]" period4_date="[null]"
              period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/>
+             depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00"
+             build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/>
 
   <!-- do not delete standard measure -->
   <project_measures ID="1" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" METRIC_ID="1"
-                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]"
-                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0" rules_category_id="[null]"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
                     committer="[null]"
-                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>
 
   <!-- delete measure on rule -->
-  <!--<project_measures ID="2" project_id="1" SNAPSHOT_ID="1" RULE_ID="33" characteristic_id="[null]" METRIC_ID="1" -->
-                    <!--url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]"-->
-                    <!--variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0" rules_category_id="[null]"-->
-                    <!--committer="[null]"-->
-                    <!--text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>-->
-
-  <!-- delete measure on quality model characteristic -->
-  <!--<project_measures ID="3" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="22" METRIC_ID="1" -->
-                    <!--url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]"-->
-                    <!--variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0" rules_category_id="[null]"-->
-                    <!--committer="[null]"-->
-                    <!--text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>-->
+  <!--<project_measures ID="2" project_id="1" SNAPSHOT_ID="1" RULE_ID="33" characteristic_id="[null]" METRIC_ID="1"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
+                    committer="[null]"
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>-->
+
+  <!-- do not delete measure on quality model characteristic -->
+  <project_measures ID="3" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="1" METRIC_ID="1"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
+                    committer="[null]"
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>
+
+  <!-- delete measure on quality model requirement -->
+  <!--<project_measures ID="4" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="2" METRIC_ID="1"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
+                    committer="[null]"
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>-->
 
   <!-- delete measure on metrics that are flagged with delete_historical_data=true -->
-  <!--<project_measures ID="4" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" METRIC_ID="2"-->
-                    <!--url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]"-->
-                    <!--variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0" rules_category_id="[null]"-->
-                    <!--committer="[null]"-->
-                    <!--text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>-->
+  <!--<project_measures ID="5" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" METRIC_ID="2"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
+                    committer="[null]"
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>-->
 </dataset>
index da5222a4a6421bb36ba90881ee1e5cefc4369ace..297829d1f12f1f5257b67a78e9cf5c12040a5bff 100644 (file)
@@ -1,13 +1,20 @@
 <dataset>
 
   <metrics id="1" delete_historical_data="[null]"
-           name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]" worst_value="[null]" optimized_best_value="[null]" best_value="[null]"
+           name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]"
+           worst_value="[null]" optimized_best_value="[null]" best_value="[null]"
            direction="0" hidden="[false]"/>
 
   <metrics id="2" delete_historical_data="[true]"
-           name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]" worst_value="0" optimized_best_value="[true]" best_value="100"
+           name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]"
+           worst_value="0" optimized_best_value="[true]" best_value="100"
            direction="1" hidden="[false]"/>
 
+  <characteristics id="1" kee="M1C1" name="M1C1" quality_model_id="1" rule_id="[null]" characteristic_order="1"
+                   depth="1" description="[null]" enabled="true"/>
+  <characteristics id="2" kee="M1C2" name="M1C2" quality_model_id="1" rule_id="333" characteristic_order="1"
+                   depth="2" description="[null]" enabled="true"/>
+
   <snapshots id="1"
              project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
              status="P" islast="[true]" purge_status="[null]"
              period3_mode="[null]" period3_param="[null]" period3_date="[null]"
              period4_mode="[null]" period4_param="[null]" period4_date="[null]"
              period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/>
+             depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00"
+             build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/>
 
   <!-- do not delete standard measure -->
   <project_measures ID="1" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" METRIC_ID="1"
-                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]"
-                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0" rules_category_id="[null]"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
                     committer="[null]"
-                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>
 
   <!-- delete measure on rule -->
   <project_measures ID="2" project_id="1" SNAPSHOT_ID="1" RULE_ID="33" characteristic_id="[null]" METRIC_ID="1"
-                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]"
-                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0" rules_category_id="[null]"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
+                    committer="[null]"
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>
+
+  <!-- do not delete measure on quality model characteristic -->
+  <project_measures ID="3" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="1" METRIC_ID="1"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
                     committer="[null]"
-                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>
 
-  <!-- delete measure on quality model characteristic -->
-  <project_measures ID="3" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="22" METRIC_ID="1"
-                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]"
-                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0" rules_category_id="[null]"
+  <!-- delete measure on quality model requirement -->
+  <project_measures ID="4" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="2" METRIC_ID="1"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
                     committer="[null]"
-                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>
 
   <!-- delete measure on metrics that are flagged with delete_historical_data=true -->
-  <project_measures ID="4" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" METRIC_ID="2"
-                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]"
-                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0" rules_category_id="[null]"
+  <project_measures ID="5" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" METRIC_ID="2"
+                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
+                    rules_category_id="[null]"
                     committer="[null]"
-                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>
+                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+                    description="[null]"/>
 </dataset>