use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class LoanCollectionResource method empty.
@Override
void empty(RoutingContext routingContext) {
WebContext context = new WebContext(routingContext);
Clients clients = Clients.create(context, client);
clients.loansStorage().delete().thenApply(r -> r.map(toFixedValue(NoContentResponse::noContent))).thenAccept(context::writeResultToHttpResponse);
}
use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class LoanCollectionResource method delete.
@Override
void delete(RoutingContext routingContext) {
WebContext context = new WebContext(routingContext);
Clients clients = Clients.create(context, client);
String id = routingContext.request().getParam("id");
clients.loansStorage().delete(id).thenApply(r -> r.map(toFixedValue(NoContentResponse::noContent))).thenAccept(context::writeResultToHttpResponse);
}
use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class LoanCollectionResource method get.
@Override
void get(RoutingContext routingContext) {
final WebContext context = new WebContext(routingContext);
final Clients clients = Clients.create(context, client);
final var userRepository = new UserRepository(clients);
final var loanRepository = new LoanRepository(clients, new ItemRepository(clients), userRepository);
final ServicePointRepository servicePointRepository = new ServicePointRepository(clients);
final LoanRepresentation loanRepresentation = new LoanRepresentation();
final LoanPolicyRepository loanPolicyRepository = new LoanPolicyRepository(clients);
final OverdueFinePolicyRepository overdueFinePolicyRepository = new OverdueFinePolicyRepository(clients);
final LostItemPolicyRepository lostItemPolicyRepository = new LostItemPolicyRepository(clients);
final AccountRepository accountRepository = new AccountRepository(clients);
final PatronGroupRepository patronGroupRepository = new PatronGroupRepository(clients);
String id = routingContext.request().getParam("id");
loanRepository.getById(id).thenComposeAsync(accountRepository::findAccountsAndActionsForLoan).thenComposeAsync(servicePointRepository::findServicePointsForLoan).thenComposeAsync(userRepository::findUserForLoan).thenComposeAsync(loanPolicyRepository::findPolicyForLoan).thenComposeAsync(overdueFinePolicyRepository::findOverdueFinePolicyForLoan).thenComposeAsync(lostItemPolicyRepository::findLostItemPolicyForLoan).thenComposeAsync(patronGroupRepository::findGroupForLoan).thenApply(loanResult -> loanResult.map(loanRepresentation::extendedLoan)).thenApply(r -> r.map(JsonHttpResponse::ok)).thenAccept(context::writeResultToHttpResponse);
}
use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class PickSlipsResource method getMany.
private void getMany(RoutingContext routingContext) {
final WebContext context = new WebContext(routingContext);
final Clients clients = Clients.create(context, client);
final var userRepository = new UserRepository(clients);
final var itemRepository = new ItemRepository(clients);
final AddressTypeRepository addressTypeRepository = new AddressTypeRepository(clients);
final ServicePointRepository servicePointRepository = new ServicePointRepository(clients);
final UUID servicePointId = UUID.fromString(routingContext.request().getParam(SERVICE_POINT_ID_PARAM));
fetchLocationsForServicePoint(servicePointId, clients).thenComposeAsync(r -> r.after(locations -> fetchPagedItemsForLocations(locations, itemRepository, LocationRepository.using(clients, servicePointRepository)))).thenComposeAsync(r -> r.after(items -> fetchOpenPageRequestsForItems(items, clients))).thenComposeAsync(r -> r.after(userRepository::findUsersForRequests)).thenComposeAsync(r -> r.after(addressTypeRepository::findAddressTypesForRequests)).thenComposeAsync(r -> r.after(servicePointRepository::findServicePointsForRequests)).thenApply(flatMapResult(this::mapResultToJson)).thenApply(r -> r.map(JsonHttpResponse::ok)).thenAccept(context::writeResultToHttpResponse);
}
use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class ScheduledAnonymizationProcessingResource method scheduledAnonymizeLoans.
private void scheduledAnonymizeLoans(RoutingContext routingContext) {
final WebContext context = new WebContext(routingContext);
final Clients clients = Clients.create(context, client);
ConfigurationRepository configurationRepository = new ConfigurationRepository(clients);
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 anonymizeStorageLoansRepository = new AnonymizeStorageLoansRepository(clients);
final var eventPublisher = new EventPublisher(clients.pubSubPublishingService());
final var loansFinder = new LoansForTenantFinder(loanRepository, accountRepository, Environment.getScheduledAnonymizationNumberOfLoansToCheck());
log.info("Initializing loan anonymization for current tenant");
safelyInitialise(configurationRepository::loanHistoryConfiguration).thenApply(r -> r.map(config -> new DefaultLoanAnonymizationService(new AnonymizationCheckersService(config, ClockUtil::getZonedDateTime), anonymizeStorageLoansRepository, eventPublisher))).thenCompose(r -> r.after(service -> service.anonymizeLoans(loansFinder::findLoansToAnonymize))).thenApply(AnonymizeLoansRepresentation::from).thenApply(r -> r.map(JsonHttpResponse::ok)).exceptionally(CommonFailures::failedDueToServerError).thenAccept(context::writeResultToHttpResponse);
}
Aggregations