]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2347 Add the column RULE_FAILURES.PERMANENT_ID
authorsimonbrandhof <simon.brandhof@gmail.com>
Tue, 12 Apr 2011 12:46:05 +0000 (14:46 +0200)
committersimonbrandhof <simon.brandhof@gmail.com>
Tue, 12 Apr 2011 12:46:05 +0000 (14:46 +0200)
22 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots-result.xml
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots.xml
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources-result.xml
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources.xml
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast-result.xml
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast.xml
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities-result.xml
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities.xml
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed-result.xml
plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed.xml
sonar-batch/src/main/java/org/sonar/batch/index/ViolationPersister.java
sonar-batch/src/test/java/org/sonar/batch/index/ViolationPersisterTest.java
sonar-batch/src/test/resources/org/sonar/batch/components/PastViolationsLoaderTest/shared.xml
sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shared.xml
sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldCopyPermanentIdFromPastViolation-result.xml [new file with mode: 0644]
sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldInsertViolations-result.xml
sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot-result.xml
sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot.xml
sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java
sonar-plugin-api/src/main/java/org/sonar/api/database/model/RuleFailureModel.java
sonar-server/src/main/webapp/WEB-INF/db/migrate/190_add_rule_failures_permanent_id.rb [new file with mode: 0644]

index 57460299a54a92808b2c4e9d57d6f7c5ab1f301e..832a4be13b02fa056db6f343b7dc1611335ad4ea 100644 (file)
@@ -95,12 +95,9 @@ public class ViolationPersisterDecorator implements Decorator {
       if (pastViolation != null) {
         // remove violation, since would be updated and shouldn't affect other violations anymore
         pastViolationsByRule.remove(violation.getRule(), pastViolation);
-        violation.setCreatedAt(pastViolation.getCreatedAt());
-      } else {
-        violation.setCreatedAt(null);//avoid plugins to set date
       }
       String checksum = getChecksumForLine(checksums, violation.getLineId());
-      violationPersister.saveViolation(context.getProject(), violation, checksum);
+      violationPersister.saveViolation(context.getProject(), violation, pastViolation, checksum);
     }
   }
 
index 404feaf2e4ab15589c5cae7f9f13d96bd23656ee..23bec12c6f9f4a630cbd0ac99feae0c8172ebcc2 100644 (file)
   <!--<SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="some sources"/>-->
 
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <!--<RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
-  <!--<RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <!--<rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <!--<rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
 
 
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index d818ec94c042c274cb264759eef0bcbb4f404e12..9dcc3739756cf45d5928701764850af32f70b673 100644 (file)
   <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="some sources"/>
 
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
 
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index 449add6cacb7b838ea877baf2814f299c44f0d2e..6da7758bade3d21e32b69fa4ab4943ed34dd6499 100644 (file)
   <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="foo"/>
 
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <!--<RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <!--<rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
   <project_measures characteristic_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]"
index 4d4e2547be2654c1ef98463f196c52e5bd2e3602..4c25124499bd218d9646ec5540c3609311a87233 100644 (file)
   <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="foo"/>
 
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
   <project_measures characteristic_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]"
index 9d24e4d5d4f58e8067b475b91bce28e29a6ddb39..b5d53d48073bd3dd0acc4300a4e20152bc43c1a9 100644 (file)
   <!--<SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>-->
   <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="foo"/>
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <!--<RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <!--<rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
 
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index d5b7a63681eae9d85c92d5e064c5590b70946eac..3f945a4e32a1f73b4a3ddf839b0890708683fa9b 100644 (file)
   <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>
   <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="foo"/>
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
 
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index f70f99ba039094ac75f2841098aff9b3f1ee2fe8..88a3ff38fff291b131b4b026a842eeaaf28ea233 100644 (file)
 
 
   <!-- old violations -->
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <!--<RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
-  <!--<RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <!--<rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <!--<rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
 
 
   <!-- last violations -->
-  <RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
   <!-- old measures -->
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index 197bdfad8c36b9346f338e62912b1e86f00ef401..8a6ef22cad58fab5f088e17a04f531544dad9d77 100644 (file)
 
 
   <!-- old violations -->
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
 
   <!-- last violations -->
-  <RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
   <!-- old measures -->
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index 04e9086dc50a4d8d8176a9c047be6cc4b7e43fef..fb803362adcdad86725e6c0fd07448ee9bcc9478 100644 (file)
 
 
   <!-- valid violations -->
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
 
   <!-- unprocessed violations -->
-  <!--<RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
-  <!--<RULE_FAILURES ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
-  <!--<RULE_FAILURES ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
-  <!--<RULE_FAILURES ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <!--<rule_failures permanent_id="[null]" ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <!--<rule_failures permanent_id="[null]" ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <!--<rule_failures permanent_id="[null]" ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
+  <!--<rule_failures permanent_id="[null]" ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>-->
 
   <!-- valid measures -->
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index 979b3e30ef315510f2528c147f16c8902e2cef53..6d37ae8d37473eb6996e82e975a919ca23c67c33 100644 (file)
 
 
   <!-- valid violations -->
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
 
   <!-- unprocessed violations -->
-  <RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="[null]" ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]" created_at="2008-12-02 13:58:00.00" checksum="[null]"/>
 
   <!-- valid measures -->
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index d6cbcf1ac27a1befd88ff0695454356a0abd1cc0..64d2c85c2d7050d962bee2915a1c9968ec1457b5 100644 (file)
@@ -40,19 +40,33 @@ public final class ViolationPersister {
   }
 
   void saveViolation(Project project, Violation violation) {
-    saveViolation(project, violation, null);
+    saveViolation(project, violation, null, null);
   }
 
-  public void saveViolation(Project project, Violation violation, String checksum) {
+  public void saveViolation(Project project, Violation violation, RuleFailureModel pastViolation, String checksum) {
     Snapshot snapshot = resourcePersister.saveResource(project, violation.getResource());
-    if (violation.getCreatedAt()==null) {
-      violation.setCreatedAt(snapshot.getCreatedAt());
-    }
+
     RuleFailureModel model = createModel(violation);
+    if (pastViolation!=null) {
+      model.setCreatedAt(pastViolation.getCreatedAt());
+      model.setPermanentId(pastViolation.getPermanentId());
+
+    } else {
+      // avoid plugins setting date
+      model.setCreatedAt(snapshot.getCreatedAt());
+    }
     model.setSnapshotId(snapshot.getId());
     model.setChecksum(checksum);
     session.save(model);
+
+    if (model.getPermanentId()==null) {
+      model.setPermanentId(model.getId());
+      session.save(model);
+    }
+
+    // the following fields can have been changed
     violation.setMessage(model.getMessage());// the message can be changed in the class RuleFailure (truncate + trim)
+    violation.setCreatedAt(model.getCreatedAt());
   }
 
   private RuleFailureModel createModel(Violation violation) {
@@ -60,7 +74,6 @@ public final class ViolationPersister {
     Rule rule = ruleFinder.findByKey(violation.getRule().getRepositoryKey(), violation.getRule().getKey());
     model.setRuleId(rule.getId());
     model.setPriority(violation.getSeverity());
-    model.setCreatedAt(violation.getCreatedAt());
     model.setLine(violation.getLineId());
     model.setMessage(violation.getMessage());
     model.setCost(violation.getCost());
index 9b27d33b2517c5f9dbc421b4032527763730b383..66a73335dd96aeb1df538576db53784a10aab7e0 100644 (file)
@@ -31,8 +31,6 @@ import org.sonar.api.rules.Violation;
 import org.sonar.core.components.DefaultRuleFinder;
 import org.sonar.jpa.test.AbstractDbUnitTestCase;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.notNullValue;
 import static org.mockito.Matchers.anyObject;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
@@ -44,6 +42,7 @@ public class ViolationPersisterTest extends AbstractDbUnitTestCase {
   private Rule rule1 = Rule.create("checkstyle", "com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck", "Check Header");
   private Rule rule2 = Rule.create("checkstyle", "com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck", "Equals Avoid Null");
   private JavaFile javaFile = new JavaFile("org.foo.Bar");
+  Project project = new Project("project");
 
   @Before
   public void before() {
@@ -64,7 +63,6 @@ public class ViolationPersisterTest extends AbstractDbUnitTestCase {
         .setSeverity(RulePriority.CRITICAL).setLineId(50).setCost(80.0);
     Violation violation2 = Violation.create(rule2, javaFile)
         .setSeverity(RulePriority.MINOR);
-    Project project = new Project("project");
 
     violationPersister.saveViolation(project, violation1a);
     violationPersister.saveViolation(project, violation1b);
@@ -73,4 +71,13 @@ public class ViolationPersisterTest extends AbstractDbUnitTestCase {
     checkTables("shouldInsertViolations", "rule_failures");
   }
 
+  @Test
+  public void shouldCopyPermanentIdFromPastViolation() {
+    RuleFailureModel pastViolation = getSession().getSingleResult(RuleFailureModel.class, "id", 1);
+
+    Violation violation = Violation.create(rule1, javaFile).setSeverity(RulePriority.MAJOR).setMessage("new message");
+    violationPersister.saveViolation(project, violation, pastViolation, "line_checksum");
+
+    checkTables("shouldCopyPermanentIdFromPastViolation", "rule_failures");
+  }
 }
index a7a222fe037ed8ae6afb8bfb81654429868c2010..8a7e3d9a5c98a8c13ac29fb81d4d9f171884e1cf 100644 (file)
@@ -19,6 +19,6 @@
              scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""
              status="U" islast="false" depth="3" />
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" />
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" />
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" />
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" />
 </dataset>
index 4ca54571036e8ea12693f7520b74e2ec90849a44..32696a8a5233494f3c498887fc17a1c03fa6e179 100644 (file)
@@ -19,6 +19,6 @@
              scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""
              status="U" islast="false" depth="3" />
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
 </dataset>
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldCopyPermanentIdFromPastViolation-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldCopyPermanentIdFromPastViolation-result.xml
new file mode 100644 (file)
index 0000000..0b126c5
--- /dev/null
@@ -0,0 +1,26 @@
+<dataset>
+
+  <rules_categories id="1" name="Efficiency" description="[null]"/>
+  <rules_categories id="6" name="Usability" description="[null]"/>
+
+  <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"
+         plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"
+         cardinality="SINGLE" parent_id="[null]"/>
+
+  <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"
+         plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"
+         cardinality="SINGLE" parent_id="[null]"/>
+
+  <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
+            name="Bar" long_name="org.foo.Bar" description="[null]"
+            enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>
+
+  <snapshots 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]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"
+             scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""
+             status="U" islast="false" depth="3" />
+
+  <rule_failures permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+
+  <rule_failures permanent_id="1" ID="3" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="2" MESSAGE="new message" LINE="[null]" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="line_checksum"/>
+</dataset>
index ba821ae315351a22e122af9121127208a9803df4..9a2cbddd9dd79bf56d5076883359f889126546d9 100644 (file)
@@ -18,9 +18,9 @@
              scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""
              status="U" islast="false" depth="3" />
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="3" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="the message" LINE="20" COST="55.6" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="[null]" LINE="50" COST="80" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
-  <RULE_FAILURES ID="5" SNAPSHOT_ID="1000" RULE_ID="31" FAILURE_LEVEL="1" MESSAGE="[null]" LINE="[null]" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="3" ID="3" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="the message" LINE="20" COST="55.6" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="4" ID="4" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="[null]" LINE="50" COST="80" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+  <rule_failures permanent_id="5" ID="5" SNAPSHOT_ID="1000" RULE_ID="31" FAILURE_LEVEL="1" MESSAGE="[null]" LINE="[null]" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
 </dataset>
\ No newline at end of file
index 95a288181036b48ffce795ef308275c5379c07c3..a2b0168b56346bd93891dfdb7235aad6285cf91b 100644 (file)
   <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="4" DATA="source code of Class1"/>
   <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="5" DATA="source code of Class2"/>
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" COST="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" COST="[null]"/>
-  <RULE_FAILURES ID="3" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]"/>
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]"/>
 
-  <RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg5" COST="[null]"/>
-  <RULE_FAILURES ID="6" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg6" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg5" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="6" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg6" COST="[null]"/>
 
   <!-- measures at project level -->
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index 3d987346f6f584446c47e2b4fb49cebc50b4cf3c..04a6b1ad75aa252b41eed0455c71b5592f2ceced 100644 (file)
   <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="4" DATA="source code of Class1"/>
   <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="5" DATA="source code of Class2"/>
 
-  <RULE_FAILURES ID="1" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" COST="[null]"/>
-  <RULE_FAILURES ID="2" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" COST="[null]"/>
-  <RULE_FAILURES ID="3" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]"/>
-  <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="1" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="2" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="3" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]"/>
 
-  <RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg5" COST="[null]"/>
-  <RULE_FAILURES ID="6" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg6" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg5" COST="[null]"/>
+  <rule_failures permanent_id="[null]" ID="6" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg6" COST="[null]"/>
 
   <!-- measures at project level -->
   <project_measures characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
index 7551bff7795837c8bf775c5173b1545b0c8f9584..47b1c4d567dc2b767b4d022722404d3f272cc11d 100644 (file)
@@ -31,7 +31,7 @@ import javax.persistence.*;
 public class SchemaMigration {
 
   public final static int VERSION_UNKNOWN = -1;
-  public static final int LAST_VERSION = 181;
+  public static final int LAST_VERSION = 190;
 
   public final static String TABLE_NAME = "schema_migrations";
 
index fdcd25583e079e2c6236f35340f6398b1f2143a9..ac682815b550a183ef1c67ccdf8fe0066936f177 100644 (file)
@@ -62,6 +62,9 @@ public class RuleFailureModel extends BaseIdentifiable {
   @Column(name = "checksum", updatable = true, nullable = true, length = 1000)
   private String checksum;
 
+  @Column(name = "permanent_id", updatable = true, nullable = true)
+  private Integer permanentId;
+
   public String getMessage() {
     return message;
   }
@@ -147,6 +150,15 @@ public class RuleFailureModel extends BaseIdentifiable {
     this.checksum = checksum;
   }
 
+  public Integer getPermanentId() {
+    return permanentId;
+  }
+
+  public RuleFailureModel setPermanentId(Integer i) {
+    this.permanentId = i;
+    return this;
+  }
+
   @Override
   public boolean equals(Object obj) {
     if (!(obj instanceof RuleFailureModel)) {
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/190_add_rule_failures_permanent_id.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/190_add_rule_failures_permanent_id.rb
new file mode 100644 (file)
index 0000000..a125c30
--- /dev/null
@@ -0,0 +1,32 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 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.8
+#
+class AddRuleFailuresPermanentId < ActiveRecord::Migration
+
+  def self.up
+    add_column 'rule_failures', 'permanent_id', :integer, :null => true
+    add_index 'rule_failures', 'permanent_id', :name => 'rf_permanent_id'
+    RuleFailure.reset_column_information
+  end
+
+end