Search in sources :

Example 1 with TicketCriteria

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);
    }
}
Also used : Ticket(io.gravitee.repository.management.model.Ticket) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) TicketCriteria(io.gravitee.repository.management.api.search.TicketCriteria) Page(io.gravitee.common.data.domain.Page) PageableBuilder(io.gravitee.repository.management.api.search.builder.PageableBuilder) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Aggregations

Page (io.gravitee.common.data.domain.Page)1 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)1 TicketCriteria (io.gravitee.repository.management.api.search.TicketCriteria)1 PageableBuilder (io.gravitee.repository.management.api.search.builder.PageableBuilder)1 Ticket (io.gravitee.repository.management.model.Ticket)1 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)1