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)));
}
Aggregations