Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To release 17.3.3 #509

Merged
merged 7 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 17.3.3 2025-01-13
* Add new LocationUpdateKafkaProcessor to sync location with request table (CIRCSTORE-556)
* Add new class like ServicePointUpdateProcessorForRequest to sync RetrievalSP updates in Request records (CIRCSTORE-541)
* Extend ItemUpdateProcessorForRequest to sync item updates in Request records (CIRCSTORE-540)
* Filter request by Retrieval Service Point (CIRCSTORE-539)

## 17.3.2 2024-12-12
* Add Intermediate ECS request phase (CIRCSTORE-542)

Expand Down
10 changes: 9 additions & 1 deletion descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
{
"id": "configuration",
"version": "2.0"
},
{
"id": "locations",
"version": "3.1"
},
{
"id": "service-points",
"version": "3.4"
}
],
"provides": [
Expand Down Expand Up @@ -179,7 +187,7 @@
},
{
"id": "request-storage",
"version": "6.1",
"version": "6.2",
"handlers": [
{
"methods": ["GET"],
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>mod-circulation-storage</artifactId>
<groupId>org.folio</groupId>
<version>17.3.3-SNAPSHOT</version>
<version>17.3.4-SNAPSHOT</version>
<licenses>
<license>
<name>Apache License 2.0</name>
Expand Down
7 changes: 6 additions & 1 deletion ramls/examples/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
"holdingsRecordId": "e63273e7-48f5-4c43-ab4e-1751ecacaa21",
"itemId": "195efae1-588f-47bd-a181-13a2eb437701",
"item": {
"barcode": "760932543816"
"barcode": "760932543816",
"itemEffectiveLocationId" : "758258bc-ecc1-41b8-abca-f7b610822ffd",
"itemEffectiveLocationName" : "XYZ Location",
"retrievalServicePointId" : "c4c90014-c8c9-4ade-8f24-b5e313319f4b",
"retrievalServicePointName" : "Circ Desk Test"

},
"position": 1,
"fulfillmentPreference": "Hold Shelf",
Expand Down
67 changes: 67 additions & 0 deletions ramls/locations/location.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "A (shelf) location, the forth-level location unit below institution, campus, and library.",
"javaType": "org.folio.rest.jaxrs.model.Location",
"type": "object",
"properties": {
"id": {
"description": "id of this (shelf) location record as UUID.",
"type": "string"
},
"name": {
"description": "Name of the (shelf) location",
"type": "string"
},
"code": {
"description": "Code of the (shelf) location, usually an abbreviation of the name.",
"type": "string"
},
"description": {
"description": "Description of the (shelf) location.",
"type": "string"
},
"discoveryDisplayName": {
"description": "Name of the (shelf) location to be shown in the discovery.",
"type": "string"
},
"isActive": {
"description": "Whether this (shelf) location is active. Inactive (shelf) locations can no longer been used.",
"type": "boolean"
},
"institutionId": {
"description": "The UUID of the institution, the first-level location unit, this (shelf) location belongs to.",
"type": "string"
},
"campusId": {
"description": "The UUID of the campus, the second-level location unit, this (shelf) location belongs to.",
"type": "string"
},
"libraryId": {
"description": "The UUID of the library, the third-level location unit, this (shelf) location belongs to.",
"type": "string"
},
"primaryServicePoint": {
"description": "The UUID of the primary service point of this (shelf) location.",
"format": "uuid",
"type": "string"
},
"servicePointIds": {
"description": "All service points that this (shelf) location has.",
"type": "array",
"items": {
"description": "The UUID of a service point that belongs to this (shelf) location.",
"type": "string",
"format": "uuid",
"not": {
"type": "null"
}
}
},
"metadata": {
"type": "object",
"$ref": "../raml-util/schemas/metadata.schema",
"readonly": true
}
},
"additionalProperties": true
}
24 changes: 24 additions & 0 deletions ramls/locations/locations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "List of (shelf) locations.",
"type": "object",
"properties": {
"locations": {
"id": "locations",
"description": "List of (shelf) locations.",
"type": "array",
"items": {
"type": "object",
"$ref": "location.json"
}
},
"totalRecords": {
"description": "Estimated or exact total number of records",
"type": "integer"
}
},
"required": [
"locations",
"totalRecords"
]
}
2 changes: 2 additions & 0 deletions ramls/request-storage.raml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ types:
requests: !include requests.json
errors: !include raml-util/schemas/errors.schema
parameters: !include raml-util/schemas/parameters.schema
location: !include locations/location.json
locations: !include locations/locations.json

traits:
pageable: !include raml-util/traits/pageable.raml
Expand Down
18 changes: 18 additions & 0 deletions ramls/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@
"barcode": {
"description": "barcode of the item",
"type": "string"
},
"itemEffectiveLocationId": {
"description": "Item's effective location",
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
},
"itemEffectiveLocationName": {
"description": "Item's effective location name",
"type": "string"
},
"retrievalServicePointId": {
"description": "Item's location primary service point",
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
},
"retrievalServicePointName": {
"description": "Item's location primary service point name",
"type": "string"
}
},
"additionalProperties": false
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/folio/EventConsumerVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.folio.rest.tools.utils.ModuleName.getModuleName;
import static org.folio.rest.tools.utils.ModuleName.getModuleVersion;
import static org.folio.service.event.InventoryEventType.INVENTORY_ITEM_UPDATED;
import static org.folio.service.event.InventoryEventType.INVENTORY_LOCATION_UPDATED;
import static org.folio.service.event.InventoryEventType.INVENTORY_SERVICE_POINT_DELETED;
import static org.folio.service.event.InventoryEventType.INVENTORY_SERVICE_POINT_UPDATED;
import static org.folio.support.kafka.KafkaConfigConstants.KAFKA_ENV;
Expand All @@ -26,6 +27,7 @@
import org.folio.kafka.services.KafkaTopic;
import org.folio.service.event.InventoryEventType;
import org.folio.service.event.handler.ItemUpdateEventHandler;
import org.folio.service.event.handler.LocationUpdateEventHandler;
import org.folio.service.event.handler.ServicePointDeleteEventHandler;
import org.folio.service.event.handler.ServicePointUpdateEventHandler;

Expand Down Expand Up @@ -83,6 +85,8 @@ private Future<Void> createConsumers() {
new ServicePointUpdateEventHandler(context)))
.compose(r -> createInventoryEventConsumer(INVENTORY_SERVICE_POINT_DELETED, config,
new ServicePointDeleteEventHandler(context)))
.compose(r -> createInventoryEventConsumer(INVENTORY_LOCATION_UPDATED, config,
new LocationUpdateEventHandler(context)))
.mapEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Collection;
import java.util.Map;

import org.folio.rest.jaxrs.model.Location;
import org.folio.rest.jaxrs.model.Servicepoint;

import io.vertx.core.Future;
Expand All @@ -12,6 +13,9 @@ public class InventoryStorageClient extends OkapiClient {
private static final String SERVICE_POINTS_URL = "/service-points";
private static final String SERVICE_POINTS_COLLECTION_NAME = "servicepoints";

private static final String LOCATION_URL = "/locations";
private static final String LOCATION_COLLECTION_NAME = "locations";

public InventoryStorageClient(Vertx vertx, Map<String, String> okapiHeaders) {
super(vertx, okapiHeaders);
}
Expand All @@ -20,4 +24,8 @@ public Future<Collection<Servicepoint>> getServicePoints(Collection<String> ids)
return get(SERVICE_POINTS_URL, ids, SERVICE_POINTS_COLLECTION_NAME, Servicepoint.class);
}

public Future<Collection<Location>> getLocations(Collection<String> ids) {
return get(LOCATION_URL, ids, LOCATION_COLLECTION_NAME, Location.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.folio.service.event.InventoryEventType.PayloadType.DELETE;
import static org.folio.service.event.InventoryEventType.PayloadType.UPDATE;
import static org.folio.support.kafka.topic.InventoryKafkaTopic.ITEM;
import static org.folio.support.kafka.topic.InventoryKafkaTopic.LOCATION;
import static org.folio.support.kafka.topic.InventoryKafkaTopic.SERVICE_POINT;

import org.folio.kafka.services.KafkaTopic;
Expand All @@ -15,7 +16,8 @@
public enum InventoryEventType {
INVENTORY_ITEM_UPDATED(ITEM, UPDATE),
INVENTORY_SERVICE_POINT_UPDATED(SERVICE_POINT, UPDATE),
INVENTORY_SERVICE_POINT_DELETED(SERVICE_POINT, DELETE);
INVENTORY_SERVICE_POINT_DELETED(SERVICE_POINT, DELETE),
INVENTORY_LOCATION_UPDATED(LOCATION, UPDATE);

private final KafkaTopic kafkaTopic;
private final PayloadType payloadType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.commons.collections4.map.CaseInsensitiveMap;
import org.folio.kafka.AsyncRecordHandler;
import org.folio.persist.RequestRepository;
import org.folio.rest.client.InventoryStorageClient;
import org.folio.service.event.handler.processor.ItemUpdateProcessorForRequest;

import io.vertx.core.Context;
Expand All @@ -14,7 +15,6 @@

public class ItemUpdateEventHandler implements AsyncRecordHandler<String, String> {
private final Context context;

public ItemUpdateEventHandler(Context context) {
this.context = context;
}
Expand All @@ -24,9 +24,8 @@ public Future<String> handle(KafkaConsumerRecord<String, String> kafkaConsumerRe
JsonObject payload = new JsonObject(kafkaConsumerRecord.value());
CaseInsensitiveMap<String, String> headers =
new CaseInsensitiveMap<>(kafkaHeadersToMap(kafkaConsumerRecord.headers()));

ItemUpdateProcessorForRequest itemUpdateProcessorForRequest =
new ItemUpdateProcessorForRequest(new RequestRepository(context, headers));
new ItemUpdateProcessorForRequest(new RequestRepository(context, headers), new InventoryStorageClient(context.owner(), headers));

return itemUpdateProcessorForRequest.run(kafkaConsumerRecord.key(), payload);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.folio.service.event.handler;

import io.vertx.core.Context;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.kafka.client.consumer.KafkaConsumerRecord;
import org.apache.commons.collections4.map.CaseInsensitiveMap;
import org.folio.kafka.AsyncRecordHandler;
import org.folio.persist.RequestRepository;
import org.folio.service.event.handler.processor.ItemLocationUpdateProcessorForRequest;

import static org.folio.kafka.KafkaHeaderUtils.kafkaHeadersToMap;

public class LocationUpdateEventHandler implements AsyncRecordHandler<String, String> {
private final Context context;
public LocationUpdateEventHandler(Context context) {
this.context = context;
}

@Override
public Future<String> handle(KafkaConsumerRecord<String, String> kafkaConsumerRecord) {
JsonObject payload = new JsonObject(kafkaConsumerRecord.value());
CaseInsensitiveMap<String, String> headers =
new CaseInsensitiveMap<>(kafkaHeadersToMap(kafkaConsumerRecord.headers()));

ItemLocationUpdateProcessorForRequest itemLocationUpdateProcessorForRequest =
new ItemLocationUpdateProcessorForRequest(new RequestRepository(context, headers));

return itemLocationUpdateProcessorForRequest.run(kafkaConsumerRecord.key(), payload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.folio.kafka.AsyncRecordHandler;
import org.folio.persist.RequestPolicyRepository;
import org.folio.persist.RequestRepository;
import org.folio.service.event.handler.processor.ItemRetrievalServicePointUpdateProcessorForRequest;
import org.folio.service.event.handler.processor.ServicePointUpdateProcessorForRequest;
import org.folio.service.event.handler.processor.ServicePointUpdateProcessorForRequestPolicy;

Expand All @@ -31,6 +32,8 @@ public Future<String> handle(KafkaConsumerRecord<String, String> kafkaConsumerRe
return new ServicePointUpdateProcessorForRequest(requestRepository)
.run(kafkaConsumerRecord.key(), payload)
.compose(notUsed -> new ServicePointUpdateProcessorForRequestPolicy(requestPolicyRepository)
.run(kafkaConsumerRecord.key(), payload));
.run(kafkaConsumerRecord.key(), payload))
.compose(notUsed -> new ItemRetrievalServicePointUpdateProcessorForRequest(requestRepository)
.run(kafkaConsumerRecord.key(), payload));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,24 @@ private Future<List<T>> processEvent(JsonObject payload) {
return succeededFuture();
}

List<Change<T>> relevantChanges = collectRelevantChanges(payload);
Future<List<Change<T>>> relevantChangesFuture =
collectRelevantChanges(payload);

if (relevantChanges.isEmpty()) {
log.info("processEvent:: no relevant changes detected");
return succeededFuture();
}
return relevantChangesFuture.compose(relevantChanges -> {

if (relevantChanges.isEmpty()) {
log.info("processEvent:: no relevant changes detected");
return succeededFuture();
}

log.info("processEvent:: {} relevant changes detected, applying", relevantChanges::size);
return applyChanges(relevantChanges, payload);
log.info("processEvent:: {} relevant changes detected, applying", relevantChanges::size);
return applyChanges(relevantChanges, payload);
});
}

protected abstract boolean validatePayload(JsonObject payload);

protected abstract List<Change<T>> collectRelevantChanges(JsonObject payload);
protected abstract Future<List<Change<T>>> collectRelevantChanges(JsonObject payload);

private Future<List<T>> applyChanges(List<Change<T>> changes, JsonObject payload) {
log.debug("applyChanges:: payload: {}", payload);
Expand Down
Loading
Loading