Search in sources :

Example 1 with AnalyticsDimensionsPagingWrapper

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Pager(org.hisp.dhis.common.Pager) AnalyticsDimensionsPagingWrapper(org.hisp.dhis.analytics.dimensions.AnalyticsDimensionsPagingWrapper)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 AnalyticsDimensionsPagingWrapper (org.hisp.dhis.analytics.dimensions.AnalyticsDimensionsPagingWrapper)1 Pager (org.hisp.dhis.common.Pager)1