Search in sources :

Example 1 with PromotionCriteria

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);
    }
}
Also used : TechnicalException(io.gravitee.repository.exceptions.TechnicalException) Page(io.gravitee.common.data.domain.Page) Promotion(io.gravitee.repository.management.model.Promotion) PromotionCriteria(io.gravitee.repository.management.api.search.PromotionCriteria)

Aggregations

Page (io.gravitee.common.data.domain.Page)1 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)1 PromotionCriteria (io.gravitee.repository.management.api.search.PromotionCriteria)1 Promotion (io.gravitee.repository.management.model.Promotion)1