Search in sources :

Example 1 with SortField

use of eu.europa.ec.fisheries.schema.exchange.v1.SortField in project UVMS-ExchangeModule-APP by UnionVMS.

the class SearchFieldMapper method getSortingString.

private static void getSortingString(Sorting sorting, StringBuilder selectBuffer) throws ExchangeSearchMapperException {
    if (sorting != null && sorting.getSortBy() != null) {
        SortField sortField = sorting.getSortBy();
        SortFieldMapper sortFieldMapper = null;
        if (sortField != null) {
            try {
                sortFieldMapper = mapSortField(sortField);
            } catch (ExchangeSearchMapperException e) {
                LOG.error("Error while mapping criteria", e);
                throw e;
            }
        }
        String fieldName = sortFieldMapper.getFieldName();
        String sortingDirection = "ASC";
        if (sorting.isReversed()) {
            sortingDirection = "DESC";
        }
        selectBuffer.append(" order by " + SearchTable.LOG.getTableAlias() + ".").append(fieldName).append(" ").append(sortingDirection);
    } else {
        selectBuffer.append(" order by " + SearchTable.LOG.getTableAlias() + ".updateTime desc ");
    }
}
Also used : ExchangeSearchMapperException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeSearchMapperException) SortField(eu.europa.ec.fisheries.schema.exchange.v1.SortField)

Aggregations

SortField (eu.europa.ec.fisheries.schema.exchange.v1.SortField)1 ExchangeSearchMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeSearchMapperException)1