use of org.alfresco.service.cmr.search.SearchParameters.SortDefinition in project alfresco-remote-api by Alfresco.
the class SearchMapper method fromSort.
/**
* SearchParameters from List<SortDef>
* @param sp SearchParameters
* @param sort List<SortDef>
*/
public void fromSort(SearchParameters sp, List<SortDef> sort) {
if (sort != null && !sort.isEmpty()) {
if (LANGUAGE_CMIS_ALFRESCO.equals(sp.getLanguage())) {
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID, new Object[] { ": sort {} not allowed with cmis language" });
}
for (SortDef sortDef : sort) {
try {
SortType sortType = SortType.valueOf(sortDef.getType());
String field = sortDef.getField();
sp.addSort(new SortDefinition(sortType, field, sortDef.isAscending()));
} catch (IllegalArgumentException e) {
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID, new Object[] { sortDef.getType() });
}
}
}
}
Aggregations