Search in sources :

Example 1 with DistributionDBResponse

use of com.synopsys.integration.alert.database.distribution.DistributionRepository.DistributionDBResponse in project hub-alert by blackducksoftware.

the class DefaultDistributionAccessor method retrieveData.

private AlertPagedModel<DistributionWithAuditInfo> retrieveData(int page, int pageSize, String sortName, Direction sortOrder, Function<PageRequest, Page<DistributionDBResponse>> retrieveData) {
    Sort sort = (sortName == null || sortOrder == null) ? Sort.unsorted() : Sort.by(sortOrder, sortName);
    PageRequest pageRequest = PageRequest.of(page, pageSize, sort);
    Page<DistributionDBResponse> pageOfResponses = retrieveData.apply(pageRequest);
    List<DistributionWithAuditInfo> distributionWithAuditInfos = pageOfResponses.get().map(this::convert).collect(Collectors.toList());
    return new AlertPagedModel<>(pageOfResponses.getTotalPages(), pageOfResponses.getNumber(), pageOfResponses.getSize(), distributionWithAuditInfos);
}
Also used : DistributionWithAuditInfo(com.synopsys.integration.alert.common.rest.model.DistributionWithAuditInfo) PageRequest(org.springframework.data.domain.PageRequest) DistributionDBResponse(com.synopsys.integration.alert.database.distribution.DistributionRepository.DistributionDBResponse) Sort(org.springframework.data.domain.Sort) AlertPagedModel(com.synopsys.integration.alert.common.rest.model.AlertPagedModel)

Aggregations

AlertPagedModel (com.synopsys.integration.alert.common.rest.model.AlertPagedModel)1 DistributionWithAuditInfo (com.synopsys.integration.alert.common.rest.model.DistributionWithAuditInfo)1 DistributionDBResponse (com.synopsys.integration.alert.database.distribution.DistributionRepository.DistributionDBResponse)1 PageRequest (org.springframework.data.domain.PageRequest)1 Sort (org.springframework.data.domain.Sort)1