use of org.folio.circulation.services.ChangeItemStatusService in project mod-circulation by folio-org.
the class ClaimItemReturnedResource method processClaimItemReturned.
private CompletableFuture<Result<Loan>> processClaimItemReturned(RoutingContext routingContext, ClaimItemReturnedRequest request) {
final Clients clients = Clients.create(new WebContext(routingContext), client);
final var itemRepository = new ItemRepository(clients);
final var userRepository = new UserRepository(clients);
final var loanRepository = new LoanRepository(clients, itemRepository, userRepository);
final ChangeItemStatusService changeItemStatusService = new ChangeItemStatusService(loanRepository, new StoreLoanAndItem(loanRepository, itemRepository));
return changeItemStatusService.getOpenLoan(request).thenApply(loan -> declareLoanClaimedReturned(loan, request)).thenCompose(changeItemStatusService::updateLoanAndItem);
}
use of org.folio.circulation.services.ChangeItemStatusService in project mod-circulation by folio-org.
the class DeclareClaimedReturnedItemAsMissingResource method processDeclareClaimedReturnedItemAsMissing.
private CompletableFuture<Result<Loan>> processDeclareClaimedReturnedItemAsMissing(RoutingContext routingContext, ChangeItemStatusRequest request) {
final Clients clients = Clients.create(new WebContext(routingContext), client);
final var itemRepository = new ItemRepository(clients);
final var userRepository = new UserRepository(clients);
final var loanRepository = new LoanRepository(clients, itemRepository, userRepository);
final ChangeItemStatusService changeItemStatusService = new ChangeItemStatusService(loanRepository, new StoreLoanAndItem(loanRepository, itemRepository));
return changeItemStatusService.getOpenLoan(request).thenApply(NotInItemStatusValidator::refuseWhenItemIsNotClaimedReturned).thenApply(r -> declareLoanMissing(r, request)).thenCompose(changeItemStatusService::updateLoanAndItem).thenCompose(r -> r.after(loan -> createNote(clients, loan)));
}
Aggregations