use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class ScheduledNoticeProcessingResource method process.
private void process(RoutingContext routingContext) {
final WebContext context = new WebContext(routingContext);
final Clients clients = Clients.create(context, client);
final ScheduledNoticesRepository scheduledNoticesRepository = ScheduledNoticesRepository.using(clients);
final 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 requestRepository = RequestRepository.using(clients, itemRepository, userRepository, loanRepository);
safelyInitialise(configurationRepository::lookupSchedulerNoticesProcessingLimit).thenCompose(r -> r.after(limit -> findNoticesToSend(configurationRepository, scheduledNoticesRepository, limit))).thenCompose(r -> r.after(notices -> handleNotices(clients, requestRepository, loanRepository, notices))).thenApply(r -> r.map(toFixedValue(NoContentResponse::noContent))).exceptionally(CommonFailures::failedDueToServerError).thenAccept(context::writeResultToHttpResponse);
}
use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class ScheduledAgeToLostResource method scheduledAgeToLost.
private void scheduledAgeToLost(RoutingContext routingContext) {
final WebContext context = new WebContext(routingContext);
final var 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 MarkOverdueLoansAsAgedLostService ageToLostService = new MarkOverdueLoansAsAgedLostService(clients, itemRepository, loanRepository);
ageToLostService.processAgeToLost().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 UpdateRequestQueueTest method createServerErrorMockBatchRequestClient.
private Clients createServerErrorMockBatchRequestClient() {
Clients clients = mock(Clients.class);
CollectionResourceClient requestBatchClient = mock(CollectionResourceClient.class);
when(clients.requestsBatchStorage()).thenReturn(requestBatchClient);
when(requestBatchClient.post(any(JsonObject.class))).thenAnswer(rq -> completedFuture(of(() -> serverErrorBatchResponse)));
return clients;
}
use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class UpdateRequestQueueTest method setUp.
@BeforeEach
public void setUp() {
Clients clients = createServerErrorMockBatchRequestClient();
final ItemRepository itemRepository = new ItemRepository(clients);
final UserRepository userRepository = new UserRepository(clients);
final var loanRepository = new LoanRepository(clients, itemRepository, userRepository);
requestRepository = mock(RequestRepository.class);
requestQueueRepository = spy(new RequestQueueRepository(RequestRepository.using(clients, itemRepository, userRepository, loanRepository)));
updateRequestQueue = new UpdateRequestQueue(requestQueueRepository, requestRepository, null, null);
}
use of org.folio.circulation.support.Clients in project mod-circulation by folio-org.
the class AbstractCirculationRulesEngineResource method applyRules.
private <T> void applyRules(RoutingContext routingContext, BiFunction<CirculationRulesProcessor, RulesExecutionParameters, CompletableFuture<Result<T>>> triggerFunction, Function<T, CompletableFuture<Result<JsonObject>>> mapToJson) {
val request = routingContext.request();
if (invalidApplyParameters(request)) {
return;
}
final WebContext context = new WebContext(routingContext);
final Clients clients = Clients.create(context, client);
triggerFunction.apply(clients.circulationRulesProcessor(), forRequest(context)).thenCompose(r -> r.after(mapToJson)).thenApply(r -> r.map(JsonHttpResponse::ok)).thenAccept(context::writeResultToHttpResponse);
}
Aggregations