private Expression getOrCreatePathExpression() { if (pathExpression == null) { // as we expect both Db and Obj paths here, let's pass the path // through the parser to generate the correct expression template... this.pathExpression = ExpressionFactory.exp(dbPath); } return pathExpression; }
/** * Creates an expression that matches all key-values pairs in * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a DB_PATH expression. AND is used to * join pair binary expressions. */ public static Expression matchAllDbExp(Map<String, ?> map, int pairType) { List<Expression> pairs = new ArrayList<>(map.size()); for (Map.Entry<String, ?> entry : map.entrySet()) { Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTDbPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.AND, pairs); }
/** * Creates an expression that matches any of the objects contained in the * <code>objects</code> array */ public static Expression matchAnyExp(Persistent... objects) { if (objects == null || objects.length == 0) { return expFalse(); } List<Expression> pairs = new ArrayList<>(objects.length); for (Persistent object : objects) { pairs.add(matchExp(object)); } return joinExp(Expression.OR, pairs); }
Expression gte(Filter filter) { return (filter.getValue() == null) ? expFalse() : greaterOrEqualExp(filter.getProperty(), filter.getValue()); }
if (filter.getCaseSensitive()) { if (filter.getExactMatch()) { newExpression = ExpressionFactory.matchExp(key, val); } else if (filter.getAnyMatch()) { newExpression = ExpressionFactory.likeExp(key, "%" + val + "%"); } else { newExpression = ExpressionFactory.likeExp(key, val + "%"); newExpression = ExpressionFactory.likeIgnoreCaseExp(key, val); } else if (filter.getAnyMatch()) { newExpression = ExpressionFactory.likeIgnoreCaseExp(key, "%" + val + "%"); } else { newExpression = ExpressionFactory.likeIgnoreCaseExp(key, val + "%"); newExpression = ExpressionFactory.matchExp(key, String.valueOf(val).toLowerCase().equals("true")); newExpression = ExpressionFactory.matchExp(key, numVal); } else if (t == Filter.NOT_EQUAL) { newExpression = ExpressionFactory.noMatchExp(key, numVal); } else if (t == Filter.LESS_THAN) { newExpression = ExpressionFactory.lessExp(key, numVal); } else if (t == Filter.LESS_THAN_EQUAL) { newExpression = ExpressionFactory.lessOrEqualExp(key, numVal); } else if (t == Filter.GREATER_THAN) { newExpression = ExpressionFactory.greaterExp(key, numVal); } else if (t == Filter.GREATER_THAN_EQUAL) { newExpression = ExpressionFactory.greaterOrEqualExp(key, numVal); continue;
@Override public Expression expressionForKey(Object key) { // allowing nulls here return ExpressionFactory.matchExp(keyProperty, key); }
return ExpressionFactory.joinExp(aggregateClass, childExpressions); Expression keyExp = ExpressionFactory.exp(key); try { entity.lastPathComponent(keyExp, Collections.emptyMap()); Expression exp = ExpressionFactory.expressionOfType(expressionTypeForQualifier(qualifierMap));
/** * @since 4.0 */ public static Expression and(Collection<Expression> expressions) { return joinExp(Expression.AND, expressions); }
/** * @since 4.0 * @see ExpressionFactory#likeIgnoreCaseExp(String, Object) */ static Expression likeIgnoreCaseExp(Expression exp, Object value) { return likeIgnoreCaseExp(exp, value, (char) 0); }
public void addRange(String fieldName, Object start, Object end) { ObjEntityViewField field = queryTarget.getField(fieldName); String path = null; if (field.getCalcType().getValue() == CalcTypeEnum.NO_CALC_TYPE_VALUE) { path = field.getObjAttribute().getName(); } else if (field.isLookup()) { path = field.getObjRelationship().getName(); } Object rawStart = field.toRawValue(start); Object rawEnd = field.toRawValue(end); Expression expr = null; if (rawStart != null && rawEnd != null) expr = ExpressionFactory.betweenExp(path, rawStart, rawEnd); else if (rawStart != null) expr = ExpressionFactory.greaterOrEqualExp(path, rawStart); else if (rawEnd != null) expr = ExpressionFactory.lessOrEqualExp(path, rawEnd); if (expr != null) conditions.add(expr); }
public Expression notExp() { Expression exp = ExpressionFactory.expressionOfType(Expression.NOT); exp.setOperand(0, this); return exp; }
quals.add(ExpressionFactory.matchAllDbExp(map, Expression.EQUAL_TO)); while (fetchBegin < qualsSize) { SelectQuery query = new SelectQuery(rootEntity, ExpressionFactory .joinExp(Expression.OR, quals.subList(fetchBegin, fetchEnd)));
.joinExp(aggregateClass, childExpressions); .expressionOfType(expressionTypeForQualifier(qualifierMap));
public void addLike(String fieldName, Object value, boolean caseSensetive) { ObjEntityViewField field = queryTarget.getField(fieldName); String path = null; if (field.getCalcType().getValue() == CalcTypeEnum.NO_CALC_TYPE_VALUE) { path = field.getObjAttribute().getName(); } else if (field.isLookup()) { path = field.getObjRelationship().getName(); } Object rawValue = field.toRawValue(value); String pattern = (rawValue != null ? rawValue.toString() : ""); Expression expr = (caseSensetive ? ExpressionFactory.likeExp(path, pattern) : ExpressionFactory.likeIgnoreCaseExp(path, pattern)); conditions.add(expr); }
Expression lte(Filter filter) { return (filter.getValue() == null) ? expFalse() : lessOrEqualExp(filter.getProperty(), filter.getValue()); }
/** * A convenience method to create an OBJ_PATH "less than or equal to" * expression. */ public static Expression lessOrEqualExp(String pathSpec, Object value) { return lessOrEqualExp(new ASTObjPath(pathSpec), value); }
/** * A convenience method to create an OBJ_PATH "greater than or equal to" * expression. */ public static Expression greaterOrEqualExp(String pathSpec, Object value) { return greaterOrEqualExp(new ASTObjPath(pathSpec), value); }
Expression gt(Filter filter) { return (filter.getValue() == null) ? expFalse() : greaterExp(filter.getProperty(), filter.getValue()); }
/** * A convenience method to create an OBJ_PATH "greater than" expression. */ public static Expression greaterExp(String pathSpec, Object value) { return greaterExp(new ASTObjPath(pathSpec), value); }