<dataset>
- <metrics id="1" NAME="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" NAME="review_note" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" NAME="review_note" 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"/>
<rules id="1" name="foo" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
- <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
<!-- project -->
<rules id="1" name="foo" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
- <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
<!-- project -->
<rules id="1" name="foo" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
- <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
<!-- project -->
<rules id="1" name="foo" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
- <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
<!-- project -->
<rules id="1" name="foo" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
- <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
</dataset>
\ No newline at end of file
<rules id="1" name="foo" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
- <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
<!-- project -->
<rules id="1" name="foo" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
- <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
<!-- project -->
<rules id="1" name="foo" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
- <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
<!-- project -->
<dataset>
- <metrics id="1" NAME="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" NAME="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" NAME="coverage" 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"/>
<projects long_name="[null]" id="1" scope="PRJ" kee="group:artifact" qualifier="TRK" name="my project"
<dataset>
- <metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" 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"/>
<dataset>
- <metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" 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"/>
<projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
<dataset>
- <metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" 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"/>
<projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
<dataset>
- <metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" 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"/>
<projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
<dataset>
- <metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" 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"/>
<projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
<dataset>
- <metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" 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"/>
<projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
<rules id="1" name="foo" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
- <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
- <metrics id="2" name="foo" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="2" name="foo" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
- <metrics id="3" name="bar" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="3" name="bar" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
- <metrics id="4" name="baz" val_type="INT" description="[null]" domain="[null]"
+ <metrics delete_historical_data="[null]" id="4" name="baz" val_type="INT" description="[null]" domain="[null]"
short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
<projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="[null]"
purgeSnapshot(snapshotId, purgeMapper);
}
});
+
// must be executed at the end for reentrance
purgeSnapshot(projectSnapshotId, purgeMapper);
}
mapper.deleteSnapshotDuplications(snapshotId);
mapper.deleteSnapshotSource(snapshotId);
mapper.deleteSnapshotViolations(snapshotId);
- mapper.deleteSnapshotRuleMeasures(snapshotId);
- mapper.deleteSnapshotCharacteristicMeasures(snapshotId);
- // TODO SONAR-2061 delete wasted measures (!metric.keepHistory)
+ mapper.deleteSnapshotWastedMeasures(snapshotId);
mapper.updatePurgeStatusToOne(snapshotId);
- return 8; // nb of SQL requests
+ return 7; // nb of SQL requests
}
@VisibleForTesting
void deleteSnapshotViolations(long snapshotId);
- void deleteSnapshotRuleMeasures(long snapshotId);
-
- void deleteSnapshotCharacteristicMeasures(long snapshotId);
+ void deleteSnapshotWastedMeasures(long snapshotId);
void updatePurgeStatusToOne(long snapshotId);
public final static int VERSION_UNKNOWN = -1;
- public static final int LAST_VERSION = 253;
+ public static final int LAST_VERSION = 254;
public static final int VERSION_2_13 = 241;
public final static String TABLE_NAME = "schema_migrations";
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('251');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('252');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('253');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('254');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
"WORST_VALUE" DECIMAL(30,20),
"BEST_VALUE" DECIMAL(30,20),
"OPTIMIZED_BEST_VALUE" BOOLEAN,
- "HIDDEN" BOOLEAN
+ "HIDDEN" BOOLEAN,
+ "DELETE_HISTORICAL_DATA" BOOLEAN
);
CREATE TABLE "LOADED_TEMPLATES" (
delete from snapshots where id=#{id}
</delete>
- <delete id="deleteSnapshotRuleMeasures" parameterType="long">
- delete from project_measures where snapshot_id=#{id} and rule_id is not null
- </delete>
-
- <delete id="deleteSnapshotCharacteristicMeasures" parameterType="long">
- delete from project_measures where snapshot_id=#{id} and characteristic_id is not null
+ <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 delete_historical_data=${_true}))
</delete>
<update id="updatePurgeStatusToOne" parameterType="long">
/**
* Test that all related data is purged.
*/
-
@Test
public void shouldPurgeSnapshot() {
setupData("shouldPurgeSnapshot");
"snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources", "duplications_index", "events", "dependencies", "reviews");
}
+ @Test
+ public void shouldDeleteWastedMeasuresWhenPurgingSnapshot() {
+ setupData("shouldDeleteWastedMeasuresWhenPurgingSnapshot");
+
+ SqlSession session = getMyBatis().openSession();
+ try {
+ // this method does not commit and close the session
+ dao.purgeSnapshot(1L, session.getMapper(PurgeMapper.class));
+ session.commit();
+
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ checkTables("shouldDeleteWastedMeasuresWhenPurgingSnapshot", "project_measures");
+ }
+
+ @Test
+ public void shouldCloseReviewWhenDisablingResource() {
+ setupData("shouldCloseReviewWhenDisablingResource");
+
+ SqlSession session = getMyBatis().openSession();
+ try {
+ // this method does not commit and close the session
+ dao.disableResource(1L, session.getMapper(PurgeMapper.class));
+ session.commit();
+
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ checkTables("shouldCloseReviewWhenDisablingResource", /* excluded column */new String[]{"updated_at"}, "reviews");
+ }
+
+
@Test
public void shouldPurgeProject() {
setupData("shouldPurgeProject");
<dataset>
- <metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" 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"/>
- <metrics id="3" name="disabled" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="3" name="disabled" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
enabled="false" worst_value="0" optimized_best_value="true" best_value="100" direction="1" hidden="false"/>
</dataset>
\ No newline at end of file
<dataset>
- <metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="1" 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" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="2" 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"/>
- <metrics id="3" name="disabled" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+ <metrics delete_historical_data="[null]" id="3" name="disabled" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
enabled="false" worst_value="0" optimized_best_value="true" best_value="100" direction="1" hidden="false"/>
</dataset>
\ No newline at end of file
--- /dev/null
+<!--
+
+Changes:
+* review.status=CLOSED
+
+Note that the column updated_at has been removed because it's excluded from DBUnit comparison.
+-->
+
+<dataset>
+
+ <reviews id="1" project_id="1" resource_id="1" status="CLOSED"
+ rule_failure_permanent_id="1" resolution="[null]" created_at="[null]" resource_line="200" severity="BLOCKER"
+ user_id="300" assignee_id="300" rule_id="500" manual_violation="[true]" manual_severity="[false]" title="[null]"/>
+
+</dataset>
\ No newline at end of file
--- /dev/null
+<dataset>
+
+ <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]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[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]"/>
+
+ <reviews id="1" project_id="1" resource_id="1" status="OPEN"
+ rule_failure_permanent_id="1" resolution="[null]" created_at="[null]" updated_at="[null]" resource_line="200" severity="BLOCKER"
+ user_id="300" assignee_id="300" rule_id="500" manual_violation="[true]" manual_severity="[false]" title="[null]"/>
+</dataset>
\ No newline at end of file
--- /dev/null
+<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]"
+ 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"
+ direction="1" hidden="false"/>
+
+ <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]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[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]"/>
+
+ <!-- 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]"
+ 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]"-->
+ <!--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]"-->
+ <!--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]"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>-->
+</dataset>
\ No newline at end of file
--- /dev/null
+<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]"
+ 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"
+ direction="1" hidden="false"/>
+
+ <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]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[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]"/>
+
+ <!-- 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]"
+ 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]"
+ 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]"
+ 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]"
+ text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]"/>
+</dataset>
\ No newline at end of file
.setDomain(DOMAIN_TESTS)
.setFormula(new SumChildValuesFormula(false))
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover";
*/
public static final Metric COVERAGE_LINE_HITS_DATA = new Metric.Builder(COVERAGE_LINE_HITS_DATA_KEY, "Coverage hits by line", Metric.ValueType.DATA)
.setDomain(DOMAIN_TESTS)
+ .setDeleteHistoricalData(true)
.create();
public static final String CONDITIONS_TO_COVER_KEY = "conditions_to_cover";
.setDomain(DOMAIN_TESTS)
.setFormula(new SumChildValuesFormula(false))
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
public static final String NEW_CONDITIONS_TO_COVER_KEY = "new_conditions_to_cover";
@Deprecated
public static final Metric BRANCH_COVERAGE_HITS_DATA = new Metric.Builder(BRANCH_COVERAGE_HITS_DATA_KEY, "Branch coverage hits", Metric.ValueType.DATA)
.setDomain(DOMAIN_TESTS)
+ .setDeleteHistoricalData(true)
.create();
public static final String CONDITIONS_BY_LINE_KEY = "conditions_by_line";
*/
public static final Metric CONDITIONS_BY_LINE = new Metric.Builder(CONDITIONS_BY_LINE_KEY, "Conditions by line", Metric.ValueType.DATA)
.setDomain(DOMAIN_TESTS)
+ .setDeleteHistoricalData(true)
.create();
public static final String COVERED_CONDITIONS_BY_LINE_KEY = "covered_conditions_by_line";
*/
public static final Metric COVERED_CONDITIONS_BY_LINE = new Metric.Builder(COVERED_CONDITIONS_BY_LINE_KEY, "Covered conditions by line", Metric.ValueType.DATA)
.setDomain(DOMAIN_TESTS)
+ .setDeleteHistoricalData(true)
.create();
.setQualitative(false)
.setFormula(new SumChildValuesFormula(false))
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
/**
.setDirection(Metric.DIRECTION_NONE)
.setQualitative(false)
.setDomain(DOMAIN_INTEGRATION_TESTS)
+ .setDeleteHistoricalData(true)
.create();
/**
.setDomain(DOMAIN_INTEGRATION_TESTS)
.setFormula(new SumChildValuesFormula(false))
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
/**
*/
public static final Metric IT_CONDITIONS_BY_LINE = new Metric.Builder(IT_CONDITIONS_BY_LINE_KEY, "IT Branches by Line", Metric.ValueType.DATA)
.setDomain(DOMAIN_INTEGRATION_TESTS)
+ .setDeleteHistoricalData(true)
.create();
/**
*/
public static final Metric IT_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(IT_COVERED_CONDITIONS_BY_LINE_KEY, "IT Covered Branches by Line", Metric.ValueType.DATA)
.setDomain(DOMAIN_INTEGRATION_TESTS)
+ .setDeleteHistoricalData(true)
.create();
.setDirection(Metric.DIRECTION_NONE)
.setQualitative(false)
.setDomain(DOMAIN_DUPLICATION)
+ .setDeleteHistoricalData(true)
.create();
.setQualitative(false)
.setDomain(DOMAIN_DESIGN)
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
public static final String LCOM4_DISTRIBUTION_KEY = "lcom4_distribution";
.setDirection(Metric.DIRECTION_NONE)
.setQualitative(false)
.setDomain(DOMAIN_DESIGN)
+ .setDeleteHistoricalData(true)
.create();
public static final String PACKAGE_CYCLES_KEY = "package_cycles";
.setDomain(DOMAIN_DESIGN)
.setFormula(new SumChildValuesFormula(false))
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
public static final String FILE_CYCLES_KEY = "file_cycles";
.setQualitative(true)
.setDomain(DOMAIN_DESIGN)
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
public static final String FILE_TANGLE_INDEX_KEY = "file_tangle_index";
.setQualitative(true)
.setDomain(DOMAIN_DESIGN)
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
public static final String FILE_TANGLES_KEY = "file_tangles";
.setQualitative(false)
.setDomain(DOMAIN_DESIGN)
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
public static final String FILE_FEEDBACK_EDGES_KEY = "file_feedback_edges";
.setQualitative(false)
.setDomain(DOMAIN_DESIGN)
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
public static final String FILE_EDGES_WEIGHT_KEY = "file_edges_weight";
.setQualitative(false)
.setDomain(DOMAIN_DESIGN)
.setHidden(true)
+ .setDeleteHistoricalData(true)
.create();
@Column(name = "hidden", updatable = true, nullable = true)
private Boolean hidden = Boolean.FALSE;
+ @Column(name = "delete_historical_data", updatable = true, nullable = true)
+ private Boolean deleteHistoricalData;
+
+ private Metric(Builder builder) {
+ this.key = builder.key;
+ this.name = builder.name;
+ this.description = builder.description;
+ this.type = builder.type;
+ this.direction = builder.direction;
+ this.domain = builder.domain;
+ this.qualitative = builder.qualitative;
+ this.userManaged = Boolean.FALSE;
+ this.enabled = Boolean.TRUE;
+ this.worstValue = builder.worstValue;
+ this.optimizedBestValue = builder.optimizedBestValue;
+ this.bestValue = builder.bestValue;
+ this.hidden = builder.hidden;
+ this.formula = builder.formula;
+ this.userManaged = builder.userManaged;
+ this.deleteHistoricalData = builder.deleteHistoricalData;
+ }
+
+
/**
* Creates an empty metric
*
}
}
- private Metric(String key, String name, ValueType type, String description, Integer direction, String domain, Boolean qualitative, Double worstValue, Double bestValue,
- Boolean optimizedBestValue, Boolean hidden, Formula formula, boolean userManaged) {
- this.key = key;
- this.name = name;
- this.description = description;
- this.type = type;
- this.direction = direction;
- this.domain = domain;
- this.qualitative = qualitative;
- this.userManaged = Boolean.FALSE;
- this.enabled = Boolean.TRUE;
- this.worstValue = worstValue;
- this.optimizedBestValue = optimizedBestValue;
- this.bestValue = bestValue;
- this.hidden = hidden;
- this.formula = formula;
- this.userManaged = userManaged;
- }
-
/**
* For internal use only
*/
*/
public boolean isNumericType() {
return ValueType.INT.equals(type)
- || ValueType.FLOAT.equals(type)
- || ValueType.PERCENT.equals(type)
- || ValueType.BOOL.equals(type)
- || ValueType.MILLISEC.equals(type)
- || ValueType.RATING.equals(type);
+ || ValueType.FLOAT.equals(type)
+ || ValueType.PERCENT.equals(type)
+ || ValueType.BOOL.equals(type)
+ || ValueType.MILLISEC.equals(type)
+ || ValueType.RATING.equals(type);
}
/**
return this;
}
+ public Boolean getDeleteHistoricalData() {
+ return deleteHistoricalData;
+ }
+
+ private Metric setDeleteHistoricalData(Boolean b) {
+ this.deleteHistoricalData = b;
+ return this;
+ }
+
@Override
public int hashCode() {
return key.hashCode();
this.userManaged = with.userManaged;
this.origin = with.origin;
this.hidden = with.hidden;
+ this.deleteHistoricalData = with.deleteHistoricalData;
return this;
}
private boolean optimizedBestValue = false;
private boolean hidden = false;
private boolean userManaged = false;
+ private boolean deleteHistoricalData = false;
/**
* @param key the metric key, should be unique among all metrics
return this;
}
+
+ public boolean isDeleteHistoricalData() {
+ return deleteHistoricalData;
+ }
+
+ /**
+ * By default, historical data are kept, but they can be automatically deleted to minimize database volume.
+ *
+ * @since 2.14
+ */
+ public Builder setDeleteHistoricalData(boolean b) {
+ this.deleteHistoricalData = b;
+ return this;
+ }
+
public Metric create() {
if (ValueType.PERCENT.equals(this.type)) {
this.bestValue = (direction == DIRECTION_BETTER ? 100.0 : 0.0);
this.worstValue = (direction == DIRECTION_BETTER ? 0.0 : 100.0);
}
- return new Metric(key, name, type, description, direction, domain, qualitative, worstValue, bestValue, optimizedBestValue, hidden, formula, userManaged);
+ return new Metric(this);
}
}
}
--- /dev/null
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2012 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+
+#
+# Sonar 2.14
+#
+class AddMetricsDeleteHistoricalData < ActiveRecord::Migration
+
+ def self.up
+ add_column 'metrics', 'delete_historical_data', :boolean, :null => true
+ Metric.reset_column_information
+ end
+
+end
<dataset>
- <metrics id="1" name="lines" val_type="FLOAT" description="Lines" domain="Size"
+ <metrics delete_historical_data="[null]" id="1" name="lines" val_type="FLOAT" description="Lines" domain="Size"
short_name="Lines" qualitative="false" user_managed="false" enabled="true" origin="JAV" worst_value="[null]"
optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
- <metrics id="2" name="coverage" val_type="PERCENT" description="Coverage" domain="Tests"
+ <metrics delete_historical_data="[null]" id="2" name="coverage" val_type="PERCENT" description="Coverage" domain="Tests"
short_name="Coverage" qualitative="true" user_managed="false" enabled="true" origin="JAV" worst_value="[null]"
optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
- <metrics id="3" name="duplicated_lines" val_type="INT" description="Duplicated lines" domain="Duplications"
+ <metrics delete_historical_data="[null]" id="3" name="duplicated_lines" val_type="INT" description="Duplicated lines" domain="Duplications"
short_name="Duplications" qualitative="false" user_managed="false" enabled="true" origin="JAV" worst_value="[null]"
optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
<dataset>
- <metrics id="1" name="key1" val_type="INT" description="description" domain="domain"
+ <metrics delete_historical_data="[null]" id="1" name="key1" val_type="INT" description="description" domain="domain"
short_name="name1" qualitative="false" user_managed="false" enabled="true" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false" />
- <metrics id="2" name="disabledkey2" val_type="INT" description="description" domain="domain"
+ <metrics delete_historical_data="[null]" id="2" name="disabledkey2" val_type="INT" description="description" domain="domain"
short_name="name2" qualitative="false" user_managed="false" enabled="false" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
<rules_profiles id="1" version="1" used_profile="true" name="profile1" default_profile="true" provided="true" language="JAV" enabled="true"/>
<dataset>
- <metrics id="1" name="key1" val_type="INT" description="description" domain="domain"
+ <metrics delete_historical_data="[null]" id="1" name="key1" val_type="INT" description="description" domain="domain"
short_name="name1" qualitative="false" user_managed="false" enabled="true" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
- <metrics id="2" name="disabledkey2" val_type="INT" description="description" domain="domain"
+ <metrics delete_historical_data="[null]" id="2" name="disabledkey2" val_type="INT" description="description" domain="domain"
short_name="name2" qualitative="false" user_managed="false" enabled="false" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
<dataset>
- <metrics id="1" name="deprecated" val_type="INT" description="description" domain="domain"
+ <metrics delete_historical_data="[null]" id="1" name="deprecated" val_type="INT" description="description" domain="domain"
short_name="short name" qualitative="false" user_managed="false" enabled="true" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
</dataset>
\ No newline at end of file
<dataset>
- <metrics id="1" name="key1" val_type="INT" description="description" domain="domain"
+ <metrics delete_historical_data="[null]" id="1" name="key1" val_type="INT" description="description" domain="domain"
short_name="short name" qualitative="false" user_managed="false" enabled="true" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
<!--New metrics -->
- <metrics id="2" name="new1" val_type="FLOAT" description="desc1" domain="domain1"
+ <metrics delete_historical_data="[null]" id="2" name="new1" val_type="FLOAT" description="desc1" domain="domain1"
short_name="short1" qualitative="true" user_managed="false" enabled="true" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
- <metrics id="3" name="new2" val_type="FLOAT" description="desc2" domain="domain2"
+ <metrics delete_historical_data="[null]" id="3" name="new2" val_type="FLOAT" description="desc2" domain="domain2"
short_name="short2" qualitative="true" user_managed="false" enabled="true" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
</dataset>
\ No newline at end of file
<dataset>
- <metrics id="1" name="key1" val_type="INT" description="description" domain="domain"
+ <metrics delete_historical_data="[null]" id="1" name="key1" val_type="INT" description="description" domain="domain"
short_name="short name" qualitative="false" user_managed="false" enabled="true" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>
</dataset>
\ No newline at end of file
<dataset>
- <metrics id="1" name="key" val_type="FLOAT" description="new description" domain="new domain"
+ <metrics delete_historical_data="[null]" id="1" name="key" val_type="FLOAT" description="new description" domain="new domain"
short_name="new short name" qualitative="true" user_managed="false" enabled="true" origin="JAV" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="-1" hidden="false"/>
</dataset>
\ No newline at end of file
<dataset>
- <metrics id="1" name="key" val_type="INT" description="old description" domain="old domain"
+ <metrics delete_historical_data="[null]" id="1" name="key" val_type="INT" description="old description" domain="old domain"
short_name="old short name" qualitative="false" user_managed="false" enabled="true" origin="GUI" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="1" hidden="false"/>