From 65ddc598126341a0054ac9ba0f1f3f137966d73b Mon Sep 17 00:00:00 2001 From: Machac Date: Wed, 2 Aug 2023 13:51:49 +0200 Subject: [PATCH] [NAE-1909] Elasticsearch index per URI node - implement --- .../engine/elastic/domain/IndexAwareElasticSearchRequest.java | 3 ++- .../application/engine/elastic/service/ElasticCaseService.java | 2 +- .../application/engine/workflow/web/WorkflowController.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/netgrif/application/engine/elastic/domain/IndexAwareElasticSearchRequest.java b/src/main/java/com/netgrif/application/engine/elastic/domain/IndexAwareElasticSearchRequest.java index baffcbf616..01451d0ffa 100644 --- a/src/main/java/com/netgrif/application/engine/elastic/domain/IndexAwareElasticSearchRequest.java +++ b/src/main/java/com/netgrif/application/engine/elastic/domain/IndexAwareElasticSearchRequest.java @@ -5,6 +5,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import java.util.Optional; import java.util.ArrayList; import java.util.Collections; @@ -47,7 +48,7 @@ public static IndexAwareElasticSearchRequest ofIndexes(List indexNames) } public static IndexAwareElasticSearchRequest ofMenuItems(List menuItemIds) { - return new IndexAwareElasticSearchRequest(Collections.unmodifiableList(menuItemIds), null); + return new IndexAwareElasticSearchRequest(Collections.unmodifiableList(Optional.ofNullable(menuItemIds).orElse(Collections.emptyList())), null); } public boolean doQueryAll() { diff --git a/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseService.java b/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseService.java index 1ca0879423..9c3f33e0de 100644 --- a/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseService.java +++ b/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseService.java @@ -566,7 +566,7 @@ protected List getIndexes(IndexAwareElasticSearchRequest request) { List result = new ArrayList<>(); if (request.getIndexNames() != null && !request.getIndexNames().isEmpty()) { if (request.doQueryAll()) { - result.addAll(indexService.getAllDynamicIndexes()); + result.addAll(indexService.getAllIndexes()); } else { result.addAll(request.getIndexNames()); } diff --git a/src/main/java/com/netgrif/application/engine/workflow/web/WorkflowController.java b/src/main/java/com/netgrif/application/engine/workflow/web/WorkflowController.java index 68d7190451..701ecce1b0 100644 --- a/src/main/java/com/netgrif/application/engine/workflow/web/WorkflowController.java +++ b/src/main/java/com/netgrif/application/engine/workflow/web/WorkflowController.java @@ -123,7 +123,7 @@ public PagedModel search2(@QuerydslPredicate(root = Case.class) Pr public PagedModel searchByIndex(@RequestBody IndexAwareApiCaseSearchRequest searchBody, @RequestParam(defaultValue = "OR") MergeFilterOperation operation, Pageable pageable, PagedResourcesAssembler assembler, Authentication auth, Locale locale) { LoggedUser user = (LoggedUser) auth.getPrincipal(); IndexAwareElasticSearchRequest elasticRequest; - if (searchBody.getSearchAll()) { + if (searchBody.getSearchAll() || searchBody.getMenuItemIds() == null || searchBody.getMenuItemIds().isEmpty()) { elasticRequest = IndexAwareElasticSearchRequest.all(); } else { elasticRequest = IndexAwareElasticSearchRequest.ofMenuItems(searchBody.getMenuItemIds());