Skip to content

Commit

Permalink
CIRCSTORE-539: added new request.item fields and db indexing into req…
Browse files Browse the repository at this point in the history
…uest schema (#498)

* CIRCSTORE-539: added new request.item fields and db indexing

* CIRCSTORE-539: fixed PR comments

* CIRCSTORE-539: upgraded request-storage interface version from 6.1 to 6.2

* CIRCSTORE-539: fix sonar issue
  • Loading branch information
kapil-epam authored Dec 6, 2024
1 parent 94078e9 commit 01893fd
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 9 deletions.
2 changes: 1 addition & 1 deletion descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
},
{
"id": "request-storage",
"version": "6.1",
"version": "6.2",
"handlers": [
{
"methods": ["GET"],
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
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
48 changes: 48 additions & 0 deletions src/main/resources/templates/db_scripts/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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"
Expand Down
13 changes: 12 additions & 1 deletion src/test/java/org/folio/rest/api/RequestsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -126,14 +127,20 @@ 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);

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");

Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,28 @@ public class RequestItemSummary {
final String title;
final String barcode;
final List<Pair<UUID, String>> 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<Pair<UUID, String>> identifiers) {
this(title, barcode, identifiers, null, null, null, null);
}

public RequestItemSummary(String title, String barcode, List<Pair<UUID, String>> 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) {
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 01893fd

Please sign in to comment.