use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class ReorderRequestContext method getReorderRequestToRequestMap.
/**
* Returns Map of pairs where key is ReorderedRequest and value is Request from the queue.
*
* @return Map of pairs ReorderRequest - Request.
*/
public Map<ReorderRequest, Request> getReorderRequestToRequestMap() {
final Map<ReorderRequest, Request> reorderRequestToRequestMap = new HashMap<>();
reorderQueueRequest.getReorderedQueue().forEach(reorderRequest -> {
Request relatedRequest = requestQueue.getRequests().stream().filter(request -> request.getId().equals(reorderRequest.getId())).findAny().orElse(null);
reorderRequestToRequestMap.put(reorderRequest, relatedRequest);
});
return reorderRequestToRequestMap;
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RenewalResource method validateIfRenewIsAllowedAndDueDateNotRequired.
private List<ValidationError> validateIfRenewIsAllowedAndDueDateNotRequired(Loan loan, RequestQueue requestQueue) {
final List<ValidationError> errors = new ArrayList<>();
final LoanPolicy loanPolicy = loan.getLoanPolicy();
final Request firstRequest = getFirstRequestInQueue(requestQueue);
if (hasRecallRequest(firstRequest)) {
errors.add(errorForRecallRequest("items cannot be renewed when there is an active recall request", firstRequest.getId()));
}
if (ITEM_STATUSES_DISALLOWED_FOR_RENEW.contains(loan.getItemStatus())) {
errors.add(itemByIdValidationError("item is " + loan.getItemStatusName(), loan.getItemId()));
}
if (loanPolicy.hasReachedRenewalLimit(loan)) {
errors.add(loanPolicyValidationError(loanPolicy, "loan at maximum renewal number"));
}
return errors;
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RequestScheduledNoticeHandler method isNoticeNotRelevantYet.
private static boolean isNoticeNotRelevantYet(ScheduledNoticeContext context) {
Request request = context.getRequest();
ScheduledNotice notice = context.getNotice();
return notice.getConfiguration().getTiming() == UPON_AT && request.isOpen() && !(notice.getTriggeringEvent() == HOLD_EXPIRATION && request.isNotYetFilled());
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RequestScheduledNoticeHandler method updateNotice.
@Override
protected CompletableFuture<Result<ScheduledNotice>> updateNotice(ScheduledNoticeContext context) {
Request request = context.getRequest();
ScheduledNotice notice = context.getNotice();
boolean isNoticeNonRecurring = !notice.getConfiguration().isRecurring();
if (isNoticeNotRelevantYet(context)) {
return ofAsync(() -> notice);
}
if (request.isClosed() || isNoticeNonRecurring || isNoticeNoLongerRelevant(context)) {
return deleteNoticeAsIrrelevant(notice);
}
ScheduledNotice nextRecurringNotice = updateNoticeNextRunTime(notice);
return nextRecurringNoticeIsNotRelevant(nextRecurringNotice, request) ? deleteNoticeAsIrrelevant(notice) : scheduledNoticesRepository.update(nextRecurringNotice);
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RequestScheduledNoticeService method scheduleRequestNotices.
public Result<RequestAndRelatedRecords> scheduleRequestNotices(RequestAndRelatedRecords relatedRecords) {
Request request = relatedRecords.getRequest();
if (request.isClosed()) {
return succeeded(relatedRecords);
}
RequestLevel requestLevel = relatedRecords.getRequest().getRequestLevel();
if (requestLevel == TITLE) {
scheduleTlrRequestNotices(relatedRecords.getRequest());
} else if (requestLevel == ITEM) {
scheduleRequestNotices(relatedRecords.getRequest());
}
return succeeded(relatedRecords);
}
Aggregations