]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4305 migrate db tables from violations/reviews to issues
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 21 May 2013 14:37:17 +0000 (16:37 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 21 May 2013 15:00:01 +0000 (17:00 +0200)
39 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java
sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java
sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java
sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_all.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_action_plans.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_assigned.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_component_root.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_date_creation.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_ids.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_planned.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_query.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_resolved.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_rules.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_open_issues.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_assignee.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_close_date.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_creation_date.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_severity.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_status.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_update_date.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml
sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml
sonar-server/src/main/webapp/WEB-INF/db/migrate/395_create_issues.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/398_delete_review_duplications.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/db/migrate/399_migrate_violations_to_issues.rb [new file with mode: 0644]

index e45a749a33deb9636a5b37b81179a2e3d19463b0..cd6907ca66ed53cdabf24ee1c6826d07022d45ec 100644 (file)
@@ -141,8 +141,8 @@ public class IssueTrackingDecorator implements Decorator {
       issue.setStatus(ref.getStatus());
       issue.setAssignee(ref.getAssignee());
       issue.setAuthorLogin(ref.getAuthorLogin());
-      if (ref.getAttributes() != null) {
-          issue.setAttributes(KeyValueFormat.parse(ref.getAttributes()));
+      if (ref.getIssueAttributes() != null) {
+          issue.setAttributes(KeyValueFormat.parse(ref.getIssueAttributes()));
       }
 
       // fields to update with current values
index de545172be55b88a41645fb5fadd77e43ec361e4..c79b4837172d8522395b5d6cdd0b419921e79efe 100644 (file)
@@ -52,7 +52,7 @@ public final class IssueDto {
   private String assignee;
   private String authorLogin;
   private String actionPlanKey;
-  private String attributes;
+  private String issueAttributes;
 
   // functional dates
   private Date issueCreationDate;
@@ -220,14 +220,14 @@ public final class IssueDto {
     return this;
   }
 
-  public String getAttributes() {
-    return attributes;
+  public String getIssueAttributes() {
+    return issueAttributes;
   }
 
-  public IssueDto setAttributes(@Nullable String s) {
+  public IssueDto setIssueAttributes(@Nullable String s) {
     Preconditions.checkArgument(s == null || s.length() <= 4000,
       "Issue attributes must not exceed 4000 characters: " + s);
-    this.attributes = s;
+    this.issueAttributes = s;
     return this;
   }
 
@@ -326,7 +326,7 @@ public final class IssueDto {
       .setRuleId(ruleId)
       .setResourceId(componentId)
       .setActionPlanKey(issue.actionPlanKey())
-      .setAttributes(issue.attributes() != null ? KeyValueFormat.format(issue.attributes()) : "")
+      .setIssueAttributes(issue.attributes() != null ? KeyValueFormat.format(issue.attributes()) : "")
       .setAuthorLogin(issue.authorLogin())
       .setIssueCreationDate(issue.creationDate())
       .setIssueCloseDate(issue.closeDate())
@@ -351,7 +351,7 @@ public final class IssueDto {
       .setReporter(issue.reporter())
       .setAssignee(issue.assignee())
       .setActionPlanKey(issue.actionPlanKey())
-      .setAttributes(issue.attributes() != null ? KeyValueFormat.format(issue.attributes()) : "")
+      .setIssueAttributes(issue.attributes() != null ? KeyValueFormat.format(issue.attributes()) : "")
       .setAuthorLogin(issue.authorLogin())
       .setIssueCreationDate(issue.creationDate())
       .setIssueCloseDate(issue.closeDate())
@@ -370,7 +370,7 @@ public final class IssueDto {
     issue.setSeverity(severity);
     issue.setReporter(reporter);
     issue.setAssignee(assignee);
-    issue.setAttributes(KeyValueFormat.parse(Objects.firstNonNull(attributes, "")));
+    issue.setAttributes(KeyValueFormat.parse(Objects.firstNonNull(issueAttributes, "")));
     issue.setComponentKey(componentKey);
     issue.setManualSeverity(manualSeverity);
     issue.setRuleKey(RuleKey.of(ruleRepo, ruleKey));
index aafefbd4286f0b54380d08ec038620a5aeeee5c2..39fdd04cd9867d0e002b5f4efedc714f4639676d 100644 (file)
@@ -32,7 +32,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 397;
+  public static final int LAST_VERSION = 399;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index 9717a2417cfb86c8c7946ef7614b1d981086d10c..4edb2f7a599787773de20a973c8bb85c6e945e99 100644 (file)
@@ -21,7 +21,7 @@
     i.reporter as reporter,
     i.assignee as assignee,
     i.author_login as authorLogin,
-    i.attributes as attributes,
+    i.issue_attributes as issueAttributes,
     i.issue_creation_date as issueCreationDate,
     i.issue_update_date as issueUpdateDate,
     i.issue_close_date as issueCloseDate,
   <insert id="insert" parameterType="Issue" useGeneratedKeys="false" keyProperty="id">
     INSERT INTO issues (kee, resource_id, rule_id, action_plan_key, severity, manual_severity,
     message, line, effort_to_fix, status,
-    resolution, checksum, reporter, assignee, author_login, attributes, issue_creation_date, issue_update_date,
+    resolution, checksum, reporter, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
     issue_close_date, created_at, updated_at)
     VALUES (#{kee}, #{resourceId}, #{ruleId}, #{actionPlanKey}, #{severity}, #{manualSeverity},
     #{message}, #{line}, #{effortToFix}, #{status},
-    #{resolution}, #{checksum}, #{reporter}, #{assignee}, #{authorLogin}, #{attributes}, #{issueCreationDate},
+    #{resolution}, #{checksum}, #{reporter}, #{assignee}, #{authorLogin}, #{issueAttributes}, #{issueCreationDate},
     #{issueUpdateDate}, #{issueCloseDate}, #{createdAt}, #{updatedAt})
   </insert>
 
     </selectKey>
     INSERT INTO issues (id, kee, resource_id, rule_id, action_plan_key, severity, manual_severity,
     message, line, effort_to_fix, status,
-    resolution, checksum, reporter, assignee, author_login, attributes, issue_creation_date, issue_update_date,
+    resolution, checksum, reporter, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
     issue_close_date, created_at, updated_at)
     VALUES (#{id}, #{kee}, #{resourceId}, #{ruleId}, #{actionPlanKey}, #{severity}, #{manualSeverity},
     #{message}, #{line}, #{effortToFix}, #{status},
-    #{resolution}, #{checksum}, #{reporter}, #{assignee}, #{authorLogin}, #{attributes}, #{issueCreationDate},
+    #{resolution}, #{checksum}, #{reporter}, #{assignee}, #{authorLogin}, #{issueAttributes}, #{issueCreationDate},
     #{issueUpdateDate}, #{issueCloseDate}, #{createdAt}, #{updatedAt})
   </insert>
 
     reporter=#{reporter},
     assignee=#{assignee},
     author_login=#{authorLogin},
-    attributes=#{attributes},
+    issue_attributes=#{issueAttributes},
     issue_creation_date=#{issueCreationDate},
     issue_update_date=#{issueUpdateDate},
     issue_close_date=#{issueCloseDate},
index 6b3fcd5313f1c6abd64dfad2986d7e767ca0daae..a6aaa812b52fda2a7942cd5e1453fb6d34e02d31 100644 (file)
@@ -162,6 +162,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('394');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('395');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('396');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('397');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('398');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('399');
 
 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;
index 640817337a557bed27674fca8044416974be8304..79018bd010c437ca754426abba3afb8d2639171e 100644 (file)
@@ -533,7 +533,7 @@ CREATE TABLE "ISSUES" (
   "ASSIGNEE" VARCHAR(40),
   "AUTHOR_LOGIN" VARCHAR(100),
   "ACTION_PLAN_KEY" VARCHAR(50) NULL,
-  "ATTRIBUTES" VARCHAR(4000),
+  "ISSUE_ATTRIBUTES" VARCHAR(4000),
   "ISSUE_CREATION_DATE" TIMESTAMP,
   "ISSUE_CLOSE_DATE" TIMESTAMP,
   "ISSUE_UPDATE_DATE" TIMESTAMP,
index cfb30567f2100817a94985030275c38b6687b268..fe83068bf2e4817045658f01f1bec0b4100be2fb 100644 (file)
@@ -62,7 +62,7 @@ public class IssueDaoTest extends AbstractDaoTestCase {
     assertThat(issue.getAuthorLogin()).isEqualTo("karadoc");
     assertThat(issue.getReporter()).isEqualTo("arthur");
     assertThat(issue.getAssignee()).isEqualTo("perceval");
-    assertThat(issue.getAttributes()).isEqualTo("JIRA=FOO-1234");
+    assertThat(issue.getIssueAttributes()).isEqualTo("JIRA=FOO-1234");
     assertThat(issue.getIssueCreationDate()).isNotNull();
     assertThat(issue.getIssueUpdateDate()).isNotNull();
     assertThat(issue.getIssueCloseDate()).isNotNull();
index 9598b8c796dc4f48997bf63191908522c1baea7e..a935fbcdcbdb39f522fc5d3b6fc97c66e74c174a 100644 (file)
@@ -44,7 +44,7 @@ public class IssueDtoTest {
     for (int i = 0; i < 4500; i++) {
       s.append('a');
     }
-    new IssueDto().setAttributes(s.toString());
+    new IssueDto().setIssueAttributes(s.toString());
   }
 
   @Test
@@ -68,7 +68,7 @@ public class IssueDtoTest {
         .setManualSeverity(true)
         .setReporter("arthur")
         .setAssignee("perceval")
-        .setAttributes("key=value")
+        .setIssueAttributes("key=value")
         .setAuthorLogin("pierre")
         .setIssueCreationDate(createdAt)
         .setIssueUpdateDate(updatedAt)
index d606a87080d1fbad9e9aba8aaddc2635d2a3cd6e..942514f541193d1e47c2e04a515a072d556e477d 100644 (file)
@@ -51,7 +51,7 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     dto.setAuthorLogin("morgan");
     dto.setAssignee("karadoc");
     dto.setActionPlanKey("current_sprint");
-    dto.setAttributes("JIRA=FOO-1234");
+    dto.setIssueAttributes("JIRA=FOO-1234");
     dto.setChecksum("123456789");
     dto.setMessage("the message");
 
@@ -84,7 +84,7 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     dto.setAuthorLogin("morgan");
     dto.setAssignee("karadoc");
     dto.setActionPlanKey("current_sprint");
-    dto.setAttributes("JIRA=FOO-1234");
+    dto.setIssueAttributes("JIRA=FOO-1234");
     dto.setChecksum("123456789");
     dto.setMessage("the message");
 
index f960ecd1b62d88ec7e6599f601438062a58279f7..99469f9ac16afc8b31af46abc39a98b954c950c7 100644 (file)
@@ -18,7 +18,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       action_plan_key="ABC"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
@@ -42,7 +42,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       action_plan_key="ABC"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
@@ -66,7 +66,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       action_plan_key="ABC"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
index 3d7bd96af2126c6adb78f0a22ea32d4875e5168e..1536bfcd739006c8f9e445a48c95c9757e615684 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -41,7 +41,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -67,7 +67,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 5655372b58e3d0e895c558d6176e3a62947fa8b5..ca8d6ea634fb4f8d454205dde8dc98edddbd4aac 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -42,7 +42,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -68,7 +68,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index f25c1c9e8ea5d1b0af0a0524b1bc8063e5c193b7..e0ab0887a437b2b388d155ef2122f600656f6470 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -41,7 +41,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -67,7 +67,7 @@
       reporter="arthur"
       assignee="[null]"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 34f07c20209acd50515bb2e7de9df21aac765a37..72522e5536047c0e058aa41137fd82bc9d2dd53d 100644 (file)
@@ -16,7 +16,7 @@
       reporter="user"
       assignee="user"
       author_login="[null]"
-      attributes="[null]"
+      issue_attributes="[null]"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -40,7 +40,7 @@
       reporter="[null]"
       assignee="user"
       author_login="[null]"
-      attributes="[null]"
+      issue_attributes="[null]"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 9b6f20c96ca8aee11be82f76da302db2cc6f3fe2..be5857897227d9cb07c15a01ffa0d316e2c60e62 100644 (file)
@@ -16,7 +16,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -40,7 +40,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-13"
       issue_update_date="2013-04-13"
       issue_close_date="2013-04-13"
index 3d6ad15c5a062f9afb02b7e23ecdf4f1c11b022b..986c069e9e43030dda5237baf2c4708581f1c3c5 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-17"
       issue_update_date="2013-04-17"
       issue_close_date="2013-04-17"
@@ -41,7 +41,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -67,7 +67,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-18"
       issue_update_date="2013-04-18"
       issue_close_date="2013-04-18"
index d01f5342d8780aa620dacb210e8c6c35b582c454..853f580260f4102764c93d513bcdb8f19d7bd248 100644 (file)
@@ -16,7 +16,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="karadoc"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index ded6b072043db4a42483ba8b61dc857feae94511..8ab824158e0bcfcc52d388c12efb56155b787d69 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -42,7 +42,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -68,7 +68,7 @@
       reporter="arthur"
       assignee="[null]"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 816742b954b30158e92d625dd54237a607886d79..8c8853780618e1509689533ac4288a172a2e7908 100644 (file)
@@ -16,7 +16,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 371d3da3f4f22174fa51c90655ca9d8dd3baffa6..aa6105074d77b47d8660e26b00d6337d373dac38 100644 (file)
@@ -16,7 +16,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -40,7 +40,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -64,7 +64,7 @@
       reporter="arthur"
       assignee="[null]"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index d2af6661a9eb7f25faa21faece12c4cbf5d92fd3..746d55ec02144d8497f0c5a1b4f20b4fcd44dcb3 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -41,7 +41,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -67,7 +67,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 3d7bd96af2126c6adb78f0a22ea32d4875e5168e..1536bfcd739006c8f9e445a48c95c9757e615684 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -41,7 +41,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -67,7 +67,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 12f7036120e18dde09e90cc2991f787a1089eb57..2314297dc66f9b4aabf348c5255d7216ecd186ba 100644 (file)
@@ -16,7 +16,7 @@
       reporter="user"
       assignee="user"
       author_login="[null]"
-      attributes="[null]"
+      issue_attributes="[null]"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -40,7 +40,7 @@
       reporter="[null]"
       assignee="user"
       author_login="[null]"
-      attributes="[null]"
+      issue_attributes="[null]"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -64,7 +64,7 @@
       reporter="[null]"
       assignee="user"
       author_login="[null]"
-      attributes="[null]"
+      issue_attributes="[null]"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 41a97ef98b80e809108e87d5eb075f0c7d698851..2e5e66e3bbb912195a4f2ee302a41f852090f77b 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="arthur"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -41,7 +41,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -67,7 +67,7 @@
       reporter="arthur"
       assignee="henry"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index b27051ff2074aeb6bd789fe1235406523fab6311..4de78ef752e869699e848a82ec3c678ac527ce42 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="arthur"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-17"
       issue_close_date="2013-04-17"
@@ -41,7 +41,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -67,7 +67,7 @@
       reporter="arthur"
       assignee="henry"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-18"
       issue_close_date="2013-04-18"
index d84b71fa09be5116d390484f358c69ddafbcb66d..4af4496b6ee6ce63f6d830a7472b258da2cf7f2e 100644 (file)
@@ -16,7 +16,7 @@
       reporter="arthur"
       assignee="arthur"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-15"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -40,7 +40,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-14"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -64,7 +64,7 @@
       reporter="arthur"
       assignee="henry"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 9dae4080973c05fa371c73ce8ea59d39142c2f57..ae7bf8136591754aca84c53c16d4efe2033d9c70 100644 (file)
@@ -16,7 +16,7 @@
       reporter="arthur"
       assignee="arthur"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -40,7 +40,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -64,7 +64,7 @@
       reporter="arthur"
       assignee="henry"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index b510a5c447ae311f2cb6ffbe3afcf55443eb64c3..963dfcfa98dfe0afc00e15bb08b5647be6623be1 100644 (file)
@@ -17,7 +17,7 @@
       reporter="arthur"
       assignee="arthur"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -41,7 +41,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -67,7 +67,7 @@
       reporter="arthur"
       assignee="henry"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 769bae1454d1a5e9f88f21787640d6fc52f9dd66..0fe273586250c8142acca34649a68e0f9bc8cb6f 100644 (file)
@@ -16,7 +16,7 @@
       reporter="arthur"
       assignee="arthur"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-17"
       issue_close_date="2013-04-17"
@@ -40,7 +40,7 @@
       reporter="arthur"
       assignee="perceval"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -64,7 +64,7 @@
       reporter="arthur"
       assignee="henry"
       author_login="[null]"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-18"
       issue_close_date="2013-04-18"
index 69e5160f9622b9cceee9f498c2dc1664ab2831bf..9bf0949ff96ed990eed6cd7900a20210fca265dd 100644 (file)
@@ -15,7 +15,7 @@
       reporter="emmerik"
       author_login="morgan"
       assignee="karadoc"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-05-18"
       issue_update_date="2013-05-19"
       issue_close_date="2013-05-20"
index 57bc88451eaf3697cd46786105d209c6c65eb2cb..7b426decddedb071c6d3d43bf109c8d8ad1c7d66 100644 (file)
@@ -34,7 +34,7 @@
       reporter="emmerik"
       author_login="morgan"
       assignee="karadoc"
-      attributes="JIRA=FOO-1234"
+      issue_attributes="JIRA=FOO-1234"
       issue_creation_date="2013-05-18"
       issue_update_date="2013-05-19"
       issue_close_date="2013-05-20"
index 06ee1af1b5061a27444999dbc1c7938c5492dedd..f6f06e40abda696fe6b9fc3087c821ea9ef9c652 100644 (file)
@@ -34,7 +34,7 @@
       reporter="[null]"
       author_login="[null]"
       assignee="[null]"
-      attributes="[null]"
+      issue_attributes="[null]"
       issue_creation_date="[null]"
       issue_update_date="[null]"
       issue_close_date="[null]"
index 97ca9b21656101c57cdaa484e17d5ce3cd7eb2e7..aa41626b8dfcbdf932dcb05e3cc7ff4508c862c0 100644 (file)
@@ -11,7 +11,7 @@
       created_at="[null]"
       updated_at="[null]"
       reporter="emmerik"
-      attributes="foo=bar"
+      issue_attributes="foo=bar"
       action_plan_key="[null]"
       issue_creation_date="2013-05-18"
       issue_update_date="2013-05-18"
index 862d14f2b750073c3d2ec15a7d60f60c0bfee6d6..d7a35807753b16fc683985372906d09e52dc7e47 100644 (file)
@@ -16,7 +16,7 @@
           created_at="2013-05-18"
           updated_at="2013-05-18"
           reporter="emmerik"
-          attributes="foo=bar"
+          issue_attributes="foo=bar"
           action_plan_key="[null]"
           issue_creation_date="2013-05-18 00:00:00.0"
           issue_update_date="2013-05-18 00:00:00.0"
index 4d8e2449c578896472a29d26cc4013debb724ecd..d3460496f19d43f5cc211b33a504e9ed3f26e317 100644 (file)
@@ -16,7 +16,7 @@
           created_at="2010-01-01"
           updated_at="2011-02-02"
           reporter="emmerik"
-          attributes="foo=bar"
+          issue_attributes="foo=bar"
           action_plan_key="[null]"
           issue_creation_date="2010-01-01"
           issue_update_date="2010-02-02"
index 5bf87b320ac82995aafdf0e7bb925fb5db73d7e2..4f5cf5e326f41bedfccd327abbebe840607ba4a7 100644 (file)
@@ -34,7 +34,7 @@
       reporter="user"
       assignee="user"
       author_login="[null]"
-      attributes="[null]"
+      issue_attributes="[null]"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
@@ -58,7 +58,7 @@
       reporter="[null]"
       assignee="user"
       author_login="[null]"
-      attributes="[null]"
+      issue_attributes="[null]"
       issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
index 2733202a82e124ae4cab2463204e48ef1508ec1f..febc7422cace618d5a3f997e5cf8b2ba880ef792 100644 (file)
@@ -40,7 +40,7 @@ class CreateIssues < ActiveRecord::Migration
       t.column :assignee,             :string,    :null => true,         :limit => 40
       t.column :author_login,         :string,    :null => true,    :limit => 100
       t.column :action_plan_key,      :string,    :null => true,    :limit => 50
-      t.column :attributes,           :string,    :null => true,    :limit => 4000
+      t.column :issue_attributes,           :string,    :null => true,    :limit => 4000
 
       # functional dates
       t.column :issue_creation_date,  :datetime,  :null => true
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/398_delete_review_duplications.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/398_delete_review_duplications.rb
new file mode 100644 (file)
index 0000000..d6b39a8
--- /dev/null
@@ -0,0 +1,42 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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 this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# Sonar 3.6
+# See SONAR-4305
+#
+class DeleteReviewDuplications < ActiveRecord::Migration
+
+  class Review < ActiveRecord::Base
+  end
+
+  def self.up
+    duplicated_ids = ActiveRecord::Base.connection.select_rows('select rule_failure_permanent_id from reviews group by rule_failure_permanent_id having count(*) > 1')
+    say_with_time "Removing #{duplicated_ids.size} duplicated reviews" do
+      duplicated_ids.each do |id|
+        reviews = Review.find(:all, :conditions => {:rule_failure_permanent_id => id})
+        # delete all reviews except the last one
+        reviews[0...-1].each do |review|
+          Review.delete(review.id)
+        end
+      end
+    end
+  end
+end
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/399_migrate_violations_to_issues.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/399_migrate_violations_to_issues.rb
new file mode 100644 (file)
index 0000000..69662da
--- /dev/null
@@ -0,0 +1,163 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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 this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# Sonar 3.6
+# See SONAR-4305
+#
+class MigrateViolationsToIssues < ActiveRecord::Migration
+
+  class RuleFailure < ActiveRecord::Base
+  end
+
+  class Issue < ActiveRecord::Base
+  end
+
+  class IssueChange < ActiveRecord::Base
+  end
+
+  class User < ActiveRecord::Base
+  end
+
+  class ActionPlan < ActiveRecord::Base
+  end
+
+  PRIORITY_TO_SEVERITY = {1 => 'INFO', 2 => 'MINOR', 3 => 'MAJOR', 4 => 'CRITICAL', 5 => 'BLOCKER'}
+
+  def self.up
+    # TODO another migration to delete duplications in reviews
+    truncate_issues
+
+    violation_ids = ActiveRecord::Base.connection.select_rows('select id from rule_failures')
+
+    say_with_time "Migrating #{violation_ids.size} violations to issues" do
+      logins_by_id = User.all.inject({}) do |result, user|
+        result[user.id]=user.login
+        result
+      end
+
+      plans_by_id = ActionPlan.all.inject({}) do |result, plan|
+        result[plan.id]=plan.kee
+        result
+      end
+
+      violation_ids.each_slice(999) do |ids|
+        violations = ActiveRecord::Base.connection.select_rows(sql_select_violation(ids))
+        ActiveRecord::Base.transaction do
+          violations.each do |violation|
+            issue_key = new_key
+            review_id = violation[0]
+            created_at = violation[7]
+            resource_id = violation[1]
+            if resource_id.present?
+              issue = Issue.new(
+                :kee => issue_key,
+                :resource_id => violation[1],
+                :rule_id => violation[2],
+                :severity => PRIORITY_TO_SEVERITY[violation[3].to_i],
+                :message => violation[4],
+                :line => violation[5],
+                :effort_to_fix => violation[6],
+                :resolution => violation[13],
+                :checksum => violation[8],
+                :author_login => nil,
+                :issue_attributes => violation[15],
+                :issue_creation_date => created_at,
+                :issue_close_date => nil,
+                :created_at => created_at
+              )
+              if review_id.present?
+                # has review
+                issue.status=violation[11]
+                issue.issue_update_date=violation[16]
+                issue.updated_at=violation[16]
+                issue.severity=violation[12]
+                issue.manual_severity=violation[14]
+                issue.reporter=logins_by_id[violation[9].to_i] if violation[9].present?
+                issue.assignee=logins_by_id[violation[10].to_i] if violation[10].present?
+
+                plan_id = select_plan_id(review_id)
+                issue.action_plan_key=plans_by_id[plan_id.to_i] if plan_id
+
+                review_comments = select_review_comments(review_id)
+                review_comments.each do |review_comment|
+                  user_id = review_comment[2]
+                  login = logins_by_id[user_id.to_i]
+                  if login
+                    IssueChange.create(
+                      :kee => new_key,
+                      :issue_key => issue_key,
+                      :user_login => login,
+                      :change_type => 'comment',
+                      :change_data => review_comment[3],
+                      :created_at => review_comment[0],
+                      :updated_at => review_comment[1]
+                    )
+                  end
+                end
+
+              else
+                # does not have review
+                issue.status='OPEN'
+                issue.issue_update_date=created_at
+                issue.updated_at=created_at
+                issue.manual_severity=false
+              end
+              issue.save
+            end
+          end
+        end
+      end
+    end
+
+    #drop_table('rule_failures')
+    #drop_table('reviews')
+    #drop_table('review_comments')
+    #drop_table('action_plans_reviews')
+  end
+
+  def self.truncate_issues
+    ActiveRecord::Base.connection.execute('truncate table issues')
+    ActiveRecord::Base.connection.execute('truncate table issue_changes')
+  end
+
+  def self.sql_select_violation(ids)
+    "select rev.id, s.project_id, rf.rule_id, rf.failure_level, rf.message, rf.line, rf.cost, rf.created_at,
+           rf.checksum,
+           rev.user_id, rev.assignee_id, rev.status, rev.severity, rev.resolution, rev.manual_severity, rev.data,
+           rev.updated_at
+    from rule_failures rf
+    inner join snapshots s on s.id=rf.snapshot_id
+    left join reviews rev on rev.rule_failure_permanent_id=rf.permanent_id
+    where rf.id in (#{ids.join(',')})"
+  end
+
+  def self.new_key
+    Java::JavaUtil::UUID.randomUUID().toString()
+  end
+
+  def self.select_plan_id(review_id)
+    ActiveRecord::Base.connection.select_value("select action_plan_id from action_plans_reviews where review_id=#{review_id}")
+  end
+
+  def self.select_review_comments(review_id)
+    ActiveRecord::Base.connection.select_rows "select created_at, updated_at, user_id, review_text from review_comments where review_id=#{review_id}"
+  end
+end
\ No newline at end of file