use of org.folio.holdingsiq.service.LoadService in project mod-kb-ebsco-java by folio-org.
the class RMAPITemplateContextBuilder method build.
public RMAPITemplateContext build() {
String tenant = okapiData.getTenant();
Configuration configuration = converter.convert(credentials);
final HoldingsIQService holdingsService = new HoldingsIQServiceImpl(configuration, vertx);
final TitlesServiceImpl titlesService = new TitlesServiceImpl(configuration, vertx, okapiData.getTenant(), titleCache);
final ProvidersServiceImpl providersService = new ProvidersServiceImpl(configuration, vertx, tenant, holdingsService, vendorCache);
final PackageServiceImpl packagesService = new PackageServiceImpl(configuration, vertx, tenant, providersService, titlesService, packageCache, searchProperties);
final ResourcesServiceImpl resourcesService = new ResourcesServiceImpl(configuration, vertx, tenant, providersService, packagesService, resourceCache);
final LoadService loadService = new LoadServiceImpl(configuration, vertx);
providersService.setPackagesService(packagesService);
return RMAPITemplateContext.builder().configuration(configuration).okapiData(okapiData).credentialsId(credentials.getId()).credentialsName(credentials.getAttributes().getName()).holdingsService(holdingsService).packagesService(packagesService).providersService(providersService).resourcesService(resourcesService).titlesService(titlesService).loadingService(loadService).build();
}
use of org.folio.holdingsiq.service.LoadService in project mod-kb-ebsco-java by folio-org.
the class AbstractLoadServiceFacade method waitForCompleteStatus.
private void waitForCompleteStatus(int retries, String transactionId, CompletableFuture<HoldingsStatus> future, LoadService loadingService) {
vertx.setTimer(statusRetryDelay, timerId -> getLoadingStatus(loadingService, transactionId).thenAccept(loadStatus -> {
final LoadStatus status = loadStatus.getStatus();
logger.info("Getting status of stage snapshot: {}.", status);
if (COMPLETED.equals(status)) {
final Integer totalCount = loadStatus.getTotalCount();
if (INTEGER_ZERO.equals(totalCount)) {
throw new IllegalStateException("Snapshot created with invalid totalCount:" + loadStatus.toString());
} else {
future.complete(loadStatus);
}
} else if (IN_PROGRESS.equals(status)) {
if (retries <= 1) {
throw new IllegalStateException("Failed to get status with status response:" + loadStatus.getStatus());
}
waitForCompleteStatus(retries - 1, transactionId, future, loadingService);
} else {
future.completeExceptionally(new IllegalStateException("Failed to get status with status response:" + loadStatus));
}
}).exceptionally(throwable -> {
future.completeExceptionally(throwable);
return null;
}));
}
Aggregations