Search in sources :

Example 1 with LoansForBorrowerFinder

use of org.folio.circulation.domain.anonymization.service.LoansForBorrowerFinder in project mod-circulation by folio-org.

the class LoanAnonymizationResource method anonymizeLoans.

private void anonymizeLoans(RoutingContext routingContext) {
    final WebContext context = new WebContext(routingContext);
    final Clients clients = Clients.create(context, client);
    String borrowerId = routingContext.request().getParam("userId");
    final var loanRepository = new LoanRepository(clients, new ItemRepository(clients), new UserRepository(clients));
    final var accountRepository = new AccountRepository(clients);
    final var loansFinder = new LoansForBorrowerFinder(borrowerId, loanRepository, accountRepository);
    final var anonymizeStorageLoansRepository = new AnonymizeStorageLoansRepository(clients);
    final var eventPublisher = new EventPublisher(clients.pubSubPublishingService());
    final var loanAnonymizationService = new DefaultLoanAnonymizationService(new AnonymizationCheckersService(), anonymizeStorageLoansRepository, eventPublisher);
    log.info("Initializing loan anonymization for borrower: {}", borrowerId);
    loanAnonymizationService.anonymizeLoans(loansFinder::findLoansToAnonymize).thenApply(AnonymizeLoansRepresentation::from).thenApply(r -> r.map(JsonHttpResponse::ok)).thenAccept(context::writeResultToHttpResponse);
}
Also used : UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) Clients(org.folio.circulation.support.Clients) LoansForBorrowerFinder(org.folio.circulation.domain.anonymization.service.LoansForBorrowerFinder) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository) MethodHandles(java.lang.invoke.MethodHandles) AnonymizeLoansRepresentation(org.folio.circulation.domain.representations.anonymization.AnonymizeLoansRepresentation) WebContext(org.folio.circulation.support.http.server.WebContext) Router(io.vertx.ext.web.Router) RoutingContext(io.vertx.ext.web.RoutingContext) JsonHttpResponse(org.folio.circulation.support.http.server.JsonHttpResponse) EventPublisher(org.folio.circulation.services.EventPublisher) RouteRegistration(org.folio.circulation.support.RouteRegistration) Logger(org.apache.logging.log4j.Logger) DefaultLoanAnonymizationService(org.folio.circulation.domain.anonymization.DefaultLoanAnonymizationService) AccountRepository(org.folio.circulation.infrastructure.storage.feesandfines.AccountRepository) LogManager(org.apache.logging.log4j.LogManager) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) AnonymizationCheckersService(org.folio.circulation.domain.anonymization.service.AnonymizationCheckersService) AnonymizeStorageLoansRepository(org.folio.circulation.infrastructure.storage.loans.AnonymizeStorageLoansRepository) HttpClient(io.vertx.core.http.HttpClient) WebContext(org.folio.circulation.support.http.server.WebContext) JsonHttpResponse(org.folio.circulation.support.http.server.JsonHttpResponse) EventPublisher(org.folio.circulation.services.EventPublisher) DefaultLoanAnonymizationService(org.folio.circulation.domain.anonymization.DefaultLoanAnonymizationService) AccountRepository(org.folio.circulation.infrastructure.storage.feesandfines.AccountRepository) Clients(org.folio.circulation.support.Clients) LoansForBorrowerFinder(org.folio.circulation.domain.anonymization.service.LoansForBorrowerFinder) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) AnonymizeLoansRepresentation(org.folio.circulation.domain.representations.anonymization.AnonymizeLoansRepresentation) AnonymizationCheckersService(org.folio.circulation.domain.anonymization.service.AnonymizationCheckersService) AnonymizeStorageLoansRepository(org.folio.circulation.infrastructure.storage.loans.AnonymizeStorageLoansRepository)

Aggregations

HttpClient (io.vertx.core.http.HttpClient)1 Router (io.vertx.ext.web.Router)1 RoutingContext (io.vertx.ext.web.RoutingContext)1 MethodHandles (java.lang.invoke.MethodHandles)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 DefaultLoanAnonymizationService (org.folio.circulation.domain.anonymization.DefaultLoanAnonymizationService)1 AnonymizationCheckersService (org.folio.circulation.domain.anonymization.service.AnonymizationCheckersService)1 LoansForBorrowerFinder (org.folio.circulation.domain.anonymization.service.LoansForBorrowerFinder)1 AnonymizeLoansRepresentation (org.folio.circulation.domain.representations.anonymization.AnonymizeLoansRepresentation)1 AccountRepository (org.folio.circulation.infrastructure.storage.feesandfines.AccountRepository)1 ItemRepository (org.folio.circulation.infrastructure.storage.inventory.ItemRepository)1 AnonymizeStorageLoansRepository (org.folio.circulation.infrastructure.storage.loans.AnonymizeStorageLoansRepository)1 LoanRepository (org.folio.circulation.infrastructure.storage.loans.LoanRepository)1 UserRepository (org.folio.circulation.infrastructure.storage.users.UserRepository)1 EventPublisher (org.folio.circulation.services.EventPublisher)1 Clients (org.folio.circulation.support.Clients)1 RouteRegistration (org.folio.circulation.support.RouteRegistration)1 JsonHttpResponse (org.folio.circulation.support.http.server.JsonHttpResponse)1 WebContext (org.folio.circulation.support.http.server.WebContext)1