Skip to content

Commit

Permalink
Experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
bvsharp committed Sep 30, 2024
1 parent 399f9c6 commit a407e54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/main/java/org/folio/fqm/service/CrossTenantQueryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getTenantsToQuery(EntityType entityType, boolean forceCrossTenantQuery) {
log.info("GETTING TENANTS TO QUERY");
Expand All @@ -43,6 +45,18 @@ public List<String> getTenantsToQuery(EntityType entityType, boolean forceCrossT
return List.of(executionContext.getTenantId());
}

return getTenants(entityType, ecsTenantInfo);
}

public List<String> getTenantsToQueryForApi(EntityType entityType) {
Map<String, String> 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<String> getTenants(EntityType entityType, Map<String, String> ecsTenantInfo) {
List<String> 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());
Expand All @@ -55,7 +69,6 @@ public List<String> getTenantsToQuery(EntityType entityType, boolean forceCrossT
return List.of(executionContext.getTenantId());
}

List<String> tenantsToQuery = new ArrayList<>();
tenantsToQuery.add(centralTenantId);
List<Map<String, String>> userTenantMaps = getUserTenants(ecsTenantInfo.get("consortiumId"), executionContext.getUserId().toString());
for (var userMap : userTenantMaps) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/folio/fqm/service/EntityTypeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public ColumnValues getFieldValues(UUID entityTypeId, String fieldName, @Nullabl
}

if (field.getValueSourceApi() != null) {
List<String> tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType, false);
List<String> tenantsToQuery = crossTenantQueryService.getTenantsToQueryForApi(entityType);
log.info("Tenants to query: {}", tenantsToQuery);
return getFieldValuesFromApi(field, searchText, tenantsToQuery);
}
Expand Down

0 comments on commit a407e54

Please sign in to comment.