Commit 67f7e229 authored by michael.simon's avatar michael.simon
Browse files

re-fix sort order for new primefaces version

parent 1165fa81
......@@ -34,6 +34,7 @@ import javax.persistence.criteria.Root;
import org.primefaces.model.FilterMeta;
import org.primefaces.model.MatchMode;
import org.primefaces.model.SortMeta;
import org.primefaces.model.SortOrder;
import edu.kit.scc.webreg.dao.BaseDao;
import edu.kit.scc.webreg.dao.GenericSortOrder;
......@@ -115,6 +116,8 @@ public abstract class JpaBaseDao<T extends BaseEntity<PK>, PK extends Serializab
// criteria.orderBy(getSortOrder(builder, root, sortField, sortOrder));
// }
criteria.orderBy(getSortOrder(builder, root, sortBy));
Query q = em.createQuery(criteria);
q.setFirstResult(first).setMaxResults(pageSize);
......@@ -333,6 +336,24 @@ public abstract class JpaBaseDao<T extends BaseEntity<PK>, PK extends Serializab
return path;
}
}
protected List<Order> getSortOrder(CriteriaBuilder builder, Root<T> root, Map<String, SortMeta> sortBy) {
List<Order> orderList = new ArrayList<Order>();
if (sortBy != null) {
for (Entry<String, SortMeta> entry : sortBy.entrySet()) {
if (entry.getValue() != null && entry.getValue().getOrder() != null && entry.getValue().getField() != null) {
if (entry.getValue().getOrder().equals(SortOrder.ASCENDING))
orderList.add(builder.asc(resolvePath(root, entry.getValue().getField())));
else if (entry.getValue().getOrder().equals(SortOrder.DESCENDING))
orderList.add(builder.desc(resolvePath(root, entry.getValue().getField())));
}
}
}
return orderList;
}
protected Order getSortOrder(CriteriaBuilder builder, Root<T> root, String sortField, GenericSortOrder sortOrder) {
if (sortOrder == GenericSortOrder.ASC)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment