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 ");
}
}
Aggregations