Search in sources :

Example 1 with SortDirection

use of org.molgenis.data.elasticsearch.generator.model.SortDirection in project molgenis by molgenis.

the class SortGenerator method toSortOrder.

private SortOrder toSortOrder(org.molgenis.data.Sort.Order order, EntityType entityType) {
    String attributeName = order.getAttr();
    if (attributeName == null) {
        throw new IllegalArgumentException("Sort property is null");
    }
    Attribute sortAttribute = entityType.getAttribute(attributeName);
    if (sortAttribute == null) {
        throw new UnknownAttributeException(entityType, attributeName);
    }
    String sortField = getSortField(sortAttribute);
    SortDirection sortDirection = getSortDirection(order.getDirection());
    return SortOrder.create(sortField, sortDirection);
}
Also used : SortDirection(org.molgenis.data.elasticsearch.generator.model.SortDirection) Attribute(org.molgenis.data.meta.model.Attribute) UnknownAttributeException(org.molgenis.data.UnknownAttributeException)

Aggregations

UnknownAttributeException (org.molgenis.data.UnknownAttributeException)1 SortDirection (org.molgenis.data.elasticsearch.generator.model.SortDirection)1 Attribute (org.molgenis.data.meta.model.Attribute)1