Search in sources :

Example 1 with PackageBulkResult

use of org.folio.rmapi.result.PackageBulkResult in project mod-kb-ebsco-java by folio-org.

the class PackageServiceImpl method retrievePackagesBulk.

public CompletableFuture<PackageBulkResult> retrievePackagesBulk(Set<String> packageIds) {
    Set<CompletableFuture<Result<PackageResult, String>>> futures = new HashSet<>();
    packageIds.forEach(inputId -> {
        try {
            PackageId id = IdParser.parsePackageId(inputId);
            futures.add(retrievePackageForBulk(id));
        } catch (ValidationException e) {
            futures.add(completedFuture(new Failure<>(inputId)));
        }
    });
    return allOfSucceeded(futures, throwable -> LOG.warn(throwable.getMessage(), throwable)).thenApply(this::mapToPackageBulk);
}
Also used : CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Sort(org.folio.holdingsiq.model.Sort) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) PackageId(org.folio.holdingsiq.model.PackageId) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FutureUtils.allOfSucceeded(org.folio.util.FutureUtils.allOfSucceeded) PackageBulkResult(org.folio.rmapi.result.PackageBulkResult) SearchProperties(org.folio.properties.common.SearchProperties) NoSuchElementException(java.util.NoSuchElementException) TitlesHoldingsIQService(org.folio.holdingsiq.service.TitlesHoldingsIQService) PackageCacheKey(org.folio.rmapi.cache.PackageCacheKey) VertxCache(org.folio.cache.VertxCache) IdParser(org.folio.rest.util.IdParser) Vertx(io.vertx.core.Vertx) Set(java.util.Set) Titles(org.folio.holdingsiq.model.Titles) VendorResult(org.folio.rmapi.result.VendorResult) Collectors(java.util.stream.Collectors) FilterQuery(org.folio.holdingsiq.model.FilterQuery) Consumer(java.util.function.Consumer) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Packages(org.folio.holdingsiq.model.Packages) PackageResult(org.folio.rmapi.result.PackageResult) ValidationException(javax.validation.ValidationException) Configuration(org.folio.holdingsiq.model.Configuration) PackageData(org.folio.holdingsiq.model.PackageData) Comparator(java.util.Comparator) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) PackagesHoldingsIQServiceImpl(org.folio.holdingsiq.service.impl.PackagesHoldingsIQServiceImpl) CompletableFuture(java.util.concurrent.CompletableFuture) ValidationException(javax.validation.ValidationException) PackageResult(org.folio.rmapi.result.PackageResult) PackageId(org.folio.holdingsiq.model.PackageId) HashSet(java.util.HashSet)

Aggregations

Vertx (io.vertx.core.Vertx)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 List (java.util.List)1 NoSuchElementException (java.util.NoSuchElementException)1 Set (java.util.Set)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 ValidationException (javax.validation.ValidationException)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 VertxCache (org.folio.cache.VertxCache)1 Configuration (org.folio.holdingsiq.model.Configuration)1 FilterQuery (org.folio.holdingsiq.model.FilterQuery)1 PackageByIdData (org.folio.holdingsiq.model.PackageByIdData)1