Commit b2e4836a by Tuomas Riihimäki

Print sorting

1 parent 5c87ae42
...@@ -15,6 +15,7 @@ import javax.persistence.criteria.Root; ...@@ -15,6 +15,7 @@ import javax.persistence.criteria.Root;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.enums.CardState; import fi.codecrew.moya.enums.CardState;
import fi.codecrew.moya.model.CardTemplate_;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
...@@ -98,8 +99,10 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -98,8 +99,10 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class); CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class);
Root<PrintedCard> root = cq.from(PrintedCard.class); Root<PrintedCard> root = cq.from(PrintedCard.class);
cq.select(root).distinct(true);
List<Predicate> preds = new ArrayList<Predicate>(); List<Predicate> preds = new ArrayList<Predicate>();
preds.add(cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent())); preds.add(cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent()));
if (state.length > 0) { if (state.length > 0) {
...@@ -107,6 +110,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -107,6 +110,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
} }
cq.where(preds.toArray(new Predicate[preds.size()])); cq.where(preds.toArray(new Predicate[preds.size()]));
cq.orderBy(cb.asc(root.get(PrintedCard_.user)), cb.asc(root.get(PrintedCard_.template).get(CardTemplate_.power)));
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!