use of io.gravitee.repository.management.api.search.PromotionCriteria in project gravitee-management-rest-api by gravitee-io.
the class PromotionServiceImpl method search.
@Override
public Page<PromotionEntity> search(PromotionQuery query, Sortable sortable, Pageable pageable) {
try {
LOGGER.debug("Searching promotions");
PromotionCriteria criteria = queryToCriteriaBuilder(query).build();
Page<Promotion> promotions = promotionRepository.search(criteria, buildSortable(sortable), buildPageable(pageable));
List<PromotionEntity> entities = promotions.getContent().stream().map(this::convert).collect(Collectors.toList());
LOGGER.debug("Searching promotions - Done with {} elements", entities.size());
return new Page<>(entities, promotions.getPageNumber() + 1, (int) promotions.getPageElements(), promotions.getTotalElements());
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to search promotions", ex);
throw new TechnicalManagementException("An error occurs while trying to search promotions", ex);
}
}
Aggregations