use of org.folio.rest.jaxrs.model.MetaTotalResults in project mod-kb-ebsco-java by folio-org.
the class PackageCollectionResultConverter method convert.
@Override
public PackageCollection convert(@NonNull PackageCollectionResult packagesResult) {
Packages packages = packagesResult.getPackages();
List<DbPackage> dbPackages = packagesResult.getDbPackages();
List<PackageCollectionItem> packageList = mapItems(packages.getPackagesList(), packageData -> {
PackageCollectionItem item = packageCollectionItemConverter.convert(packageData);
item.getAttributes().withTags(new Tags().withTagList(getTagsById(dbPackages, createPackageId(packageData))));
return item;
});
return new PackageCollection().withJsonapi(RestConstants.JSONAPI).withMeta(new MetaTotalResults().withTotalResults(packages.getTotalResults())).withData(packageList);
}
use of org.folio.rest.jaxrs.model.MetaTotalResults in project mod-kb-ebsco-java by folio-org.
the class ResourceCollectionResultConverter method convert.
@Override
public ResourceCollection convert(@NonNull ResourceCollectionResult resourceCollectionResult) {
final Titles titles = resourceCollectionResult.getTitles();
final List<DbResource> resources = resourceCollectionResult.getTitlesList();
final List<DbHoldingInfo> holdings = resourceCollectionResult.getHoldings();
final List<ResourceCollectionItem> resourceCollectionItems = mapItems(titles.getTitleList(), title -> mapResourceCollectionItem(resources, resourceCollectionItemConverter.convert(title), createResourceId(title)));
final List<ResourceCollectionItem> holdingCollectionItems = mapItems(holdings, dbHolding -> mapResourceCollectionItem(resources, holdingCollectionItemConverter.convert(dbHolding), createResourceId(dbHolding)));
resourceCollectionItems.addAll(holdingCollectionItems);
resourceCollectionItems.sort(Comparator.comparing(o -> o.getAttributes().getName()));
return new ResourceCollection().withJsonapi(RestConstants.JSONAPI).withMeta(new MetaTotalResults().withTotalResults(titles.getTotalResults())).withData(resourceCollectionItems);
}
use of org.folio.rest.jaxrs.model.MetaTotalResults in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturnFilteredResourcesWithNonEmptyCustomerResourceList.
@Test
public void shouldReturnFilteredResourcesWithNonEmptyCustomerResourceList() throws IOException, URISyntaxException {
mockResourceById(RESOURCES_BY_PACKAGE_ID_EMPTY_CUSTOMER_RESOURCE_LIST_STUB_FILE);
final ResourceCollection resourceCollection = getWithOk(PACKAGE_RESOURCES_PATH, STUB_TOKEN_HEADER).as(ResourceCollection.class);
final MetaTotalResults metaTotalResults = resourceCollection.getMeta();
assertThat(metaTotalResults.getTotalResults(), equalTo(3));
}
Aggregations