Search in sources :

Example 1 with VendorResult

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

the class ResourcesServiceImpl method retrieveResource.

public CompletableFuture<ResourceResult> retrieveResource(ResourceId resourceId, List<String> includes, boolean useCache) {
    CompletableFuture<Title> titleFuture;
    CompletableFuture<PackageByIdData> packageFuture;
    CompletableFuture<VendorResult> vendorFuture;
    if (useCache) {
        titleFuture = retrieveResourceWithCache(resourceId, tenantId, configuration);
    } else {
        titleFuture = super.retrieveResource(resourceId);
    }
    if (includes.contains(INCLUDE_PROVIDER_VALUE)) {
        vendorFuture = providerService.retrieveProvider(resourceId.getProviderIdPart(), "");
    } else {
        vendorFuture = completedFuture(new VendorResult(null, null));
    }
    if (includes.contains(INCLUDE_PACKAGE_VALUE)) {
        PackageId id = PackageId.builder().providerIdPart(resourceId.getProviderIdPart()).packageIdPart(resourceId.getPackageIdPart()).build();
        packageFuture = packagesService.retrievePackage(id);
    } else {
        packageFuture = completedFuture(null);
    }
    boolean includeTitle = includes.contains("title");
    return CompletableFuture.allOf(titleFuture, vendorFuture, packageFuture).thenCompose(o -> completedFuture(new ResourceResult(titleFuture.join(), vendorFuture.join().getVendor(), packageFuture.join(), includeTitle)));
}
Also used : ResourceResult(org.folio.rmapi.result.ResourceResult) VendorResult(org.folio.rmapi.result.VendorResult) Title(org.folio.holdingsiq.model.Title) PackageId(org.folio.holdingsiq.model.PackageId) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData)

Aggregations

PackageByIdData (org.folio.holdingsiq.model.PackageByIdData)1 PackageId (org.folio.holdingsiq.model.PackageId)1 Title (org.folio.holdingsiq.model.Title)1 ResourceResult (org.folio.rmapi.result.ResourceResult)1 VendorResult (org.folio.rmapi.result.VendorResult)1