use of org.folio.repository.resources.DbResource 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);
}
Aggregations