use of org.eclipse.kapua.model.query.predicate.KapuaOrPredicate in project kapua by eclipse.
the class ServiceDAO method handleOrPredicate.
@SuppressWarnings("rawtypes")
private static <E> Expression<Boolean> handleOrPredicate(KapuaOrPredicate andPredicate, Map<ParameterExpression, Object> binds, CriteriaBuilder cb, Root<E> entityRoot, EntityType<E> entityType) throws KapuaException {
List<Expression<Boolean>> exprs = new ArrayList<Expression<Boolean>>();
for (KapuaPredicate pred : andPredicate.getPredicates()) {
Expression<Boolean> expr = handleKapuaQueryPredicates(pred, binds, cb, entityRoot, entityType);
exprs.add(expr);
}
return cb.or(exprs.toArray(new Predicate[] {}));
}
use of org.eclipse.kapua.model.query.predicate.KapuaOrPredicate in project kapua by eclipse.
the class ServiceDAO method handleKapuaQueryPredicates.
/**
* Criteria for query entity utility method
*
* @param qp
* @param binds
* @param cb
* @param userPermissionRoot
* @param entityType
* @return
* @throws KapuaException
*/
@SuppressWarnings("rawtypes")
protected static <E> Expression<Boolean> handleKapuaQueryPredicates(KapuaPredicate qp, Map<ParameterExpression, Object> binds, CriteriaBuilder cb, Root<E> userPermissionRoot, EntityType<E> entityType) throws KapuaException {
Expression<Boolean> expr = null;
if (qp instanceof KapuaAttributePredicate) {
KapuaAttributePredicate attrPred = (KapuaAttributePredicate) qp;
expr = handleAttributePredicate(attrPred, binds, cb, userPermissionRoot, entityType);
} else if (qp instanceof KapuaAndPredicate) {
KapuaAndPredicate andPredicate = (KapuaAndPredicate) qp;
expr = handleAndPredicate(andPredicate, binds, cb, userPermissionRoot, entityType);
} else if (qp instanceof KapuaOrPredicate) {
KapuaOrPredicate andPredicate = (KapuaOrPredicate) qp;
expr = handleOrPredicate(andPredicate, binds, cb, userPermissionRoot, entityType);
}
return expr;
}
Aggregations