Search in sources :

Example 1 with LoadService

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();
}
Also used : HoldingsIQService(org.folio.holdingsiq.service.HoldingsIQService) PackageServiceImpl(org.folio.rmapi.PackageServiceImpl) LoadService(org.folio.holdingsiq.service.LoadService) Configuration(org.folio.holdingsiq.model.Configuration) LoadServiceImpl(org.folio.holdingsiq.service.impl.LoadServiceImpl) ResourcesServiceImpl(org.folio.rmapi.ResourcesServiceImpl) ProvidersServiceImpl(org.folio.rmapi.ProvidersServiceImpl) HoldingsIQServiceImpl(org.folio.holdingsiq.service.impl.HoldingsIQServiceImpl) TitlesServiceImpl(org.folio.rmapi.TitlesServiceImpl)

Example 2 with LoadService

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;
    }));
}
Also used : HoldingsServiceMessagesFactory.getSnapshotCreatedMessage(org.folio.repository.holdings.HoldingsServiceMessagesFactory.getSnapshotCreatedMessage) IntStream(java.util.stream.IntStream) DateTimeFormatterBuilder(java.time.format.DateTimeFormatterBuilder) COMPLETED(org.folio.repository.holdings.LoadStatus.COMPLETED) Producer(org.glassfish.jersey.internal.util.Producer) ZonedDateTime(java.time.ZonedDateTime) LocalDateTime(java.time.LocalDateTime) CompletableFuture(java.util.concurrent.CompletableFuture) LoadHoldingsMessage(org.folio.service.holdings.message.LoadHoldingsMessage) StringUtils(org.apache.commons.lang3.StringUtils) HoldingsServiceMessagesFactory.getLoadFailedMessage(org.folio.repository.holdings.HoldingsServiceMessagesFactory.getLoadFailedMessage) Value(org.springframework.beans.factory.annotation.Value) BiPredicate(java.util.function.BiPredicate) IN_PROGRESS(org.folio.repository.holdings.LoadStatus.IN_PROGRESS) Nullable(org.springframework.lang.Nullable) ZoneOffset(java.time.ZoneOffset) INTEGER_ZERO(org.apache.commons.lang3.math.NumberUtils.INTEGER_ZERO) IntFunction(java.util.function.IntFunction) LoadStatus(org.folio.repository.holdings.LoadStatus) Vertx(io.vertx.core.Vertx) Collectors(java.util.stream.Collectors) HOLDINGS_SERVICE_ADDRESS(org.folio.service.holdings.HoldingConstants.HOLDINGS_SERVICE_ADDRESS) List(java.util.List) Component(org.springframework.stereotype.Component) ChronoUnit(java.time.temporal.ChronoUnit) Logger(org.apache.logging.log4j.Logger) DateTimeFormatter(java.time.format.DateTimeFormatter) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) LoadService(org.folio.holdingsiq.service.LoadService) LoadServiceImpl(org.folio.holdingsiq.service.impl.LoadServiceImpl) LogManager(org.apache.logging.log4j.LogManager) HoldingsServiceMessagesFactory.getSnapshotFailedMessage(org.folio.repository.holdings.HoldingsServiceMessagesFactory.getSnapshotFailedMessage) LoadStatus(org.folio.repository.holdings.LoadStatus)

Aggregations

LoadService (org.folio.holdingsiq.service.LoadService)2 LoadServiceImpl (org.folio.holdingsiq.service.impl.LoadServiceImpl)2 Vertx (io.vertx.core.Vertx)1 LocalDateTime (java.time.LocalDateTime)1 ZoneOffset (java.time.ZoneOffset)1 ZonedDateTime (java.time.ZonedDateTime)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 DateTimeFormatterBuilder (java.time.format.DateTimeFormatterBuilder)1 ChronoUnit (java.time.temporal.ChronoUnit)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 BiPredicate (java.util.function.BiPredicate)1 IntFunction (java.util.function.IntFunction)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 StringUtils (org.apache.commons.lang3.StringUtils)1 INTEGER_ZERO (org.apache.commons.lang3.math.NumberUtils.INTEGER_ZERO)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 Configuration (org.folio.holdingsiq.model.Configuration)1