diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 4e775f55..4ce7a918 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"], diff --git a/ramls/examples/request.json b/ramls/examples/request.json index efeca2d2..ce1d9f2d 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 8c1f5423..42189648 100644 --- a/ramls/request.json +++ b/ramls/request.json @@ -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 diff --git a/src/main/resources/templates/db_scripts/schema.json b/src/main/resources/templates/db_scripts/schema.json index bc1b06ae..066c0bf1 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" diff --git a/src/test/java/org/folio/rest/api/RequestsApiTest.java b/src/test/java/org/folio/rest/api/RequestsApiTest.java index cc5fb257..164d7504 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 99dcfaa6..2a05eff4 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, identifiers, 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 4a7e8335..407965ff 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()