Browse Source

SONAR-4305 migrate db tables from violations/reviews to issues

tags/3.6
Simon Brandhof 11 years ago
parent
commit
714ba2eebc
39 changed files with 293 additions and 86 deletions
  1. 2
    2
      plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
  2. 8
    8
      sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java
  3. 1
    1
      sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
  4. 6
    6
      sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
  5. 2
    0
      sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
  6. 1
    1
      sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
  7. 1
    1
      sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java
  8. 2
    2
      sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java
  9. 2
    2
      sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java
  10. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml
  11. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_all.xml
  12. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_action_plans.xml
  13. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_assigned.xml
  14. 2
    2
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_component_root.xml
  15. 2
    2
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_date_creation.xml
  16. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_ids.xml
  17. 1
    1
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml
  18. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_planned.xml
  19. 1
    1
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_query.xml
  20. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_resolved.xml
  21. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_rules.xml
  22. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml
  23. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_open_issues.xml
  24. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_assignee.xml
  25. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_close_date.xml
  26. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_creation_date.xml
  27. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_severity.xml
  28. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_status.xml
  29. 3
    3
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_update_date.xml
  30. 1
    1
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml
  31. 1
    1
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml
  32. 1
    1
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate.xml
  33. 1
    1
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml
  34. 1
    1
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml
  35. 1
    1
      sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml
  36. 2
    2
      sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml
  37. 1
    1
      sonar-server/src/main/webapp/WEB-INF/db/migrate/395_create_issues.rb
  38. 42
    0
      sonar-server/src/main/webapp/WEB-INF/db/migrate/398_delete_review_duplications.rb
  39. 163
    0
      sonar-server/src/main/webapp/WEB-INF/db/migrate/399_migrate_violations_to_issues.rb

+ 2
- 2
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java View 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

+ 8
- 8
sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java View 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));

+ 1
- 1
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java View 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

+ 6
- 6
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml View 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,
@@ -69,11 +69,11 @@
<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>

@@ -85,11 +85,11 @@
</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>

@@ -110,7 +110,7 @@
reporter=#{reporter},
assignee=#{assignee},
author_login=#{authorLogin},
attributes=#{attributes},
issue_attributes=#{issueAttributes},
issue_creation_date=#{issueCreationDate},
issue_update_date=#{issueUpdateDate},
issue_close_date=#{issueCloseDate},

+ 2
- 0
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql View 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;

+ 1
- 1
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl View 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,

+ 1
- 1
sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java View 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();

+ 2
- 2
sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java View 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)

+ 2
- 2
sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java View 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");


+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_all.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_action_plans.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_assigned.xml View 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"

+ 2
- 2
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_component_root.xml View 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"

+ 2
- 2
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_date_creation.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_ids.xml View 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"

+ 1
- 1
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_planned.xml View 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"

+ 1
- 1
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_query.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_resolved.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_rules.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_open_issues.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_assignee.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_close_date.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_creation_date.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_severity.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_status.xml View 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"

+ 3
- 3
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_update_date.xml View 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"

+ 1
- 1
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml View 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"

+ 1
- 1
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml View 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"

+ 1
- 1
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate.xml View 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]"

+ 1
- 1
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml View 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"

+ 1
- 1
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml View 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"

+ 1
- 1
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml View 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"

+ 2
- 2
sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml View 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"

+ 1
- 1
sonar-server/src/main/webapp/WEB-INF/db/migrate/395_create_issues.rb View 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

+ 42
- 0
sonar-server/src/main/webapp/WEB-INF/db/migrate/398_delete_review_duplications.rb View File

@@ -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

+ 163
- 0
sonar-server/src/main/webapp/WEB-INF/db/migrate/399_migrate_violations_to_issues.rb View File

@@ -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

Loading…
Cancel
Save