From 4ebf740a0610c26d3bb60eb1f8dfeb4d03072355 Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Fri, 29 Nov 2024 12:49:59 +0530 Subject: [PATCH 1/4] CIRCSTORE-539: added new request.item fields and db indexing --- ramls/examples/request.json | 7 ++- ramls/request.json | 16 +++++++ .../templates/db_scripts/schema.json | 48 +++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/ramls/examples/request.json b/ramls/examples/request.json index efeca2d28..ce1d9f2d8 100644 --- a/ramls/examples/request.json +++ b/ramls/examples/request.json @@ -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", diff --git a/ramls/request.json b/ramls/request.json index 8c1f54231..9b3060b40 100644 --- a/ramls/request.json +++ b/ramls/request.json @@ -133,6 +133,22 @@ "barcode": { "description": "barcode of the item", "type": "string" + }, + "itemEffectiveLocationId": { + "description": "Item's effective location", + "type": "string" + }, + "itemEffectiveLocationName": { + "description": "Item's effective location name", + "type": "string" + }, + "retrievalServicePointId": { + "description": "Item's location primary service point", + "type": "string" + }, + "retrievalServicePointName": { + "description": "Item's location primary service point name", + "type": "string" } }, "additionalProperties": false diff --git a/src/main/resources/templates/db_scripts/schema.json b/src/main/resources/templates/db_scripts/schema.json index bc1b06ae2..066c0bf1f 100644 --- a/src/main/resources/templates/db_scripts/schema.json +++ b/src/main/resources/templates/db_scripts/schema.json @@ -235,6 +235,30 @@ "tOps": "ADD", "caseSensitive": false, "removeAccents": false + }, + { + "fieldName": "item.itemEffectiveLocationId", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": false + }, + { + "fieldName": "item.itemEffectiveLocationName", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": false + }, + { + "fieldName": "item.retrievalServicePointId", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": false + }, + { + "fieldName": "item.retrievalServicePointName", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": false } ], "fullTextIndex": [ @@ -298,6 +322,30 @@ "tOps": "ADD", "caseSensitive": false, "removeAccents": false + }, + { + "fieldName": "item.itemEffectiveLocationId", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": false + }, + { + "fieldName": "item.itemEffectiveLocationName", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": false + }, + { + "fieldName": "item.retrievalServicePointId", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": false + }, + { + "fieldName": "item.retrievalServicePointName", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": false } ], "customSnippetPath": "requestUpdateTrigger.sql" From 9a80571bd56b1a2d0f308c1bfb41dffdaf162896 Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Thu, 5 Dec 2024 15:58:50 +0530 Subject: [PATCH 2/4] CIRCSTORE-539: fixed PR comments --- ramls/request.json | 6 ++++-- .../org/folio/rest/api/RequestsApiTest.java | 13 ++++++++++++- .../support/builders/RequestItemSummary.java | 19 ++++++++++++++++++- .../builders/RequestRequestBuilder.java | 13 ++++++++----- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/ramls/request.json b/ramls/request.json index 9b3060b40..42189648b 100644 --- a/ramls/request.json +++ b/ramls/request.json @@ -136,7 +136,8 @@ }, "itemEffectiveLocationId": { "description": "Item's effective location", - "type": "string" + "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", @@ -144,7 +145,8 @@ }, "retrievalServicePointId": { "description": "Item's location primary service point", - "type": "string" + "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", diff --git a/src/test/java/org/folio/rest/api/RequestsApiTest.java b/src/test/java/org/folio/rest/api/RequestsApiTest.java index cc5fb2578..164d75047 100644 --- a/src/test/java/org/folio/rest/api/RequestsApiTest.java +++ b/src/test/java/org/folio/rest/api/RequestsApiTest.java @@ -41,6 +41,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; +import java.util.Collections; import java.util.List; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -126,6 +127,10 @@ public void canCreateARequest(String requestLevel) throws InterruptedException, UUID holdingsRecordId = UUID.randomUUID(); UUID instanceId = UUID.randomUUID(); UUID pickupServicePointId = UUID.randomUUID(); + String itemEffectiveLocationId = UUID.randomUUID().toString(); + String itemEffectiveLocationName = "Book"; + String retrievalServicePointId = UUID.randomUUID().toString(); + String retrievalServicePointName = "SP-1"; DateTime requestDate = new DateTime(2017, 7, 22, 10, 22, 54, DateTimeZone.UTC); DateTime requestExpirationDate = new DateTime(2017, 7, 30, 0, 0, DateTimeZone.UTC); DateTime holdShelfExpirationDate = new DateTime(2017, 8, 31, 0, 0, DateTimeZone.UTC); @@ -133,7 +138,9 @@ public void canCreateARequest(String requestLevel) throws InterruptedException, UUID isbnIdentifierId = UUID.randomUUID(); UUID issnIdentifierId = UUID.randomUUID(); - final RequestItemSummary nod = new RequestItemSummary("Nod", "565578437802") + final RequestItemSummary nod = new RequestItemSummary("Nod", + "565578437802", Collections.emptyList(), itemEffectiveLocationId, + itemEffectiveLocationName, retrievalServicePointId, retrievalServicePointName) .addIdentifier(isbnIdentifierId, "978-92-8011-566-9") .addIdentifier(issnIdentifierId, "2193988"); @@ -182,6 +189,10 @@ public void canCreateARequest(String requestLevel) throws InterruptedException, assertThat(representation.containsKey("item"), is(true)); JsonObject item = representation.getJsonObject("item"); assertThat(item.getString("barcode"), is("565578437802")); + assertThat(item.getString("itemEffectiveLocationId"), is(itemEffectiveLocationId)); + assertThat(item.getString("itemEffectiveLocationName"), is(itemEffectiveLocationName)); + assertThat(item.getString("retrievalServicePointId"), is(retrievalServicePointId)); + assertThat(item.getString("retrievalServicePointName"), is(retrievalServicePointName)); assertThat(representation.containsKey("instance"), is(true)); JsonObject instance = representation.getJsonObject("instance"); diff --git a/src/test/java/org/folio/rest/support/builders/RequestItemSummary.java b/src/test/java/org/folio/rest/support/builders/RequestItemSummary.java index 99dcfaa67..96ccd4270 100644 --- a/src/test/java/org/folio/rest/support/builders/RequestItemSummary.java +++ b/src/test/java/org/folio/rest/support/builders/RequestItemSummary.java @@ -12,15 +12,28 @@ public class RequestItemSummary { final String title; final String barcode; final List> identifiers; + final String itemEffectiveLocationId; + final String itemEffectiveLocationName; + final String retrievalServicePointId; + final String retrievalServicePointName; + public RequestItemSummary(String title, String barcode) { this(title, barcode, Collections.emptyList()); } private RequestItemSummary(String title, String barcode, List> identifiers) { + this(title, barcode, Collections.emptyList(), null, null, null, null); + } + + public RequestItemSummary(String title, String barcode, List> identifiers, String itemEffectiveLocationId, String itemEffectiveLocationName, String retrievalServicePointId, String retrievalServicePointName) { this.title = title; this.barcode = barcode; this.identifiers = new ArrayList<>(identifiers); + this.itemEffectiveLocationId = itemEffectiveLocationId; + this.itemEffectiveLocationName = itemEffectiveLocationName; + this.retrievalServicePointId = retrievalServicePointId; + this.retrievalServicePointName = retrievalServicePointName; } public RequestItemSummary addIdentifier(UUID identifierId, String value) { @@ -30,6 +43,10 @@ public RequestItemSummary addIdentifier(UUID identifierId, String value) { return new RequestItemSummary( this.title, this.barcode, - copiedIdentifiers); + copiedIdentifiers, + this.itemEffectiveLocationId, + this.itemEffectiveLocationName, + this.retrievalServicePointId, + this.retrievalServicePointName); } } diff --git a/src/test/java/org/folio/rest/support/builders/RequestRequestBuilder.java b/src/test/java/org/folio/rest/support/builders/RequestRequestBuilder.java index 4a7e8335d..407965ff1 100644 --- a/src/test/java/org/folio/rest/support/builders/RequestRequestBuilder.java +++ b/src/test/java/org/folio/rest/support/builders/RequestRequestBuilder.java @@ -1,18 +1,16 @@ package org.folio.rest.support.builders; -import java.util.UUID; -import java.util.stream.Collectors; - import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import lombok.AllArgsConstructor; import lombok.With; - import org.folio.rest.jaxrs.model.SearchIndex; +import org.folio.rest.jaxrs.model.Tags; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; -import org.folio.rest.jaxrs.model.Tags; +import java.util.UUID; +import java.util.stream.Collectors; @AllArgsConstructor @With @@ -111,6 +109,11 @@ public JsonObject create() { final JsonObject item = new JsonObject(); put(item, "barcode", this.itemSummary.barcode); + put(item, "itemEffectiveLocationId", this.itemSummary.itemEffectiveLocationId); + put(item, "itemEffectiveLocationName", this.itemSummary.itemEffectiveLocationName); + put(item, "retrievalServicePointId", this.itemSummary.retrievalServicePointId); + put(item, "retrievalServicePointName", this.itemSummary.retrievalServicePointName); + final JsonArray identifiers = new JsonArray(this.itemSummary.identifiers .stream() .map(pair -> new JsonObject() From 021e9e4920a3a2cd748e86e0682f397e05cd3ce2 Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Thu, 5 Dec 2024 16:36:06 +0530 Subject: [PATCH 3/4] CIRCSTORE-539: upgraded request-storage interface version from 6.1 to 6.2 --- descriptors/ModuleDescriptor-template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 4e775f55c..4ce7a918e 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -179,7 +179,7 @@ }, { "id": "request-storage", - "version": "6.1", + "version": "6.2", "handlers": [ { "methods": ["GET"], From d1099150f0426febc882c7c4ee127dff786f3b39 Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Thu, 5 Dec 2024 18:19:58 +0530 Subject: [PATCH 4/4] CIRCSTORE-539: fix sonar issue --- .../org/folio/rest/support/builders/RequestItemSummary.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/folio/rest/support/builders/RequestItemSummary.java b/src/test/java/org/folio/rest/support/builders/RequestItemSummary.java index 96ccd4270..2a05eff42 100644 --- a/src/test/java/org/folio/rest/support/builders/RequestItemSummary.java +++ b/src/test/java/org/folio/rest/support/builders/RequestItemSummary.java @@ -23,7 +23,7 @@ public RequestItemSummary(String title, String barcode) { } private RequestItemSummary(String title, String barcode, List> identifiers) { - this(title, barcode, Collections.emptyList(), null, null, null, null); + this(title, barcode, identifiers, null, null, null, null); } public RequestItemSummary(String title, String barcode, List> identifiers, String itemEffectiveLocationId, String itemEffectiveLocationName, String retrievalServicePointId, String retrievalServicePointName) {