diff --git a/ramls/reindex-records/publishReindexRecords.json b/ramls/reindex-records/publishReindexRecords.json index 1ef24d167..4dc0eaed5 100644 --- a/ramls/reindex-records/publishReindexRecords.json +++ b/ramls/reindex-records/publishReindexRecords.json @@ -11,7 +11,7 @@ "recordType": { "description": "Inventory storage record type (e.g. instance, item, holding)", "type": "string", - "enum": ["instance", "item", "holding"] + "enum": ["instance", "item", "holdings"] }, "recordIdsRange": { "description": "Range of records IDs", diff --git a/src/main/java/org/folio/persist/InstanceRepository.java b/src/main/java/org/folio/persist/InstanceRepository.java index bb2ceda29..9abafe6b8 100644 --- a/src/main/java/org/folio/persist/InstanceRepository.java +++ b/src/main/java/org/folio/persist/InstanceRepository.java @@ -116,7 +116,8 @@ public Future getInstanceSet(boolean instance, boolean holdingsRecords } } - public Future> getReindexInstances(String fromId, String toId, boolean notConsortiumCentralTenant) { + public Future>> getReindexInstances(String fromId, String toId, + boolean notConsortiumRecords) { var sql = new StringBuilder("SELECT i.jsonb || jsonb_build_object('isBoundWith', EXISTS(SELECT 1 FROM "); sql.append(postgresClientFuturized.getFullTableName(BOUND_WITH_TABLE)); sql.append(" as bw JOIN "); @@ -126,15 +127,15 @@ public Future> getReindexInstances(String fromId, String toId, bool sql.append(" as hr ON hr.id = bw.holdingsrecordid WHERE hr.instanceId = i.id LIMIT 1)) FROM "); sql.append(postgresClientFuturized.getFullTableName(INSTANCE_TABLE)); sql.append(" i WHERE i.id >= '").append(fromId).append("' AND i.id <= '").append(toId).append("'"); - if (notConsortiumCentralTenant) { + if (notConsortiumRecords) { sql.append(" AND i.jsonb->>'source' NOT LIKE 'CONSORTIUM-%'"); } sql.append(";"); return postgresClient.select(sql.toString()).map(rows -> { - var resultList = new LinkedList(); + var resultList = new LinkedList>(); for (var row : rows) { - resultList.add(row.getJsonObject(0).encode()); + resultList.add(row.getJsonObject(0).getMap()); } return resultList; }); diff --git a/src/main/java/org/folio/rest/impl/InventoryReindexRecordsPublishApi.java b/src/main/java/org/folio/rest/impl/InventoryReindexRecordsPublishApi.java index 4c9c8b934..06ea713a9 100644 --- a/src/main/java/org/folio/rest/impl/InventoryReindexRecordsPublishApi.java +++ b/src/main/java/org/folio/rest/impl/InventoryReindexRecordsPublishApi.java @@ -34,7 +34,7 @@ public void postInventoryReindexRecordsPublish(PublishReindexRecords entity, case ITEM -> publishFuture = new ItemService(vertxContext, okapiHeaders) .publishReindexItemRecords(rangeId, fromId, toId); - case HOLDING -> + case HOLDINGS -> publishFuture = new HoldingsService(vertxContext, okapiHeaders) .publishReindexHoldingsRecords(rangeId, fromId, toId); default -> publishFuture = Future.failedFuture( diff --git a/src/main/java/org/folio/services/domainevent/HoldingDomainEventPublisher.java b/src/main/java/org/folio/services/domainevent/HoldingDomainEventPublisher.java index 8d9e833f9..44bc8ae21 100644 --- a/src/main/java/org/folio/services/domainevent/HoldingDomainEventPublisher.java +++ b/src/main/java/org/folio/services/domainevent/HoldingDomainEventPublisher.java @@ -30,7 +30,7 @@ public Future publishReindexHoldings(String key, List hold return succeededFuture(); } - return domainEventService.publishReindexRecords(key, PublishReindexRecords.RecordType.HOLDING, holdings); + return domainEventService.publishReindexRecords(key, PublishReindexRecords.RecordType.HOLDINGS, holdings); } @Override diff --git a/src/main/java/org/folio/services/domainevent/InstanceDomainEventPublisher.java b/src/main/java/org/folio/services/domainevent/InstanceDomainEventPublisher.java index 0b22dc6b3..6e31876be 100644 --- a/src/main/java/org/folio/services/domainevent/InstanceDomainEventPublisher.java +++ b/src/main/java/org/folio/services/domainevent/InstanceDomainEventPublisher.java @@ -22,7 +22,7 @@ public class InstanceDomainEventPublisher extends AbstractDomainEventPublisher { private static final Logger log = getLogger(InstanceDomainEventPublisher.class); - private final CommonDomainEventPublisher instanceReindexPublisher; + private final CommonDomainEventPublisher> instanceReindexPublisher; public InstanceDomainEventPublisher(Context context, Map okapiHeaders) { super(new InstanceRepository(context, okapiHeaders), @@ -32,7 +32,7 @@ public InstanceDomainEventPublisher(Context context, Map okapiHe REINDEX_RECORDS.fullTopicName(tenantId(okapiHeaders))); } - public Future publishReindexInstances(String key, List instances) { + public Future publishReindexInstances(String key, List> instances) { if (CollectionUtils.isEmpty(instances) || StringUtils.isBlank(key)) { return succeededFuture(); } diff --git a/src/test/java/org/folio/rest/impl/InventoryReindexRecordsPublishIT.java b/src/test/java/org/folio/rest/impl/InventoryReindexRecordsPublishIT.java index f33e97cf5..18b6f8d3d 100644 --- a/src/test/java/org/folio/rest/impl/InventoryReindexRecordsPublishIT.java +++ b/src/test/java/org/folio/rest/impl/InventoryReindexRecordsPublishIT.java @@ -137,7 +137,7 @@ void post_shouldReturn201_whenPublishingInstancesForReindex(Vertx vertx, EVENT_MESSAGE_MATCHERS.hasReindexEventMessageFor()); var event = kafkaMessages.stream().toList().get(0).getBody(); var records = event.getJsonArray("records").stream() - .map(o -> new JsonObject((String) o)) + .map(JsonObject::mapFrom) .toList(); Assertions.assertThat(event.getString("recordType")).isEqualTo(PublishReindexRecords.RecordType.INSTANCE.value()); Assertions.assertThat(records).contains(mainInstance, anotherInstance); @@ -151,7 +151,7 @@ private static Stream reindexTypesProvider() { List.of(new Item().withId(RECORD1_ID), new Item().withId(RECORD2_ID))), arguments( HOLDING_TABLE, - PublishReindexRecords.RecordType.HOLDING, + PublishReindexRecords.RecordType.HOLDINGS, List.of(new Holding().withId(RECORD1_ID), new Holding().withId(RECORD2_ID))) ); }