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);
}
Aggregations