From cec77dd7a1295e1ddc3247103852476384edbc9c Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 23 Mar 2016 15:47:05 +0100 Subject: [PATCH] SONAR-7473 Drop 'reporter' field from ES --- .../benchmark/IssueIndexBenchmarkTest.java | 1 - .../sonar/server/issue/index/IssueDoc.java | 11 ++++--- .../issue/index/IssueIndexDefinition.java | 2 -- .../issue/index/IssueResultSetIterator.java | 30 +++++++++---------- .../server/issue/IssueServiceMediumTest.java | 2 -- .../org/sonar/server/issue/IssueTesting.java | 1 - .../index/IssueResultSetIteratorTest.java | 1 - .../IssueResultSetIteratorTest/one_issue.xml | 2 +- 8 files changed, 20 insertions(+), 30 deletions(-) diff --git a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java index 616a256f0ed..6131f87787b 100644 --- a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java +++ b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java @@ -191,7 +191,6 @@ public class IssueIndexBenchmarkTest { issue.setEffort(1000L); issue.setGap(3.14); issue.setLanguage("php"); - issue.setReporter(users.next()); issue.setRuleKey(rules.next()); issue.setResolution(resolutions.next()); issue.setStatus(statuses.next()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java index 03a29a0fbe6..777f4b14dfd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java @@ -144,10 +144,14 @@ public class IssueDoc extends BaseDoc implements Issue { return getNullableField(IssueIndexDefinition.FIELD_ISSUE_RESOLUTION); } + /** + * @deprecated since 5.5 + */ + @Deprecated @Override @CheckForNull public String reporter() { - return getNullableField(IssueIndexDefinition.FIELD_ISSUE_REPORTER); + throw new UnsupportedOperationException("manual issue feature has been dropped"); } @Override @@ -324,11 +328,6 @@ public class IssueDoc extends BaseDoc implements Issue { return this; } - public IssueDoc setReporter(@Nullable String s) { - setField(IssueIndexDefinition.FIELD_ISSUE_REPORTER, s); - return this; - } - public IssueDoc setAssignee(@Nullable String s) { setField(IssueIndexDefinition.FIELD_ISSUE_ASSIGNEE, s); return this; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java index 6945a72e2f6..224556589c2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java @@ -66,7 +66,6 @@ public class IssueIndexDefinition implements IndexDefinition { public static final String FIELD_ISSUE_MODULE_PATH = "modulePath"; public static final String FIELD_ISSUE_PROJECT_UUID = "project"; public static final String FIELD_ISSUE_DIRECTORY_PATH = "dirPath"; - public static final String FIELD_ISSUE_REPORTER = "reporter"; public static final String FIELD_ISSUE_RESOLUTION = "resolution"; public static final String FIELD_ISSUE_RULE_KEY = "ruleKey"; public static final String FIELD_ISSUE_SEVERITY = "severity"; @@ -125,7 +124,6 @@ public class IssueIndexDefinition implements IndexDefinition { issueMapping.createUuidPathField(FIELD_ISSUE_MODULE_PATH); issueMapping.stringFieldBuilder(FIELD_ISSUE_PROJECT_UUID).enableSorting().build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_DIRECTORY_PATH).docValues().build(); - issueMapping.stringFieldBuilder(FIELD_ISSUE_REPORTER).docValues().build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_RESOLUTION).build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_RULE_KEY).build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_SEVERITY).build(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java index 31f3eda2f22..823647b60a2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java @@ -66,15 +66,14 @@ class IssueResultSetIterator extends ResultSetIterator { "i.checksum", "i.status", "i.effort", - "i.reporter", "i.author_login", "i.issue_close_date", "i.issue_creation_date", "i.issue_update_date", "r.plugin_name", + "r.plugin_rule_key", // column 21 - "r.plugin_rule_key", "r.language", "p.uuid", "p.module_uuid_path", @@ -172,26 +171,25 @@ class IssueResultSetIterator extends ResultSetIterator { doc.setChecksum(rs.getString(12)); doc.setStatus(rs.getString(13)); doc.setEffort(getLong(rs, 14)); - doc.setReporter(rs.getString(15)); - doc.setAuthorLogin(rs.getString(16)); - doc.setFuncCloseDate(longToDate(getLong(rs, 17))); - doc.setFuncCreationDate(longToDate(getLong(rs, 18))); - doc.setFuncUpdateDate(longToDate(getLong(rs, 19))); - String ruleRepo = rs.getString(20); - String ruleKey = rs.getString(21); + doc.setAuthorLogin(rs.getString(15)); + doc.setFuncCloseDate(longToDate(getLong(rs, 16))); + doc.setFuncCreationDate(longToDate(getLong(rs, 17))); + doc.setFuncUpdateDate(longToDate(getLong(rs, 18))); + String ruleRepo = rs.getString(19); + String ruleKey = rs.getString(20); doc.setRuleKey(RuleKey.of(ruleRepo, ruleKey).toString()); - doc.setLanguage(rs.getString(22)); - doc.setComponentUuid(rs.getString(23)); - String moduleUuidPath = rs.getString(24); + doc.setLanguage(rs.getString(21)); + doc.setComponentUuid(rs.getString(22)); + String moduleUuidPath = rs.getString(23); doc.setModuleUuid(extractModule(moduleUuidPath)); doc.setModuleUuidPath(moduleUuidPath); - String scope = rs.getString(26); - String filePath = extractFilePath(rs.getString(25), scope); + String scope = rs.getString(25); + String filePath = extractFilePath(rs.getString(24), scope); doc.setFilePath(filePath); doc.setDirectoryPath(extractDirPath(doc.filePath(), scope)); - String tags = rs.getString(27); + String tags = rs.getString(26); doc.setTags(ImmutableList.copyOf(TAGS_SPLITTER.split(tags == null ? "" : tags))); - doc.setType(RuleType.valueOf(rs.getInt(28))); + doc.setType(RuleType.valueOf(rs.getInt(27))); return doc; } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java index bd8f8b59a70..d8009ea2ac8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java @@ -260,7 +260,6 @@ public class IssueServiceMediumTest { assertThat(manualIssue.message()).isEqualTo("Fix it"); assertThat(manualIssue.line()).isNull(); assertThat(manualIssue.severity()).isEqualTo(Severity.MINOR); - assertThat(manualIssue.reporter()).isEqualTo("john"); } @Test @@ -286,7 +285,6 @@ public class IssueServiceMediumTest { assertThat(manualIssue.line()).isEqualTo(1); assertThat(manualIssue.severity()).isEqualTo(Severity.MINOR); assertThat(manualIssue.gap()).isNull(); - assertThat(manualIssue.reporter()).isEqualTo("john"); assertThat(manualIssue.assignee()).isEqualTo("arthur"); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java index ded112a90ef..d37888487bd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java @@ -64,7 +64,6 @@ public class IssueTesting { doc.setKey("ABC"); doc.setRuleKey(RuleTesting.XOO_X1.toString()); doc.setType(RuleType.CODE_SMELL); - doc.setReporter(null); doc.setAssignee("steve"); doc.setAuthorLogin("roger"); doc.setLanguage("xoo"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueResultSetIteratorTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueResultSetIteratorTest.java index 93acb15a7ed..25fb7a093b1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueResultSetIteratorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueResultSetIteratorTest.java @@ -69,7 +69,6 @@ public class IssueResultSetIteratorTest { assertThat(issue.isManualSeverity()).isFalse(); assertThat(issue.assignee()).isEqualTo("guy1"); assertThat(issue.authorLogin()).isEqualTo("guy2"); - assertThat(issue.reporter()).isEqualTo("john"); assertThat(issue.checksum()).isEqualTo("FFFFF"); assertThat(issue.line()).isEqualTo(444); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("squid", "AvoidCycles")); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/one_issue.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/one_issue.xml index 5b8f3cd046c..d4343d23191 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/one_issue.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/one_issue.xml @@ -24,7 +24,7 @@ component_uuid="FILE1" project_uuid="PROJECT1" rule_id="200" - reporter="john" + reporter="[null]" issue_attributes="JIRA=http://jira.com" action_plan_key="PLAN1" tags="tag1,tag2,tag3" -- 2.39.5