public QueryEvaluationContext(JsonNode root, JsonNode contextRoot, Path p) { this.root = root; this.contextRoot = contextRoot; this.contextPath = p.mutableCopy(); }
@Override public MutablePath getFullPath(MutablePath mp) { return Path.EMPTY.mutableCopy(); } };
@Override public MutablePath getFullPath(MutablePath mp) { return Path.EMPTY.mutableCopy(); } };
@Override public MutablePath getFullPath(MutablePath mp) { return Path.EMPTY.mutableCopy(); } };
public QueryEvaluationContext(JsonNode root, JsonNode contextRoot, Path p) { this.root = root; this.contextRoot = contextRoot; this.contextPath = p.mutableCopy(); }
public QueryEvaluationContext(JsonNode root, Path p) { this.contextRoot = root; this.contextPath = p.mutableCopy(); }
/** * Get a reference to the hidden path's actual field. * * This does not guarantee the sub-path exists. * * @param path * @return */ public static Path getFieldForHidden(Path hiddenPath) { return hiddenPath.prefix(-2).mutableCopy().push(hiddenPath.getLast()); }
/** * Get a reference to the path's hidden sub-field. * * This does not guarantee the sub-path exists. * * @param path * @return */ public static Path getHiddenForField(Path path) { if (path.getLast().equals(Path.ANY)) { return path.prefix(-2).mutableCopy().push(HIDDEN_SUB_PATH).push(path.suffix(2)); } return path.prefix(-1).mutableCopy().push(HIDDEN_SUB_PATH).push(path.getLast()); }
/** * If a path includes array indexes, change the indexes into ANY */ private static Path toMask(Path p) { int n = p.numSegments(); MutablePath mp = null; for (int i = 0; i < n; i++) { if (p.isIndex(i)) { if (mp == null) { mp = p.mutableCopy(); } mp.set(i, Path.ANY); } } return mp == null ? p : mp.immutableCopy(); }
/** * If a path includes array indexes, change the indexes into ANY */ private static Path toMask(Path p) { int n = p.numSegments(); MutablePath mp = null; for (int i = 0; i < n; i++) { if (p.isIndex(i)) { if (mp == null) { mp = p.mutableCopy(); } mp.set(i, Path.ANY); } } return mp == null ? p : mp.immutableCopy(); }
/** * Returns a query binder for a slot. The slot cannot have '*' in it (i.e. * there must be only one location for the slot in the document). */ public BindQuery getBindersForSlot(ChildSlot slot, AssociationQuery childAq) { List<Binder> binders = new ArrayList<>(); for (BoundObject bo : childAq.getFieldBindings()) { // Interpret field based on this slot Path field = bo.getFieldInfo().getEntityRelativeFieldNameWithContext(); Path fieldAtSlot = field.mutableCopy().rewriteIndexes(slot.getLocalContainerName()).immutableCopy(); if (fieldAtSlot.nAnys() > 0) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(fieldAtSlot); List<Value> value=new ArrayList<Value>(); while (cursor.hasNext()) { cursor.next(); ((List)value).add(getValue(bo.getFieldInfo().getFieldMd(),cursor.getCurrentValue())); } binders.add(new Binder(bo,value)); } else { binders.add(new Binder(bo,getValue(bo.getFieldInfo().getFieldMd(),doc.get(fieldAtSlot)))); } } return new BindQuery(binders); }
/** * Returns a query binder for a slot. The slot cannot have '*' in it (i.e. * there must be only one location for the slot in the document). */ public BindQuery getBindersForSlot(ChildSlot slot, AssociationQuery childAq) { List<Binder> binders = new ArrayList<>(); for (BoundObject bo : childAq.getFieldBindings()) { // Interpret field based on this slot Path field = bo.getFieldInfo().getEntityRelativeFieldNameWithContext(); Path fieldAtSlot = field.mutableCopy().rewriteIndexes(slot.getLocalContainerName()).immutableCopy(); if (fieldAtSlot.nAnys() > 0) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(fieldAtSlot); List<Value> value=new ArrayList<Value>(); while (cursor.hasNext()) { cursor.next(); ((List)value).add(getValue(bo.getFieldInfo().getFieldMd(),cursor.getCurrentValue())); } binders.add(new Binder(bo,value)); } else { binders.add(new Binder(bo,getValue(bo.getFieldInfo().getFieldMd(),doc.get(fieldAtSlot)))); } } return new BindQuery(binders); }