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
private String assignee;
private String authorLogin;
private String actionPlanKey;
- private String attributes;
+ private String issueAttributes;
// functional dates
private Date issueCreationDate;
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;
}
.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())
.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())
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));
*/
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
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},
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;
"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,
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();
for (int i = 0; i < 4500; i++) {
s.append('a');
}
- new IssueDto().setAttributes(s.toString());
+ new IssueDto().setIssueAttributes(s.toString());
}
@Test
.setManualSeverity(true)
.setReporter("arthur")
.setAssignee("perceval")
- .setAttributes("key=value")
+ .setIssueAttributes("key=value")
.setAuthorLogin("pierre")
.setIssueCreationDate(createdAt)
.setIssueUpdateDate(updatedAt)
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");
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");
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
reporter="[null]"
author_login="[null]"
assignee="[null]"
- attributes="[null]"
+ issue_attributes="[null]"
issue_creation_date="[null]"
issue_update_date="[null]"
issue_close_date="[null]"
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"
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"
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"
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"
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"
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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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