use of io.gravitee.repository.management.api.search.TicketCriteria in project gravitee-management-rest-api by gravitee-io.
the class TicketServiceImpl method search.
@Override
public Page<TicketEntity> search(TicketQuery query, Sortable sortable, Pageable pageable) {
try {
LOGGER.debug("search tickets");
TicketCriteria criteria = queryToCriteriaBuilder(query).build();
Page<Ticket> tickets = ticketRepository.search(criteria, buildSortable(sortable), new PageableBuilder().pageNumber(pageable.getPageNumber() - 1).pageSize(pageable.getPageSize()).build());
List<TicketEntity> entities = tickets.getContent().stream().map(this::getApiNameAndApplicationName).map(this::convert).collect(Collectors.toList());
LOGGER.debug("search tickets - Done with {} elements", entities.size());
return new Page<>(entities, tickets.getPageNumber() + 1, (int) tickets.getPageElements(), tickets.getTotalElements());
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to search tickets", ex);
throw new TechnicalManagementException("An error occurs while trying to search tickets", ex);
}
}
Aggregations