use of org.folio.circulation.domain.RequestQueue 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.RequestQueue in project mod-circulation by folio-org.
the class LoanCollectionResource method unsetDueDateChangedByRecallIfNoOpenRecallsInQueue.
private LoanAndRelatedRecords unsetDueDateChangedByRecallIfNoOpenRecallsInQueue(LoanAndRelatedRecords loanAndRelatedRecords) {
if (dueDateHasNotChanged(loanAndRelatedRecords.getExistingLoan(), loanAndRelatedRecords.getLoan())) {
return loanAndRelatedRecords;
}
RequestQueue queue = loanAndRelatedRecords.getRequestQueue();
Loan loan = loanAndRelatedRecords.getLoan();
log.info("Loan {} prior to flag check: {}", loan.getId(), loan.asJson());
if (loan.wasDueDateChangedByRecall() && !queue.hasOpenRecalls()) {
log.info("Loan {} registers as having due date change flag set to true and no open recalls in queue.", loan.getId());
return loanAndRelatedRecords.withLoan(loan.unsetDueDateChangedByRecall());
} else {
log.info("Loan {} registers as either not having due date change flag set to true or as having open recalls in queue.", loan.getId());
return loanAndRelatedRecords;
}
}
use of org.folio.circulation.domain.RequestQueue in project mod-circulation by folio-org.
the class RenewalResource method validateIfRenewIsAllowed.
private Result<RenewalContext> validateIfRenewIsAllowed(RenewalContext context, boolean isDueDateRequired) {
Loan loan = context.getLoan();
RequestQueue requestQueue = context.getRequestQueue();
try {
final var errors = isDueDateRequired ? validateIfRenewIsAllowedAndDueDateRequired(loan, requestQueue) : validateIfRenewIsAllowedAndDueDateNotRequired(loan, requestQueue);
final var loanPolicy = loan.getLoanPolicy();
if (loanPolicy.isNotLoanable() || loanPolicy.isNotRenewable()) {
return failedValidation(errors);
}
if (errors.isEmpty()) {
return succeeded(context);
}
return failedValidation(errors);
} catch (Exception e) {
return failedDueToServerError(e);
}
}
Aggregations