From a407e544f122be2ecfa49921e4bc1d863051d708 Mon Sep 17 00:00:00 2001 From: Bobby Sharp Date: Mon, 30 Sep 2024 14:15:25 -0400 Subject: [PATCH] Experimenting --- .../fqm/service/CrossTenantQueryService.java | 15 ++++++++++++++- .../org/folio/fqm/service/EntityTypeService.java | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/folio/fqm/service/CrossTenantQueryService.java b/src/main/java/org/folio/fqm/service/CrossTenantQueryService.java index 601f5dc5..4bd7ad6c 100644 --- a/src/main/java/org/folio/fqm/service/CrossTenantQueryService.java +++ b/src/main/java/org/folio/fqm/service/CrossTenantQueryService.java @@ -26,6 +26,8 @@ public class CrossTenantQueryService { private static final String COMPOSITE_INSTANCES_ID = "6b08439b-4f8e-4468-8046-ea620f5cfb74"; private static final String SIMPLE_INSTANCES_ID = "8fc4a9d2-7ccf-4233-afb8-796911839862"; + private static final String SIMPLE_HOLDINGS_ID = "30a5cfad-1868-4f46-86b9-a6ef67e2d9bf"; + private static final String SIMPLE_ITEMS_ID = "372e025a-9444-473a-9ffd-fa0f63db1674"; public List getTenantsToQuery(EntityType entityType, boolean forceCrossTenantQuery) { log.info("GETTING TENANTS TO QUERY"); @@ -43,6 +45,18 @@ public List getTenantsToQuery(EntityType entityType, boolean forceCrossT return List.of(executionContext.getTenantId()); } + return getTenants(entityType, ecsTenantInfo); + } + + public List getTenantsToQueryForApi(EntityType entityType) { + Map ecsTenantInfo = getEcsTenantInfo(); + if (SIMPLE_INSTANCES_ID.equals(entityType.getId()) || SIMPLE_HOLDINGS_ID.equals(entityType.getId()) || SIMPLE_ITEMS_ID.equals(entityType.getId())) { + return getTenants(entityType, ecsTenantInfo); + } return List.of(executionContext.getTenantId()); + } + + private List getTenants(EntityType entityType, Map ecsTenantInfo) { + List tenantsToQuery = new ArrayList<>(); String centralTenantId = getCentralTenantId(ecsTenantInfo); if (!executionContext.getTenantId().equals(centralTenantId)) { log.debug("Tenant {} is not central tenant. Running intra-tenant query.", executionContext.getTenantId()); @@ -55,7 +69,6 @@ public List getTenantsToQuery(EntityType entityType, boolean forceCrossT return List.of(executionContext.getTenantId()); } - List tenantsToQuery = new ArrayList<>(); tenantsToQuery.add(centralTenantId); List> userTenantMaps = getUserTenants(ecsTenantInfo.get("consortiumId"), executionContext.getUserId().toString()); for (var userMap : userTenantMaps) { diff --git a/src/main/java/org/folio/fqm/service/EntityTypeService.java b/src/main/java/org/folio/fqm/service/EntityTypeService.java index bf4663f0..16c25860 100644 --- a/src/main/java/org/folio/fqm/service/EntityTypeService.java +++ b/src/main/java/org/folio/fqm/service/EntityTypeService.java @@ -127,7 +127,7 @@ public ColumnValues getFieldValues(UUID entityTypeId, String fieldName, @Nullabl } if (field.getValueSourceApi() != null) { - List tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType, false); + List tenantsToQuery = crossTenantQueryService.getTenantsToQueryForApi(entityType); log.info("Tenants to query: {}", tenantsToQuery); return getFieldValuesFromApi(field, searchText, tenantsToQuery); }