diff --git a/ramls/raml-util b/ramls/raml-util index 9d7fe883b4..f48a63f3e4 160000 --- a/ramls/raml-util +++ b/ramls/raml-util @@ -1 +1 @@ -Subproject commit 9d7fe883b4e08a262ee3cffc69c33f8b7b63710b +Subproject commit f48a63f3e45b9a3b437d21c3a61ed10b8ceb5f25 diff --git a/ramls/request.json b/ramls/request.json index 9e38fe6c7f..5e27fb2d06 100644 --- a/ramls/request.json +++ b/ramls/request.json @@ -17,7 +17,7 @@ "requestLevel": { "description": "Level of the request - Item or Title", "type": "string", - "enum": ["Item"] + "enum": ["Item", "Title"] }, "requestDate": { "description": "Date the request was made", @@ -358,6 +358,56 @@ } } }, + "printDetails": { + "description": "The print details of the request", + "type": "object", + "readonly": true, + "properties": { + "printCount": { + "description": "Total no of times the request is printed", + "type": "integer", + "readOnly": true + }, + "requesterId": { + "description": "User uuid of last print requester", + "type": "string", + "readOnly": true + }, + "isPrinted": { + "description": "Whether the request is ever printed", + "type": "boolean", + "readOnly": true + }, + "printEventDate": { + "description": "Recent printed time of the request", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "lastPrintRequester": { + "description": "Details of the User who printed the request recently", + "readonly": true, + "type": "object", + "properties": { + "firstName": { + "description": "first name of the user", + "type": "string", + "readonly": true + }, + "lastName": { + "description": "last name of the user", + "type": "string", + "readonly": true + }, + "middleName": { + "description": "middle name of the user", + "type": "string", + "readonly": true + } + } + } + } + }, "tags": { "type": "object", "description": "Tags", @@ -383,6 +433,10 @@ "description": "Request fields used for search", "type": "object", "$ref": "request-search-index.json" + }, + "isDcbReRequestCancellation": { + "description": "Indicates whether the request was cancelled during a DCB transaction update", + "type": "boolean" } }, "additionalProperties": false, diff --git a/src/main/java/org/folio/circulation/domain/Request.java b/src/main/java/org/folio/circulation/domain/Request.java index 0774075a5b..afae370507 100644 --- a/src/main/java/org/folio/circulation/domain/Request.java +++ b/src/main/java/org/folio/circulation/domain/Request.java @@ -27,6 +27,7 @@ import static org.folio.circulation.domain.representations.RequestProperties.REQUEST_LEVEL; import static org.folio.circulation.domain.representations.RequestProperties.REQUEST_TYPE; import static org.folio.circulation.domain.representations.RequestProperties.STATUS; +import static org.folio.circulation.support.json.JsonPropertyFetcher.getBooleanProperty; import static org.folio.circulation.support.json.JsonPropertyFetcher.getDateTimeProperty; import static org.folio.circulation.support.json.JsonPropertyFetcher.getIntegerProperty; import static org.folio.circulation.support.json.JsonPropertyFetcher.getProperty; @@ -406,6 +407,10 @@ public boolean hasLoan() { return loan != null; } + public boolean getDcbReRequestCancellationValue() { + return getBooleanProperty(requestRepresentation, "isDcbReRequestCancellation"); + } + public enum Operation { CREATE, REPLACE, MOVE; } diff --git a/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java b/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java index abbf46c61e..a494a0c8b9 100644 --- a/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java +++ b/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java @@ -119,10 +119,12 @@ public Result sendNoticeOnRequestCancelled( log.debug("sendNoticeOnRequestCancelled:: parameters records: {}", () -> records); Request request = records.getRequest(); - if (request.hasItemId()) { - sendCancellationNoticeForRequestWithItemId(request); - } else { - sendCancellationNoticeForRequestWithoutItemId(request); + if (!request.getDcbReRequestCancellationValue()) { + if (request.hasItemId()) { + sendCancellationNoticeForRequestWithItemId(request); + } else { + sendCancellationNoticeForRequestWithoutItemId(request); + } } return succeeded(records); diff --git a/src/test/java/org/folio/circulation/resources/RequestNoticeSenderTest.java b/src/test/java/org/folio/circulation/resources/RequestNoticeSenderTest.java new file mode 100644 index 0000000000..a742d50205 --- /dev/null +++ b/src/test/java/org/folio/circulation/resources/RequestNoticeSenderTest.java @@ -0,0 +1,36 @@ +package org.folio.circulation.resources; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; + +import org.folio.circulation.domain.Request; +import org.folio.circulation.domain.RequestAndRelatedRecords; +import org.folio.circulation.domain.notice.ImmediatePatronNoticeService; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +import api.support.builders.RequestBuilder; +import io.vertx.core.json.JsonObject; + +@ExtendWith(MockitoExtension.class) +class RequestNoticeSenderTest { + + @Mock + private ImmediatePatronNoticeService immediatePatronNoticeService; + @InjectMocks + private RequestNoticeSender requestNoticeSender; + + @Test + void shouldNotSendNotificationWhenIsDcbCancellationTrue() { + JsonObject representation = new RequestBuilder().create(); + representation.put("isDcbReRequestCancellation", true); + requestNoticeSender.sendNoticeOnRequestCancelled( + new RequestAndRelatedRecords(Request.from(representation))); + Mockito.verify(immediatePatronNoticeService, times(0)).acceptNoticeEvent(any()); + Mockito.verify(immediatePatronNoticeService, times(0)).sendNotice(any(), any()); + } +}