@Override protected ItrState itrArrayMatchExpression(ArrayMatchExpression q, Path context) { return iterate(q.getElemMatch(),context); }
@Override protected ItrState itrArrayMatchExpression(ArrayMatchExpression q, Path context) { return iterate(q.getElemMatch(),context); }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { // No need to rewrite elemMatch using relative context, because that is already interpreted relative to the array return new ArrayMatchExpression(toRelative(q.getArray(), context), q.getElemMatch()); }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { // No need to rewrite elemMatch using relative context, because that is already interpreted relative to the array return new ArrayMatchExpression(toRelative(q.getArray(), context), q.getElemMatch()); }
private DBObject translateArrayElemMatch(FieldTreeNode context, ArrayMatchExpression expr) { FieldTreeNode arrayNode = resolve(context, expr.getArray()); if (arrayNode instanceof ArrayField) { ArrayElement el = ((ArrayField) arrayNode).getElement(); if (el instanceof ObjectArrayElement) { return new BasicDBObject(translatePath(expr.getArray()), new BasicDBObject("$elemMatch", translate(el, expr.getElemMatch()))); } } throw Error.get(ERR_INVALID_FIELD, expr.toString()); }
/** * Default behavior is to recursively iterate the nested query. If nested * processing returns an object different from the original nested query, * this method creates a new array match expression using the new query * expression, and returns that. */ protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { QueryExpression newq = iterate(q.getElemMatch(), new Path(new Path(context, q.getArray()), Path.ANYPATH)); if (newq != q.getElemMatch()) { return new ArrayMatchExpression(q.getArray(), newq); } else { return q; } } }
/** * Default behavior is to recursively iterate the nested query. If nested * processing returns an object different from the original nested query, * this method creates a new array match expression using the new query * expression, and returns that. */ protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { QueryExpression newq = iterate(q.getElemMatch(), new Path(new Path(context, q.getArray()), Path.ANYPATH)); if (newq != q.getElemMatch()) { return new ArrayMatchExpression(q.getArray(), newq); } else { return q; } } }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { Path p = rewrite(context, q.getArray()); if (!p.equals(q.getArray())) { return new ArrayMatchExpression(p, q.getElemMatch()); } else { return q; } }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { Path p = rewrite(context, q.getArray()); if (!p.equals(q.getArray())) { return new ArrayMatchExpression(p, q.getElemMatch()); } else { return q; } }
private static boolean isFieldQueried(Path field, ArrayMatchExpression q, Path context) { LOGGER.debug("Checking if field {} is queried by array expression {}", field, q); if (isFieldQueried(field, q.getArray(), context)) { return true; } else { return q.getElemMatch().isRequired(field, new Path(new Path(context, q.getArray()), Path.ANYPATH)); } } }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { Path p = rewrite(context, q.getArray()); if (!p.equals(q.getArray())) { return new ArrayMatchExpression(p, q.getElemMatch()); } else { return q; } }
private static boolean isFieldQueried(Path field, ArrayMatchExpression q, Path context) { LOGGER.debug("Checking if field {} is queried by array expression {}", field, q); if (isFieldQueried(field, q.getArray(), context)) { return true; } else { return q.getElemMatch().isRequired(field, new Path(new Path(context, q.getArray()), Path.ANYPATH)); } } }
@Override protected T itrArrayMatchExpression(ArrayMatchExpression q, Path context) { QueryFieldInfo oldArray=enclosingArray; enclosingArray=findFieldInfo(q.getArray(),q); T ret=processArrayMatchExpression(q.getElemMatch(), new Path(new Path(context, q.getArray()), Path.ANYPATH)); enclosingArray=oldArray; return ret; } }
public ArrayMatchEvaluator(ArrayMatchExpression expr, FieldTreeNode context) { // field needs to be resolved relative to the current context field = expr.getArray(); FieldTreeNode node = context.resolve(field); if (node == null) { throw new EvaluationError(expr); } if (node instanceof ArrayField) { elem = ((ArrayField) node).getElement(); ev = QueryEvaluator.getInstance(expr.getElemMatch(), elem); } else { throw new EvaluationError(expr, CrudConstants.ERR_EXPECTED_ARRAY + field); } }
public ArrayMatchEvaluator(ArrayMatchExpression expr, FieldTreeNode context) { // field needs to be resolved relative to the current context field = expr.getArray(); FieldTreeNode node = context.resolve(field); if (node == null) { throw new EvaluationError(expr); } if (node instanceof ArrayField) { elem = ((ArrayField) node).getElement(); ev = QueryEvaluator.getInstance(expr.getElemMatch(), elem); } else { throw new EvaluationError(expr, CrudConstants.ERR_EXPECTED_ARRAY + field); } }
private DBObject translateArrayElemMatch(FieldTreeNode context, EntityMetadata md, ArrayMatchExpression expr, EntityMetadata emd, MutablePath fullPath) { FieldInfo finfo=resolveFieldForQuery(context,fullPath.immutableCopy(),expr.getArray()); if (finfo.fieldMd instanceof ArrayField) { ArrayElement el = ((ArrayField) finfo.fieldMd).getElement(); if (el instanceof ObjectArrayElement) { fullPath.push(finfo.field).push(Path.ANYPATH); BasicDBObject obj = new BasicDBObject(translatePath(finfo.field), new BasicDBObject("$elemMatch", translate(el, expr.getElemMatch(), emd, fullPath))); fullPath.pop().pop(); return obj; } else { throw new NeedsJS(); } } throw Error.get(ERR_INVALID_FIELD, expr.toString()); }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { ArrayMatchExpression x = (ArrayMatchExpression) super.itrArrayMatchExpression(q, context); Path p = map(applyContext(context, x.getArray())); if (p != null) { return new ArrayMatchExpression(removeContext(context, p, x.getArray()), x.getElemMatch()); } else { return x; } }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { ArrayMatchExpression x = (ArrayMatchExpression) super.itrArrayMatchExpression(q, context); Path p = map(applyContext(context, x.getArray())); if (p != null) { return new ArrayMatchExpression(removeContext(context, p, x.getArray()), x.getElemMatch()); } else { return x; } }
@Override protected T itrArrayMatchExpression(ArrayMatchExpression q, Path context) { QueryFieldInfo oldArray=enclosingArray; enclosingArray=findFieldInfo(q.getArray(),q); T ret=processArrayMatchExpression(q.getElemMatch(), new Path(new Path(context, q.getArray()), Path.ANYPATH)); enclosingArray=oldArray; return ret; } }
@Override public QueryExpression rewrite(QueryExpression q) { ArrayMatchExpression ae = dyncast(ArrayMatchExpression.class, q); QueryExpression newq = q; if (ae != null) { QueryExpression nestedq = ae.getElemMatch(); ValueComparisonExpression vce; FieldComparisonExpression fce; NaryValueRelationalExpression nvre; NaryFieldRelationalExpression nfre; if ((vce = dyncast(ValueComparisonExpression.class, nestedq)) != null) { newq = new ValueComparisonExpression(normalize(ae, vce.getField()), vce.getOp(), vce.getRvalue()); } else if ((fce = dyncast(FieldComparisonExpression.class, nestedq)) != null) { newq = new FieldComparisonExpression(normalize(ae, fce.getField()), fce.getOp(), normalize(ae, fce.getRfield())); } } return newq; }