@Override public Expression expressionForKey(Object key) { // allowing nulls here return ExpressionFactory.matchExp(keyProperty, key); }
/** * A convenience method to create an OBJ_PATH "equal to" expression. */ public static Expression matchExp(String pathSpec, Object value) { return matchExp(new ASTObjPath(pathSpec), value); }
/** * @return An expression representing equality to TRUE. */ public Expression isTrue() { return ExpressionFactory.matchExp(getExpression(), Boolean.TRUE); }
/** * @return An expression representing equality to FALSE. */ public Expression isFalse() { return ExpressionFactory.matchExp(getExpression(), Boolean.FALSE); }
/** * @return An expression representing equality to a value. */ public Expression eq(E value) { return ExpressionFactory.matchExp(getExpression(), value); }
/** * @return An expression representing null. */ public Expression isNull() { return ExpressionFactory.matchExp(getExpression(), null); }
/** * 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); }
/** * @return An expression representing a non-null value. */ public Expression isNotNull() { return ExpressionFactory.matchExp(getExpression(), null).notExp(); }
/** * @return An expression representing equality between two attributes * (columns). */ public Expression eq(Property<?> value) { return ExpressionFactory.matchExp(getExpression(), value.getExpression()); }
/** * Get a persistent entity based on a key value pair for a specific class. */ private Object getEntity(Object objectContext, Class<?> clazz, String key, Object value) { try { ObjectContext context = objectContext == null ? this.getReadOnlyObjectContext() : (ObjectContext) objectContext; Expression exp = ExpressionFactory.matchExp(key, value); SelectQuery query = new SelectQuery(clazz, exp); List<?> list = context.performQuery(query); return list.size() == 0 ? null : list.get(0); } catch (Exception e) { return null; } }
Expression eq(Filter filter) { return matchExp(filter.getProperty(), filter.getValue()); }
public void addEqual(String fieldName, Object value) { 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); conditions.add(ExpressionFactory.matchExp(path, rawValue)); }
if (filter.getCaseSensitive()) { if (filter.getExactMatch()) { newExpression = ExpressionFactory.matchExp(key, val); } else if (filter.getAnyMatch()) { newExpression = ExpressionFactory.likeExp(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); newExpression = ExpressionFactory.matchExp(key, dateVal); } else if (t == Filter.NOT_EQUAL) { newExpression = ExpressionFactory.noMatchExp(key, dateVal);