use of org.hisp.dhis.analytics.dimensions.AnalyticsDimensionsPagingWrapper in project dhis2-core by dhis2.
the class DimensionFilteringAndPagingService method pageAndFilter.
public AnalyticsDimensionsPagingWrapper<ObjectNode> pageAndFilter(Collection<DimensionResponse> dimensionResponses, DimensionsCriteria dimensionsCriteria, List<String> fields) {
AnalyticsDimensionsPagingWrapper<ObjectNode> pagingWrapper = new AnalyticsDimensionsPagingWrapper<>();
List<DimensionResponse> filteredDimensions = filterStream(dimensionResponses.stream(), dimensionsCriteria).collect(Collectors.toList());
FieldFilterParams<DimensionResponse> filterParams = FieldFilterParams.of(sortedAndPagedStream(filteredDimensions.stream(), dimensionsCriteria).collect(Collectors.toList()), fields);
List<ObjectNode> objectNodes = fieldFilterService.toObjectNodes(filterParams);
pagingWrapper.setDimensions(objectNodes);
if (dimensionsCriteria.isPaging()) {
pagingWrapper.setPager(new Pager(Optional.ofNullable(dimensionsCriteria.getPage()).orElse(1), filteredDimensions.size(), dimensionsCriteria.getPageSize()));
}
return pagingWrapper;
}
Aggregations