use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class LoanRelatedFeeFineClosedHandlerResource method processEvent.
private CompletableFuture<Result<Loan>> processEvent(WebContext context, LoanRelatedFeeFineClosedEvent event, EventPublisher eventPublisher) {
final Clients clients = create(context, client);
final var itemRepository = new ItemRepository(clients);
final var userRepository = new UserRepository(clients);
final var loanRepository = new LoanRepository(clients, itemRepository, userRepository);
final var accountRepository = new AccountRepository(clients);
final var lostItemPolicyRepository = new LostItemPolicyRepository(clients);
return loanRepository.getById(event.getLoanId()).thenCompose(r -> r.after(loan -> {
if (loan.isItemLost()) {
return closeLoanWithLostItemIfLostFeesResolved(loan, loanRepository, itemRepository, accountRepository, lostItemPolicyRepository, eventPublisher);
}
return completedFuture(succeeded(loan));
}));
}
Aggregations