/** * Builds a (potentially nested) projection based on the given projection, * and the location in the metadata field tree. */ public static Projector getInstance(Projection projection, Path ctxPath, FieldTreeNode ctx) { if (projection instanceof FieldProjection) { return new FieldProjector((FieldProjection) projection, ctxPath, ctx); } else if (projection instanceof ProjectionList) { return new ListProjector((ProjectionList) projection, ctxPath, ctx); } else if (projection instanceof ArrayRangeProjection) { return new ArrayRangeProjector((ArrayRangeProjection) projection, ctxPath, ctx); } else { return new ArrayQueryProjector((ArrayQueryMatchProjection) projection, ctxPath, ctx); } }
@Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; for (Updater x : updaters) { if (x.update(doc, contextMd, contextPath)) { ret = true; } } return ret; } }
@Override public boolean evaluate(QueryEvaluationContext ctx) { ctx.setResult(true); return true; } }
@Override protected Boolean projectArray(Path p, QueryEvaluationContext ctx) { Path contextRoot = ctx.getPath(); QueryEvaluationContext nestedContext = ctx.getNestedContext(contextRoot.isEmpty() ? p : p.suffix(-contextRoot.numSegments())); if (query.evaluate(nestedContext)) { setLastMatch(true); return isIncluded() ? Boolean.TRUE : Boolean.FALSE; } return null; } }
private JsonDoc project(JsonDoc doc, Projector p) { if (doc == null) { return null; } else { return p.project(doc, factory); } } }
private static ArrayNode sort(JsonNodeFactory factory, Projector projector, ArrayNode node, Path nodePath) { ArrayProjector p = findArrayProjectorForField(projector, nodePath); if (p != null && p.getSort() != null) { LOGGER.debug("Sorting array elements using {}", p.getSort()); return p.sortArray(node, factory); } return node; }
public QueryEvaluationContext evaluate(JsonDoc doc) { QueryEvaluationContext ctx = new QueryEvaluationContext(doc.getRoot()); evaluate(ctx); return ctx; }
private static SortFieldInfo getSortField(Path field, FieldTreeNode context, boolean descending) { FieldTreeNode fieldMd = context.resolve(field); if (!(fieldMd instanceof SimpleField)) { throw new EvaluationError(CrudConstants.ERR_EXPECTED_VALUE + ":" + field); } return new SortFieldInfo((SimpleField) fieldMd, field, descending); } }
/** * Returns whether the current caller has access to all the given fields * based on the operation */ public boolean hasAccess(Set<Path> fields, Operation op) { for (Path x : fields) { if (!hasAccess(x, op)) { return false; } } return true; }
@Override public void getUpdateFields(Set<Path> fields) { for (Updater x : updaters) { x.getUpdateFields(fields); } }
@Override public boolean equals(Object x) { try { return compareTo((SortableItem) x) == 0; } catch (Exception e) { return false; } }
@Override public boolean exactMatch() { for(Projector p:items) if(p.exactMatch()) return true; return false; }
/** * Builds a (potentially nested) projection based on the given projection, * and the location in the metadata field tree. */ public static Projector getInstance(Projection projection, Path ctxPath, FieldTreeNode ctx) { if (projection instanceof FieldProjection) { return new FieldProjector((FieldProjection) projection, ctxPath, ctx); } else if (projection instanceof ProjectionList) { return new ListProjector((ProjectionList) projection, ctxPath, ctx); } else if (projection instanceof ArrayRangeProjection) { return new ArrayRangeProjector((ArrayRangeProjection) projection, ctxPath, ctx); } else { return new ArrayQueryProjector((ArrayQueryMatchProjection) projection, ctxPath, ctx); } }
@Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; for (Updater x : updaters) { if (x.update(doc, contextMd, contextPath)) { ret = true; } } return ret; } }
/** * Returns whether the current caller has access to all the given fields * based on the operation */ public boolean hasAccess(Set<Path> fields, Operation op) { for (Path x : fields) { if (!hasAccess(x, op)) { return false; } } return true; }
public boolean evaluate(QueryEvaluationContext ctx) { ctx.setResult(true); return true; } };
@Override public void getUpdateFields(Set<Path> fields) { for (Updater x : updaters) { x.getUpdateFields(fields); } }
@Override public boolean equals(Object x) { try { return compareTo((SortableItem) x) == 0; } catch (Exception e) { return false; } }
/** * Builds a (potentially nested) projection based on the given projection, * and the location in the metadata field tree. */ public static Projector getInstance(Projection projection, Path ctxPath, FieldTreeNode ctx) { if (projection instanceof FieldProjection) { return new FieldProjector((FieldProjection) projection, ctxPath, ctx); } else if (projection instanceof ProjectionList) { return new ListProjector((ProjectionList) projection, ctxPath, ctx); } else if (projection instanceof ArrayRangeProjection) { return new ArrayRangeProjector((ArrayRangeProjection) projection, ctxPath, ctx); } else { return new ArrayQueryProjector((ArrayQueryMatchProjection) projection, ctxPath, ctx); } }
/** * Returns whether the current caller has access to all the given fields * based on the operation */ public boolean hasAccess(Set<Path> fields, Operation op) { for (Path x : fields) { if (!hasAccess(x, op)) { return false; } } return true; }