use of org.folio.circulation.storage.SingleOpenLoanForItemInStorageFinder in project mod-circulation by folio-org.
the class RenewByIdResource method findLoan.
@Override
protected CompletableFuture<Result<Loan>> findLoan(JsonObject request, LoanRepository loanRepository, ItemRepository itemRepository, UserRepository userRepository, CirculationErrorHandler errorHandler) {
final Result<RenewByIdRequest> requestResult = RenewByIdRequest.from(request);
final String itemId = requestResult.map(RenewByIdRequest::getItemId).orElse("unknown item ID");
final SingleOpenLoanForItemInStorageFinder singleOpenLoanFinder = new SingleOpenLoanForItemInStorageFinder(loanRepository, userRepository, false);
final ItemByIdInStorageFinder itemFinder = new ItemByIdInStorageFinder(itemRepository, noItemFoundForIdFailure(itemId));
return completedFuture(requestResult).thenCompose(r -> lookupItem(itemFinder, itemId, errorHandler)).thenCompose(r -> r.after(item -> lookupLoan(singleOpenLoanFinder, item, errorHandler))).thenApply(r -> r.next(loan -> refuseWhenUserNotFound(loan, errorHandler))).thenApply(r -> r.next(loan -> refuseWhenUserDoesNotMatch(loan, requestResult.value(), errorHandler)));
}
use of org.folio.circulation.storage.SingleOpenLoanForItemInStorageFinder in project mod-circulation by folio-org.
the class CheckInProcessAdapter method newInstance.
public static CheckInProcessAdapter newInstance(Clients clients, ItemRepository itemRepository, UserRepository userRepository, LoanRepository loanRepository, RequestRepository requestRepository, RequestQueueRepository requestQueueRepository) {
final var itemFinder = new ItemByBarcodeInStorageFinder(itemRepository);
final SingleOpenLoanForItemInStorageFinder singleOpenLoanFinder = new SingleOpenLoanForItemInStorageFinder(loanRepository, userRepository, true);
final var overdueFineService = new OverdueFineService(new OverdueFinePolicyRepository(clients), itemRepository, new FeeFineOwnerRepository(clients), new FeeFineRepository(clients), ScheduledNoticesRepository.using(clients), new OverduePeriodCalculatorService(new CalendarRepository(clients), new LoanPolicyRepository(clients)), new FeeFineFacade(clients));
return new CheckInProcessAdapter(itemFinder, singleOpenLoanFinder, new LoanCheckInService(), requestQueueRepository, new UpdateItem(itemRepository), UpdateRequestQueue.using(clients, requestRepository, requestQueueRepository), loanRepository, new ServicePointRepository(clients), userRepository, new AddressTypeRepository(clients), new LogCheckInService(clients), overdueFineService, FeeFineScheduledNoticeService.using(clients), new LostItemFeeRefundService(clients, itemRepository, userRepository, loanRepository), new EventPublisher(clients.pubSubPublishingService()));
}
Aggregations