diff options
author | Aurelien Poscia <aurelien.poscia@sonarsource.com> | 2022-06-08 17:11:15 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-06-15 20:03:02 +0000 |
commit | b7206c7c6fd9a77f2bea2a9c1bb004d9366f748a (patch) | |
tree | ef92fb477a99769bbc46e9f72a7f95493d7fe919 /server/sonar-webserver-es | |
parent | 1d5c0a3bb6123d0e9754238f7017384fdc7526f9 (diff) | |
download | sonarqube-b7206c7c6fd9a77f2bea2a9c1bb004d9366f748a.tar.gz sonarqube-b7206c7c6fd9a77f2bea2a9c1bb004d9366f748a.zip |
SONAR-11599 drop module_uuid from ES index, api/issues/search and issueDto.
Diffstat (limited to 'server/sonar-webserver-es')
6 files changed, 2 insertions, 57 deletions
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java index dd303ee35c4..459a89763fb 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java @@ -122,7 +122,6 @@ import static org.sonar.server.issue.index.IssueIndex.Facet.CWE; import static org.sonar.server.issue.index.IssueIndex.Facet.DIRECTORIES; import static org.sonar.server.issue.index.IssueIndex.Facet.FILES; import static org.sonar.server.issue.index.IssueIndex.Facet.LANGUAGES; -import static org.sonar.server.issue.index.IssueIndex.Facet.MODULE_UUIDS; import static org.sonar.server.issue.index.IssueIndex.Facet.OWASP_TOP_10; import static org.sonar.server.issue.index.IssueIndex.Facet.OWASP_TOP_10_2021; import static org.sonar.server.issue.index.IssueIndex.Facet.PROJECT_UUIDS; @@ -151,7 +150,6 @@ import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_KEY; import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_LANGUAGE; import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_LINE; import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_MODULE_PATH; -import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_MODULE_UUID; import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_NEW_CODE_REFERENCE; import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_OWASP_TOP_10; import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_OWASP_TOP_10_2021; @@ -203,7 +201,6 @@ public class IssueIndex { public static final String FACET_PROJECTS = "projects"; public static final String FACET_ASSIGNED_TO_ME = "assigned_to_me"; - public static final String FACET_MODULES = "moduleUuids"; private static final int DEFAULT_FACET_SIZE = 15; private static final int MAX_FACET_SIZE = 100; @@ -244,7 +241,6 @@ public class IssueIndex { TAGS(PARAM_TAGS, FIELD_ISSUE_TAGS, STICKY, MAX_FACET_SIZE), AUTHOR(PARAM_AUTHOR, FIELD_ISSUE_AUTHOR_LOGIN, STICKY, MAX_FACET_SIZE), PROJECT_UUIDS(FACET_PROJECTS, FIELD_ISSUE_PROJECT_UUID, STICKY, MAX_FACET_SIZE), - MODULE_UUIDS(FACET_MODULES, FIELD_ISSUE_MODULE_UUID, STICKY, MAX_FACET_SIZE), FILES(PARAM_FILES, FIELD_ISSUE_FILE_PATH, STICKY, MAX_FACET_SIZE), DIRECTORIES(PARAM_DIRECTORIES, FIELD_ISSUE_DIRECTORY_PATH, STICKY, MAX_FACET_SIZE), ASSIGNEES(PARAM_ASSIGNEES, FIELD_ISSUE_ASSIGNEE_UUID, STICKY, MAX_FACET_SIZE), @@ -511,9 +507,6 @@ public class IssueIndex { "__module", new SimpleFieldFilterScope(FIELD_ISSUE_MODULE_PATH), createTermsFilter(FIELD_ISSUE_MODULE_PATH, query.moduleRootUuids())); filters.addFilter( - FIELD_ISSUE_MODULE_UUID, new SimpleFieldFilterScope(FIELD_ISSUE_MODULE_UUID), - createTermsFilter(FIELD_ISSUE_MODULE_UUID, query.moduleUuids())); - filters.addFilter( FIELD_ISSUE_DIRECTORY_PATH, new SimpleFieldFilterScope(FIELD_ISSUE_DIRECTORY_PATH), createTermsFilter(FIELD_ISSUE_DIRECTORY_PATH, query.directories())); filters.addFilter( @@ -701,7 +694,6 @@ public class IssueIndex { AllFilters queryFilters, SearchSourceBuilder esRequest) { addFacetIfNeeded(options, aggregationHelper, esRequest, STATUSES, NO_SELECTED_VALUES); addFacetIfNeeded(options, aggregationHelper, esRequest, PROJECT_UUIDS, query.projectUuids().toArray()); - addFacetIfNeeded(options, aggregationHelper, esRequest, MODULE_UUIDS, query.moduleUuids().toArray()); addFacetIfNeeded(options, aggregationHelper, esRequest, DIRECTORIES, query.directories().toArray()); addFacetIfNeeded(options, aggregationHelper, esRequest, FILES, query.files().toArray()); addFacetIfNeeded(options, aggregationHelper, esRequest, SCOPES, query.scopes().toArray()); diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java index 140afa3fcd1..fb743517548 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java @@ -66,7 +66,6 @@ public class IssueQuery { private final Collection<String> statuses; private final Collection<String> resolutions; private final Collection<String> components; - private final Collection<String> modules; private final Collection<String> moduleRoots; private final Collection<String> projects; private final Collection<String> directories; @@ -107,7 +106,6 @@ public class IssueQuery { this.statuses = defaultCollection(builder.statuses); this.resolutions = defaultCollection(builder.resolutions); this.components = defaultCollection(builder.components); - this.modules = defaultCollection(builder.modules); this.moduleRoots = defaultCollection(builder.moduleRoots); this.projects = defaultCollection(builder.projects); this.directories = defaultCollection(builder.directories); @@ -163,10 +161,6 @@ public class IssueQuery { return components; } - public Collection<String> moduleUuids() { - return modules; - } - public Collection<String> moduleRootUuids() { return moduleRoots; } @@ -326,7 +320,6 @@ public class IssueQuery { private Collection<String> statuses; private Collection<String> resolutions; private Collection<String> components; - private Collection<String> modules; private Collection<String> moduleRoots; private Collection<String> projects; private Collection<String> directories; @@ -390,11 +383,6 @@ public class IssueQuery { return this; } - public Builder moduleUuids(@Nullable Collection<String> l) { - this.modules = l; - return this; - } - public Builder moduleRootUuids(@Nullable Collection<String> l) { this.moduleRoots = l; return this; diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java index 6b08ec07bd9..989936ff93b 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java @@ -398,14 +398,8 @@ public class IssueQueryFactory { } private static void addDirectories(IssueQuery.Builder builder, List<ComponentDto> directories) { - Collection<String> directoryModuleUuids = new HashSet<>(); - Collection<String> directoryPaths = new HashSet<>(); - for (ComponentDto directory : directories) { - directoryModuleUuids.add(directory.moduleUuid()); - directoryPaths.add(directory.path()); - } - builder.moduleUuids(directoryModuleUuids); - builder.directories(directoryPaths); + Set<String> paths = directories.stream().map(ComponentDto::path).collect(Collectors.toSet()); + builder.directories(paths); } private List<ComponentDto> getComponentsFromKeys(DbSession dbSession, Collection<String> componentKeys, @Nullable String branch, @Nullable String pullRequest) { diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java index eb31178750a..a41d651ba9a 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java @@ -113,25 +113,6 @@ public class IssueIndexFiltersTest { } @Test - public void filter_by_modules() { - ComponentDto project = newPrivateProjectDto(); - ComponentDto module = newModuleDto(project); - ComponentDto subModule = newModuleDto(module); - ComponentDto file = newFileDto(subModule, null); - - indexIssues( - newDoc("I3", module), - newDoc("I5", subModule), - newDoc("I2", file)); - - assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList(project.uuid())).moduleUuids(singletonList(file.uuid()))); - assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())).moduleUuids(singletonList(module.uuid())), "I3"); - assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())).moduleUuids(singletonList(subModule.uuid())), "I2", "I5"); - assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList(project.uuid())).moduleUuids(singletonList(project.uuid()))); - assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList(project.uuid())).moduleUuids(singletonList("unknown"))); - } - - @Test public void filter_by_components_on_contextualized_search() { ComponentDto project = newPrivateProjectDto(); ComponentDto module = newModuleDto(project); @@ -181,8 +162,6 @@ public class IssueIndexFiltersTest { assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList("unknown"))); assertThatSearchReturnsOnly(IssueQuery.builder().projectUuids(singletonList(project.uuid())), "I1", "I2", "I3", "I4", "I5", "I6"); assertThatSearchReturnsOnly(IssueQuery.builder().viewUuids(singletonList(view)), "I1", "I2", "I3", "I4", "I5", "I6"); - assertThatSearchReturnsOnly(IssueQuery.builder().moduleUuids(singletonList(module.uuid())), "I3", "I4"); - assertThatSearchReturnsOnly(IssueQuery.builder().moduleUuids(singletonList(subModule.uuid())), "I5", "I6"); assertThatSearchReturnsOnly(IssueQuery.builder().files(singletonList(file1.path())), "I2"); assertThatSearchReturnsOnly(IssueQuery.builder().files(asList(file1.path(), file2.path(), file3.path())), "I2", "I4", "I6"); } @@ -296,7 +275,6 @@ public class IssueIndexFiltersTest { newDoc("I6", branchFile)); assertThatSearchReturnsOnly(IssueQuery.builder().branchUuid(branch.uuid()).mainBranch(false), "I4", "I5", "I6"); - assertThatSearchReturnsOnly(IssueQuery.builder().moduleUuids(singletonList(branchModule.uuid())).branchUuid(branch.uuid()).mainBranch(false), "I5", "I6"); assertThatSearchReturnsOnly(IssueQuery.builder().files(singletonList(branchFile.path())).branchUuid(branch.uuid()).mainBranch(false), "I6"); assertThatSearchReturnsEmpty(IssueQuery.builder().files(singletonList(branchFile.uuid())).mainBranch(false).branchUuid("unknown")); } diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java index 649e3f5abb8..a3dd520af59 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java @@ -311,7 +311,6 @@ public class IssueQueryFactoryTest { assertThat(query.componentUuids()).isEmpty(); assertThat(query.projectUuids()).isEmpty(); - assertThat(query.moduleUuids()).isEmpty(); assertThat(query.moduleRootUuids()).isEmpty(); assertThat(query.directories()).isEmpty(); assertThat(query.files()).isEmpty(); @@ -508,7 +507,6 @@ public class IssueQueryFactoryTest { IssueQuery query = underTest.create(request); - assertThat(query.moduleUuids()).containsOnly(dir.moduleUuid()); assertThat(query.directories()).containsOnly(dir.path()); assertThat(query.onComponentOnly()).isFalse(); } diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryTest.java index 567daa7814d..907e5b34bac 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryTest.java @@ -45,7 +45,6 @@ public class IssueQueryTest { .resolutions(List.of(Issue.RESOLUTION_FALSE_POSITIVE)) .projectUuids(List.of("PROJECT")) .componentUuids(List.of("org/struts/Action.java")) - .moduleUuids(List.of("org.struts:core")) .rules(List.of(rule)) .assigneeUuids(List.of("gargantua")) .languages(List.of("xoo")) @@ -73,7 +72,6 @@ public class IssueQueryTest { assertThat(query.resolutions()).containsOnly(Issue.RESOLUTION_FALSE_POSITIVE); assertThat(query.projectUuids()).containsOnly("PROJECT"); assertThat(query.componentUuids()).containsOnly("org/struts/Action.java"); - assertThat(query.moduleUuids()).containsOnly("org.struts:core"); assertThat(query.assignees()).containsOnly("gargantua"); assertThat(query.languages()).containsOnly("xoo"); assertThat(query.tags()).containsOnly("tag1", "tag2"); @@ -128,7 +126,6 @@ public class IssueQueryTest { .issueKeys(null) .projectUuids(null) .componentUuids(null) - .moduleUuids(null) .statuses(null) .assigneeUuids(null) .resolutions(null) @@ -145,7 +142,6 @@ public class IssueQueryTest { assertThat(query.issueKeys()).isEmpty(); assertThat(query.projectUuids()).isEmpty(); assertThat(query.componentUuids()).isEmpty(); - assertThat(query.moduleUuids()).isEmpty(); assertThat(query.statuses()).isEmpty(); assertThat(query.assignees()).isEmpty(); assertThat(query.resolutions()).isEmpty(); @@ -166,7 +162,6 @@ public class IssueQueryTest { assertThat(query.issueKeys()).isEmpty(); assertThat(query.projectUuids()).isEmpty(); assertThat(query.componentUuids()).isEmpty(); - assertThat(query.moduleUuids()).isEmpty(); assertThat(query.statuses()).isEmpty(); assertThat(query.assignees()).isEmpty(); assertThat(query.resolutions()).isEmpty(); |