From: Julien Lancelot Date: Tue, 21 May 2013 13:38:15 +0000 (+0200) Subject: Revert "SONAR-4301 Replace issues.severity column type from String to Integer" X-Git-Tag: 3.6~325 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c1211d5b9f0674832f8a33da9f0f2c3bf66ff146;p=sonarqube.git Revert "SONAR-4301 Replace issues.severity column type from String to Integer" This reverts commit 2c2728075a1c142965bf6c018ba94919955f80d8. --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java index 170bf467e3c..e45a749a33d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java @@ -43,6 +43,7 @@ import org.sonar.core.issue.db.IssueDto; import org.sonar.core.issue.workflow.IssueWorkflow; import java.util.Collection; +import java.util.Map; @DependedUpon(DecoratorBarriers.END_OF_ISSUES_UPDATES) public class IssueTrackingDecorator implements Decorator { @@ -147,11 +148,11 @@ public class IssueTrackingDecorator implements Decorator { // fields to update with current values if (ref.isManualSeverity()) { issue.setManualSeverity(true); - issue.setSeverity(ref.getSeverityLabel()); + issue.setSeverity(ref.getSeverity()); } else { // Emulate change of severity in the current scan. String severity = issue.severity(); - issue.setSeverity(ref.getSeverityLabel()); + issue.setSeverity(ref.getSeverity()); updater.setSeverity(issue, severity, changeContext); } Integer line = issue.line(); diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java index 8bf64abc1a3..de545172be5 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java @@ -21,18 +21,14 @@ package org.sonar.core.issue.db; import com.google.common.base.Objects; import com.google.common.base.Preconditions; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.sonar.api.rule.RuleKey; -import org.sonar.api.rule.Severity; import org.sonar.api.utils.KeyValueFormat; import org.sonar.core.issue.DefaultIssue; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - import java.util.Date; /** @@ -44,7 +40,7 @@ public final class IssueDto { private String kee; private Integer resourceId; private Integer ruleId; - private Integer severity; + private String severity; private boolean manualSeverity; private String message; private Integer line; @@ -119,11 +115,11 @@ public final class IssueDto { } @CheckForNull - public Integer getSeverity() { + public String getSeverity() { return severity; } - public IssueDto setSeverity(@Nullable Integer severity) { + public IssueDto setSeverity(@Nullable String severity) { this.severity = severity; return this; } @@ -292,11 +288,6 @@ public final class IssueDto { return componentKey; } - @CheckForNull - public String getSeverityLabel() { - return severity != null ? Severity.ALL.get(severity - 1) : null; - } - /** * Only for unit tests */ @@ -319,18 +310,6 @@ public final class IssueDto { return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); } - private static Integer toSeverityIndex(final String severity){ - if (severity != null) { - return Iterables.indexOf(Severity.ALL, new Predicate() { - @Override - public boolean apply(String currentSeverity) { - return currentSeverity.equals(severity); - } - }) + 1; - } - return null; - } - public static IssueDto toDtoForInsert(DefaultIssue issue, Integer componentId, Integer ruleId, Date now) { return new IssueDto() .setKee(issue.key()) @@ -339,7 +318,7 @@ public final class IssueDto { .setEffortToFix(issue.effortToFix()) .setResolution(issue.resolution()) .setStatus(issue.status()) - .setSeverity(toSeverityIndex(issue.severity())) + .setSeverity(issue.severity()) .setChecksum(issue.getChecksum()) .setManualSeverity(issue.manualSeverity()) .setReporter(issue.reporter()) @@ -366,7 +345,7 @@ public final class IssueDto { .setEffortToFix(issue.effortToFix()) .setResolution(issue.resolution()) .setStatus(issue.status()) - .setSeverity(toSeverityIndex(issue.severity())) + .setSeverity(issue.severity()) .setChecksum(issue.getChecksum()) .setManualSeverity(issue.manualSeverity()) .setReporter(issue.reporter()) @@ -388,7 +367,7 @@ public final class IssueDto { issue.setMessage(message); issue.setEffortToFix(effortToFix); issue.setLine(line); - issue.setSeverity(getSeverityLabel()); + issue.setSeverity(severity); issue.setReporter(reporter); issue.setAssignee(assignee); issue.setAttributes(KeyValueFormat.parse(Objects.firstNonNull(attributes, ""))); diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index 39fdd04cd98..aafefbd4286 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -32,7 +32,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 399; + public static final int LAST_VERSION = 397; public static enum Status { UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml index 01991164893..9717a2417cf 100644 --- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml @@ -210,9 +210,9 @@ #{key} - + and i.severity in - #{severity} + #{severity} diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index 2311cec80a3..6b3fcd5313f 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -159,9 +159,9 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('388'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('391'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('392'); 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; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl index e7bcf22855a..640817337a5 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl @@ -521,7 +521,7 @@ CREATE TABLE "ISSUES" ( "KEE" VARCHAR(50) UNIQUE NOT NULL, "RESOURCE_ID" INTEGER NOT NULL, "RULE_ID" INTEGER, - "SEVERITY" INTEGER, + "SEVERITY" VARCHAR(10), "MANUAL_SEVERITY" BOOLEAN NOT NULL, "MESSAGE" VARCHAR(4000), "LINE" INTEGER, diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java index 3c962585f19..cfb30567f21 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java @@ -51,7 +51,7 @@ public class IssueDaoTest extends AbstractDaoTestCase { assertThat(issue.getId()).isEqualTo(100L); assertThat(issue.getResourceId()).isEqualTo(401); assertThat(issue.getRuleId()).isEqualTo(500); - assertThat(issue.getSeverity()).isEqualTo(5); + assertThat(issue.getSeverity()).isEqualTo("BLOCKER"); assertThat(issue.isManualSeverity()).isFalse(); assertThat(issue.getMessage()).isNull(); assertThat(issue.getLine()).isEqualTo(200); @@ -227,9 +227,9 @@ public class IssueDaoTest extends AbstractDaoTestCase { IssueQuery query = IssueQuery.builder().sort(IssueQuery.Sort.SEVERITY).asc(true).build(); List results = newArrayList(dao.select(query)); assertThat(results).hasSize(3); - assertThat(results.get(0).getSeverityLabel()).isEqualTo("MINOR"); - assertThat(results.get(1).getSeverityLabel()).isEqualTo("MAJOR"); - assertThat(results.get(2).getSeverityLabel()).isEqualTo("BLOCKER"); + assertThat(results.get(0).getSeverity()).isEqualTo("BLOCKER"); + assertThat(results.get(1).getSeverity()).isEqualTo("MAJOR"); + assertThat(results.get(2).getSeverity()).isEqualTo("MINOR"); } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java index 551dc0926e3..9598b8c796d 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java @@ -63,7 +63,7 @@ public class IssueDtoTest { .setResolution(Issue.RESOLUTION_FALSE_POSITIVE) .setEffortToFix(15.0) .setLine(6) - .setSeverity(5) + .setSeverity("BLOCKER") .setMessage("message") .setManualSeverity(true) .setReporter("arthur") diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java index 7767c139710..d606a87080d 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java @@ -46,7 +46,7 @@ public class IssueMapperTest extends AbstractDaoTestCase { dto.setEffortToFix(3.14); dto.setResolution("FIXED"); dto.setStatus("RESOLVED"); - dto.setSeverity(5); + dto.setSeverity("BLOCKER"); dto.setReporter("emmerik"); dto.setAuthorLogin("morgan"); dto.setAssignee("karadoc"); @@ -79,7 +79,7 @@ public class IssueMapperTest extends AbstractDaoTestCase { dto.setEffortToFix(3.14); dto.setResolution("FIXED"); dto.setStatus("RESOLVED"); - dto.setSeverity(5); + dto.setSeverity("BLOCKER"); dto.setReporter("emmerik"); dto.setAuthorLogin("morgan"); dto.setAssignee("karadoc"); diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml index af6e601bb18..f960ecd1b62 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml @@ -8,7 +8,7 @@ kee="ABCDE" resource_id="400" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -32,7 +32,7 @@ kee="ABCDF" resource_id="400" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -56,7 +56,7 @@ kee="ABCDG" resource_id="400" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_all.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_all.xml index fb1aedd7222..3d7bd96af21 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_all.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_all.xml @@ -6,7 +6,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -30,7 +30,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -56,7 +56,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_action_plans.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_action_plans.xml index de78e71414d..5655372b58e 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_action_plans.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_action_plans.xml @@ -6,7 +6,7 @@ resource_id="401" rule_id="500" action_plan_key="ABC" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -31,7 +31,7 @@ resource_id="401" rule_id="500" action_plan_key="ABC" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -57,7 +57,7 @@ resource_id="401" rule_id="501" action_plan_key="DEF" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_assigned.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_assigned.xml index 1d3d7943d7e..f25c1c9e8ea 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_assigned.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_assigned.xml @@ -6,7 +6,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -30,7 +30,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -56,7 +56,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_component_root.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_component_root.xml index 2319088e7f0..34f07c20209 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_component_root.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_component_root.xml @@ -5,7 +5,7 @@ kee="100" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -29,7 +29,7 @@ kee="101" resource_id="402" rule_id="501" - severity="3" + severity="MAJOR" manual_severity="[false]" message="[null]" line="120" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_date_creation.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_date_creation.xml index c1fddd480d3..9b6f20c96ca 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_date_creation.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_date_creation.xml @@ -5,7 +5,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -29,7 +29,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_ids.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_ids.xml index d6f85f325c4..3d6ad15c5a0 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_ids.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_ids.xml @@ -6,7 +6,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -30,7 +30,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -56,7 +56,7 @@ kee="ABCDE" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml index 88ca9ebd960..d01f5342d87 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml @@ -5,7 +5,7 @@ kee="ABCDE" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_planned.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_planned.xml index 9aa1641068b..ded6b072043 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_planned.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_planned.xml @@ -6,7 +6,7 @@ resource_id="401" rule_id="500" action_plan_key="ABC" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -31,7 +31,7 @@ resource_id="401" rule_id="500" action_plan_key="ABC" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -57,7 +57,7 @@ resource_id="401" rule_id="501" action_plan_key="[null]" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_query.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_query.xml index 557be9b7ba5..816742b954b 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_query.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_query.xml @@ -5,7 +5,7 @@ kee="ABCDE" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_resolved.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_resolved.xml index 886fb14e175..371d3da3f4f 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_resolved.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_resolved.xml @@ -5,7 +5,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -29,7 +29,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -53,7 +53,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_rules.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_rules.xml index d20560f0811..d2af6661a9e 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_rules.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_rules.xml @@ -6,7 +6,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -30,7 +30,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -56,7 +56,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml index fb1aedd7222..3d7bd96af21 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml @@ -6,7 +6,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -30,7 +30,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -56,7 +56,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_open_issues.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_open_issues.xml index 8b3a9f44ca3..12f7036120e 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_open_issues.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_open_issues.xml @@ -5,7 +5,7 @@ kee="100" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -29,7 +29,7 @@ kee="101" resource_id="402" rule_id="501" - severity="3" + severity="MAJOR" manual_severity="[false]" message="[null]" line="120" @@ -53,7 +53,7 @@ kee="102" resource_id="402" rule_id="501" - severity="3" + severity="MAJOR" manual_severity="[false]" message="[null]" line="120" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_assignee.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_assignee.xml index 2f902a85565..41a97ef98b8 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_assignee.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_assignee.xml @@ -6,7 +6,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -30,7 +30,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -56,7 +56,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_close_date.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_close_date.xml index 9339d6e437e..b27051ff207 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_close_date.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_close_date.xml @@ -6,7 +6,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -30,7 +30,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -56,7 +56,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_creation_date.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_creation_date.xml index b4c6ba44d29..d84b71fa09b 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_creation_date.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_creation_date.xml @@ -5,7 +5,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -29,7 +29,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -53,7 +53,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_severity.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_severity.xml index e5ffc2e5fda..9dae4080973 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_severity.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_severity.xml @@ -5,7 +5,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="2" + severity="MINOR" manual_severity="[false]" message="[null]" line="200" @@ -29,7 +29,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -53,7 +53,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="3" + severity="MAJOR" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_status.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_status.xml index 4e12d924be8..b510a5c447a 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_status.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_status.xml @@ -6,7 +6,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -30,7 +30,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -56,7 +56,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_update_date.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_update_date.xml index a74da66a8c8..769bae1454d 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_update_date.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_update_date.xml @@ -5,7 +5,7 @@ kee="ABCDE-1" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -29,7 +29,7 @@ kee="ABCDE-2" resource_id="401" rule_id="500" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" @@ -53,7 +53,7 @@ kee="ABCDE-3" resource_id="401" rule_id="501" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="[null]" line="200" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml index e32f7d9f30c..69e5160f962 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml @@ -4,7 +4,7 @@ kee="ABCDE" resource_id="123" rule_id="200" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="the message" line="500" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml index 7bcccd58b05..57bc88451ea 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml @@ -23,7 +23,7 @@ kee="ABCDE" resource_id="123" rule_id="200" - severity="5" + severity="BLOCKER" manual_severity="[false]" message="the message" line="500" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate.xml index 9e13008d3db..06ee1af1b50 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate.xml @@ -23,7 +23,7 @@ kee="ABCDE" resource_id="123" rule_id="200" - severity="1" + severity="INFO" manual_severity="[false]" message="old" line="[null]" diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml index 0a10ae36591..97ca9b21656 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml @@ -1,5 +1,5 @@ - - - - severitiesIndexSql; - private IssueQuery(Builder builder) { this.issueKeys = builder.issueKeys; this.severities = builder.severities; @@ -98,8 +89,6 @@ public class IssueQuery { this.pageSize = builder.pageSize; this.pageIndex = builder.pageIndex; this.requiredRole = builder.requiredRole; - - this.severitiesIndexSql = severitiesIndexSql(severities); } public Collection issueKeys() { @@ -192,23 +181,6 @@ public class IssueQuery { return new Builder(); } - private Collection severitiesIndexSql(@Nullable Collection severities) { - if (severities != null) { - return newArrayList(Iterables.transform(severities, new Function() { - @Override - public Integer apply(final String currentSeverity) { - return Iterables.indexOf(Severity.ALL, new Predicate() { - @Override - public boolean apply(String severity) { - return severity.equals(currentSeverity); - } - }) + 1; - }; - })); - } - return null; - } - public static class Builder { private Collection issueKeys; private Collection severities; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java index 938c5ff56f9..fb972c40cee 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java @@ -71,7 +71,6 @@ public class IssueQueryTest { assertThat(query.pageSize()).isEqualTo(10); assertThat(query.pageIndex()).isEqualTo(2); assertThat(query.requiredRole()).isEqualTo(UserRole.CODEVIEWER); - assertThat(query.severitiesIndexSql).containsOnly(5); } @Test diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/395_create_issues.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/395_create_issues.rb new file mode 100644 index 00000000000..2733202a82e --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/395_create_issues.rb @@ -0,0 +1,66 @@ +# +# 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 +# +class CreateIssues < ActiveRecord::Migration + + def self.up + create_table :issues do |t| + t.column :kee, :string, :null => false, :limit => 50 + t.column :resource_id, :integer, :null => false + t.column :rule_id, :integer, :null => true + t.column :severity, :string, :null => true, :limit => 10 + t.column :manual_severity, :boolean, :null => false + t.column :message, :string, :null => true, :limit => 4000 + t.column :line, :integer, :null => true + t.column :effort_to_fix, :decimal, :null => true, :precision => 30, :scale => 20 + t.column :status, :string , :null => true, :limit => 20 + t.column :resolution, :string , :null => true, :limit => 20 + t.column :checksum, :string , :null => true, :limit => 1000 + t.column :reporter, :string, :null => true, :limit => 40 + 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 + + # functional dates + t.column :issue_creation_date, :datetime, :null => true + t.column :issue_close_date, :datetime, :null => true + t.column :issue_update_date, :datetime, :null => true + + # technical dates + t.column :created_at, :datetime, :null => true + t.column :updated_at, :datetime, :null => true + end + + add_index :issues, :kee, :name => 'issues_kee', :unique => true + add_index :issues, :resource_id, :name => 'issues_resource_id' + add_index :issues, :rule_id, :name => 'issues_rule_id' + add_index :issues, :severity, :name => 'issues_severity' + add_index :issues, :status, :name => 'issues_status' + add_index :issues, :assignee, :name => 'issues_assignee' + add_index :issues, :action_plan_key, :name => 'issues_action_plan_key' + add_index :issues, :issue_creation_date, :name => 'issues_creation_date' + end + +end + diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/396_create_issue_changes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/396_create_issue_changes.rb new file mode 100644 index 00000000000..016380cf8f6 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/396_create_issue_changes.rb @@ -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 +# +class CreateIssueChanges < ActiveRecord::Migration + + def self.up + create_table :issue_changes do |t| + t.column :kee, :string, :null => true, :limit => 50 + t.column :issue_key, :string, :null => false, :limit => 50 + t.column :user_login, :string, :null => true, :limit => 40 + t.column :change_type, :string, :null => true, :limit => 20 + t.column :change_data, :text, :null => true + t.column :created_at, :datetime, :null => true + t.column :updated_at, :datetime, :null => true + end + + add_index :issue_changes, :kee, :name => 'issue_changes_kee' + add_index :issue_changes, :issue_key, :name => 'issue_changes_issue_key' + end + +end + diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/398_create_issues.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/398_create_issues.rb deleted file mode 100644 index 7a262906d3d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/398_create_issues.rb +++ /dev/null @@ -1,66 +0,0 @@ -# -# 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 -# -class CreateIssues < ActiveRecord::Migration - - def self.up - create_table :issues do |t| - t.column :kee, :string, :null => false, :limit => 50 - t.column :resource_id, :integer, :null => false - t.column :rule_id, :integer, :null => true - t.column :severity, :integer, :null => true - t.column :manual_severity, :boolean, :null => false - t.column :message, :string, :null => true, :limit => 4000 - t.column :line, :integer, :null => true - t.column :effort_to_fix, :decimal, :null => true, :precision => 30, :scale => 20 - t.column :status, :string , :null => true, :limit => 20 - t.column :resolution, :string , :null => true, :limit => 20 - t.column :checksum, :string , :null => true, :limit => 1000 - t.column :reporter, :string, :null => true, :limit => 40 - 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 - - # functional dates - t.column :issue_creation_date, :datetime, :null => true - t.column :issue_close_date, :datetime, :null => true - t.column :issue_update_date, :datetime, :null => true - - # technical dates - t.column :created_at, :datetime, :null => true - t.column :updated_at, :datetime, :null => true - end - - add_index :issues, :kee, :name => 'issues_kee', :unique => true - add_index :issues, :resource_id, :name => 'issues_resource_id' - add_index :issues, :rule_id, :name => 'issues_rule_id' - add_index :issues, :severity, :name => 'issues_severity' - add_index :issues, :status, :name => 'issues_status' - add_index :issues, :assignee, :name => 'issues_assignee' - add_index :issues, :action_plan_key, :name => 'issues_action_plan_key' - add_index :issues, :issue_creation_date, :name => 'issues_creation_date' - end - -end - diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/399_create_issue_changes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/399_create_issue_changes.rb deleted file mode 100644 index 016380cf8f6..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/399_create_issue_changes.rb +++ /dev/null @@ -1,42 +0,0 @@ -# -# 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 -# -class CreateIssueChanges < ActiveRecord::Migration - - def self.up - create_table :issue_changes do |t| - t.column :kee, :string, :null => true, :limit => 50 - t.column :issue_key, :string, :null => false, :limit => 50 - t.column :user_login, :string, :null => true, :limit => 40 - t.column :change_type, :string, :null => true, :limit => 20 - t.column :change_data, :text, :null => true - t.column :created_at, :datetime, :null => true - t.column :updated_at, :datetime, :null => true - end - - add_index :issue_changes, :kee, :name => 'issue_changes_kee' - add_index :issue_changes, :issue_key, :name => 'issue_changes_issue_key' - end - -end -