diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-02-07 23:18:34 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-02-07 23:18:34 +0100 |
commit | cad21a041f6d4727e3cd92f25aef5f4939ad667a (patch) | |
tree | 63ea17811e46c1bdbea453794c49ccf36c804612 /sonar-core/src | |
parent | 7c9d586b16242d1a8ce143f0eadf6de90ce4b1cb (diff) | |
download | sonarqube-cad21a041f6d4727e3cd92f25aef5f4939ad667a.tar.gz sonarqube-cad21a041f6d4727e3cd92f25aef5f4939ad667a.zip |
SONAR-2756 Purge measures related to quality model requirements
Diffstat (limited to 'sonar-core/src')
5 files changed, 110 insertions, 42 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java index baf8fc38680..fbf5f663e79 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java @@ -179,6 +179,7 @@ public class PurgeDao { mapper.deleteSnapshotSource(snapshotId); mapper.deleteSnapshotViolations(snapshotId); mapper.deleteSnapshotWastedMeasures(snapshotId); + mapper.deleteSnapshotMeasuresOnQualityModelRequirements(snapshotId); mapper.updatePurgeStatusToOne(snapshotId); } diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java index 4aa251a7437..3eb54da5b9b 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java @@ -45,6 +45,8 @@ public interface PurgeMapper { void deleteSnapshotWastedMeasures(long snapshotId); + void deleteSnapshotMeasuresOnQualityModelRequirements(long snapshotId); + void updatePurgeStatusToOne(long snapshotId); void disableResource(long resourceId); diff --git a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml index de31a052238..38ef704ed70 100644 --- a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml @@ -111,10 +111,15 @@ <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> diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml index b85e127f0c2..3ada3c43bdd 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml @@ -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]" @@ -16,33 +23,56 @@ 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> diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml index da5222a4a64..297829d1f12 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml @@ -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]" @@ -16,33 +23,56 @@ 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> |