From 11839995e43d8ed19bc4ebdc429ab031dcd54d59 Mon Sep 17 00:00:00 2001 From: Vignesh-Kalyanasundaram Date: Wed, 27 Nov 2024 13:00:04 +0530 Subject: [PATCH] UXPROD-5001 Avoid sending cancellation notice if the suppressNotification flag is set --- ramls/request.json | 4 ++++ .../java/org/folio/circulation/domain/Request.java | 5 +++++ .../circulation/resources/RequestNoticeSender.java | 11 +++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ramls/request.json b/ramls/request.json index 491928db08..1445a72849 100644 --- a/ramls/request.json +++ b/ramls/request.json @@ -437,6 +437,10 @@ "itemLocationCode": { "description": "Allow specifying item location when creating title-level requests", "type": "string" + }, + "isSuppressNotification": { + "description": "Flag to suppress sending cancellation notifications. If true, no notification will be sent when cancelling the request", + "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 597cda08ef..e869ec099d 100644 --- a/src/main/java/org/folio/circulation/domain/Request.java +++ b/src/main/java/org/folio/circulation/domain/Request.java @@ -29,6 +29,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; @@ -427,6 +428,10 @@ public boolean hasLoan() { return loan != null; } + public boolean getSuppressNotificationFlag() { + return getBooleanProperty(requestRepresentation, "isSuppressNotification"); + } + 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..f79972c7fe 100644 --- a/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java +++ b/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java @@ -119,10 +119,13 @@ public Result sendNoticeOnRequestCancelled( log.debug("sendNoticeOnRequestCancelled:: parameters records: {}", () -> records); Request request = records.getRequest(); - if (request.hasItemId()) { - sendCancellationNoticeForRequestWithItemId(request); - } else { - sendCancellationNoticeForRequestWithoutItemId(request); + // Send the cancellation notice only if the suppressNotification flag is false + if (!request.getSuppressNotificationFlag()) { + if (request.hasItemId()) { + sendCancellationNoticeForRequestWithItemId(request); + } else { + sendCancellationNoticeForRequestWithoutItemId(request); + } } return succeeded(records);