Search in sources :

Example 41 with Clients

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));
    }));
}
Also used : UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) Clients(org.folio.circulation.support.Clients) LOAN_RELATED_FEE_FINE_CLOSED(org.folio.circulation.domain.EventType.LOAN_RELATED_FEE_FINE_CLOSED) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) LoanRelatedFeeFineClosedEvent(org.folio.circulation.domain.subscribers.LoanRelatedFeeFineClosedEvent) WebContext(org.folio.circulation.support.http.server.WebContext) Router(io.vertx.ext.web.Router) CompletableFuture(java.util.concurrent.CompletableFuture) LoanRelatedFeeFineClosedEvent.fromJson(org.folio.circulation.domain.subscribers.LoanRelatedFeeFineClosedEvent.fromJson) ValidationErrorFailure.singleValidationError(org.folio.circulation.support.ValidationErrorFailure.singleValidationError) Resource(org.folio.circulation.resources.Resource) RoutingContext(io.vertx.ext.web.RoutingContext) AccountRepository(org.folio.circulation.infrastructure.storage.feesandfines.AccountRepository) LostItemPolicyRepository(org.folio.circulation.infrastructure.storage.loans.LostItemPolicyRepository) Clients.create(org.folio.circulation.support.Clients.create) Result.failed(org.folio.circulation.support.results.Result.failed) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) Account(org.folio.circulation.domain.Account) CommonFailures(org.folio.circulation.support.results.CommonFailures) Result.succeeded(org.folio.circulation.support.results.Result.succeeded) Loan(org.folio.circulation.domain.Loan) MappingFunctions.toFixedValue(org.folio.circulation.support.results.MappingFunctions.toFixedValue) ValidationError(org.folio.circulation.support.http.server.ValidationError) Result(org.folio.circulation.support.results.Result) EventPublisher(org.folio.circulation.services.EventPublisher) NoContentResponse.noContent(org.folio.circulation.support.http.server.NoContentResponse.noContent) RouteRegistration(org.folio.circulation.support.RouteRegistration) Logger(org.apache.logging.log4j.Logger) StoreLoanAndItem(org.folio.circulation.StoreLoanAndItem) FeeFine.lostItemFeeTypes(org.folio.circulation.domain.FeeFine.lostItemFeeTypes) LogManager(org.apache.logging.log4j.LogManager) NoContentResponse(org.folio.circulation.support.http.server.NoContentResponse) HttpClient(io.vertx.core.http.HttpClient) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) LostItemPolicyRepository(org.folio.circulation.infrastructure.storage.loans.LostItemPolicyRepository) UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) AccountRepository(org.folio.circulation.infrastructure.storage.feesandfines.AccountRepository) Clients(org.folio.circulation.support.Clients) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository)

Aggregations

Clients (org.folio.circulation.support.Clients)41 WebContext (org.folio.circulation.support.http.server.WebContext)38 HttpClient (io.vertx.core.http.HttpClient)36 RoutingContext (io.vertx.ext.web.RoutingContext)36 ItemRepository (org.folio.circulation.infrastructure.storage.inventory.ItemRepository)33 UserRepository (org.folio.circulation.infrastructure.storage.users.UserRepository)32 LoanRepository (org.folio.circulation.infrastructure.storage.loans.LoanRepository)31 Result (org.folio.circulation.support.results.Result)31 Router (io.vertx.ext.web.Router)30 CompletableFuture (java.util.concurrent.CompletableFuture)29 JsonObject (io.vertx.core.json.JsonObject)26 EventPublisher (org.folio.circulation.services.EventPublisher)26 Result.succeeded (org.folio.circulation.support.results.Result.succeeded)23 RouteRegistration (org.folio.circulation.support.RouteRegistration)21 ValidationErrorFailure.singleValidationError (org.folio.circulation.support.ValidationErrorFailure.singleValidationError)21 Loan (org.folio.circulation.domain.Loan)19 RequestRepository (org.folio.circulation.infrastructure.storage.requests.RequestRepository)19 JsonHttpResponse (org.folio.circulation.support.http.server.JsonHttpResponse)19 NoContentResponse (org.folio.circulation.support.http.server.NoContentResponse)19 MappingFunctions.toFixedValue (org.folio.circulation.support.results.MappingFunctions.toFixedValue)19