Search in sources :

Example 1 with OrSearchCondition

use of org.apache.cxf.jaxrs.ext.search.OrSearchCondition in project cxf by apache.

the class AbstractJPATypedQueryVisitor method visit.

public void visit(SearchCondition<T> sc) {
    if (builder == null) {
        builder = em.getCriteriaBuilder();
        cq = builder.createQuery(queryClass);
        root = cq.from(tClass);
        predStack.push(new ArrayList<>());
    }
    if (sc.getStatement() != null) {
        predStack.peek().add(buildPredicate(sc.getStatement()));
    } else {
        predStack.push(new ArrayList<>());
        for (SearchCondition<T> condition : sc.getSearchConditions()) {
            condition.accept(this);
        }
        List<Predicate> predsList = predStack.pop();
        Predicate[] preds = predsList.toArray(new Predicate[predsList.size()]);
        Predicate newPred;
        if (sc instanceof OrSearchCondition) {
            newPred = builder.or(preds);
        } else {
            newPred = builder.and(preds);
        }
        predStack.peek().add(newPred);
    }
}
Also used : OrSearchCondition(org.apache.cxf.jaxrs.ext.search.OrSearchCondition) Predicate(javax.persistence.criteria.Predicate)

Aggregations

Predicate (javax.persistence.criteria.Predicate)1 OrSearchCondition (org.apache.cxf.jaxrs.ext.search.OrSearchCondition)1