use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RequestNoticeSender method sendNoticeOnRequestAwaitingPickup.
public Result<CheckInContext> sendNoticeOnRequestAwaitingPickup(CheckInContext context) {
final Item item = context.getItem();
final RequestQueue requestQueue = context.getRequestQueue();
if (item == null || item.isNotFound()) {
log.warn("Request Awaiting Pickup notice processing is aborted: item is missing");
} else if (requestQueue == null) {
log.warn("Request Awaiting Pickup notice processing is aborted: request queue is null");
} else if (item.isAwaitingPickup()) {
requestQueue.getRequests().stream().filter(Request::hasTopPriority).filter(Request::isAwaitingPickup).filter(Request::hasChangedStatus).findFirst().map(request -> request.withItem(item)).ifPresent(this::fetchDataAndSendRequestAwaitingPickupNotice);
}
return succeeded(context);
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RequestNoticeSender method sendNoticeOnRequestMoved.
public Result<RequestAndRelatedRecords> sendNoticeOnRequestMoved(RequestAndRelatedRecords relatedRecords) {
Request request = relatedRecords.getRequest();
Loan loan = request.getLoan();
if (request.getRequestType() == RequestType.RECALL && loan != null) {
sendNoticeOnItemRecalledEvent(loan);
sendLogEvent(loan);
}
return Result.succeeded(relatedRecords);
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RenewalResource method renewThroughOverride.
public CompletableFuture<Result<RenewalContext>> renewThroughOverride(RenewalContext context) {
final JsonObject overrideBlocks = context.getRenewalRequest().getJsonObject(OVERRIDE_BLOCKS);
final String comment = getProperty(overrideBlocks, COMMENT);
if (StringUtils.isBlank(comment)) {
return completedFuture(failedValidation("Override renewal request must have a comment", COMMENT, null));
}
final ZonedDateTime overrideDueDate = getDateTimeProperty(overrideBlocks.getJsonObject(RENEWAL_DUE_DATE_REQUIRED_OVERRIDE_BLOCK), DUE_DATE);
Loan loan = context.getLoan();
boolean hasRecallRequest = context.getRequestQueue().getRequests().stream().findFirst().map(r -> r.getRequestType() == RequestType.RECALL).orElse(false);
return completedFuture(overrideRenewal(loan, ClockUtil.getZonedDateTime(), overrideDueDate, comment, hasRecallRequest)).thenApply(mapResult(context::withLoan));
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class TitleLevelRequestNoticeSender method sendNoticeOnRequestCancelled.
@Override
protected Result<Void> sendNoticeOnRequestCancelled(RequestAndRelatedRecords relatedRecords) {
Request request = relatedRecords.getRequest();
if (request.getTlrSettingsConfiguration().isTitleLevelRequestsFeatureEnabled() && request.getTlrSettingsConfiguration().getCancellationPatronNoticeTemplateId() != null) {
PatronNoticeEvent requestCancelledEvent = createPatronNoticeEvent(request, NoticeEventType.REQUEST_CANCELLATION);
applyTlrCancellationNotice(request.getTlrSettingsConfiguration(), requestCancelledEvent);
}
return Result.succeeded(null);
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RenewalResource method validateIfRenewIsAllowedAndDueDateRequired.
private List<ValidationError> validateIfRenewIsAllowedAndDueDateRequired(Loan loan, RequestQueue requestQueue) {
final List<ValidationError> errors = new ArrayList<>();
final LoanPolicy loanPolicy = loan.getLoanPolicy();
final Request firstRequest = getFirstRequestInQueue(requestQueue);
if (loanPolicy.isNotLoanable()) {
errors.add(loanPolicyValidationError(loanPolicy, "item is not loanable"));
} else if (loanPolicy.isNotRenewable()) {
errors.add(loanPolicyValidationError(loanPolicy, "loan is not renewable"));
}
if (isHold(firstRequest)) {
if (!loanPolicy.isHoldRequestRenewable()) {
errors.add(loanPolicyValidationError(loanPolicy, CAN_NOT_RENEW_ITEM_ERROR));
}
if (loanPolicy.isFixed()) {
if (loanPolicy.hasAlternateRenewalLoanPeriodForHolds()) {
errors.add(loanPolicyValidationError(loanPolicy, FIXED_POLICY_HAS_ALTERNATE_RENEWAL_PERIOD_FOR_HOLDS));
}
if (loanPolicy.hasRenewalPeriod()) {
errors.add(loanPolicyValidationError(loanPolicy, FIXED_POLICY_HAS_ALTERNATE_RENEWAL_PERIOD));
}
}
}
return errors;
}
Aggregations