/** * Returns all nodes matching the path. The path can contain * * * @param p The path * * Returns a cursor iterating through all nodes of arrays, if any */ public KeyValueCursor<Path, JsonNode> getAllNodes(Path p) { return getAllNodes(p, false); }
/** * Returns all nodes matching the path. The path can contain * * * @param p The path * * Returns a cursor iterating through all nodes of arrays, if any */ public KeyValueCursor<Path, JsonNode> getAllNodes(Path p) { return getAllNodes(p, false); }
/** * Returns a list of fields in the doc inaccessible to the current user * during update. * * @param newDoc The new version of the document * @param oldDoc The old version of the document */ public List<Path> getInaccessibleFields_Update(JsonDoc newDoc, JsonDoc oldDoc) { Set<Path> inaccessibleFields = getInaccessibleFields(Operation.update); List<Path> ret = new ArrayList<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { KeyValueCursor<Path, JsonNode> oldCursor = oldDoc.getAllNodes(x); KeyValueCursor<Path, JsonNode> newCursor = newDoc.getAllNodes(x); if (different(oldCursor, newCursor)) { ret.add(x); } } return ret; }
/** * Returns a list of fields in the doc inaccessible to the current user * during insertion. If the returned list is empty, the user can insert the * doc. */ public Set<Path> getInaccessibleFields_Insert(JsonDoc doc) { Set<Path> inaccessibleFields = getInaccessibleFields(Operation.insert); Set<Path> ret = new HashSet<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(x); if (cursor.hasNext()) { ret.add(x); } } return ret; }
/** * Returns a list of fields in the doc inaccessible to the current user * during insertion. If the returned list is empty, the user can insert the * doc. */ public List<Path> getInaccessibleFields_Insert(JsonDoc doc) { Set<Path> inaccessibleFields = getInaccessibleFields(Operation.insert); List<Path> ret = new ArrayList<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(x); if (cursor.hasNext()) { ret.add(x); } } return ret; }
/** * Returns a list of fields in the doc inaccessible to the current user * during insertion. If the returned list is empty, the user can insert the * doc. */ public Set<Path> getInaccessibleFields_Insert(JsonDoc doc) { Set<Path> inaccessibleFields = getInaccessibleFields(Operation.insert); Set<Path> ret = new HashSet<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(x); if (cursor.hasNext()) { ret.add(x); } } return ret; }
public KeyValueCursor<Path, JsonNode> getNodes(Path relativePath) { return new JsonDoc(contextRoot).getAllNodes(new Path(relativePath)); }
public KeyValueCursor<Path, JsonNode> getNodes(Path relativePath) { return new JsonDoc(root).getAllNodes(contextPath.isEmpty() ? relativePath : new Path(contextPath, relativePath)); }
public KeyValueCursor<Path, JsonNode> getNodes(Path relativePath) { return new JsonDoc(root).getAllNodes(contextPath.isEmpty() ? relativePath : new Path(contextPath, relativePath)); }
public KeyValueCursor<Path, JsonNode> getNodes(Path relativePath, boolean returnMissingNodes) { return new JsonDoc(root).getAllNodes(contextPath.isEmpty() ? relativePath : new Path(contextPath, relativePath), returnMissingNodes); }
@Override public Set<Key> extract(JsonDoc doc,Set<Key> set) { if(set==null) set=new HashSet<>(); KeyValueCursor<Path,JsonNode> cursor=doc.getAllNodes(fullName); boolean hasData=false; while(cursor.hasNext()) { cursor.next(); set.add(new SimpleKey(type.fromJson(cursor.getCurrentValue()))); hasData=true; } if(!hasData) { // No value in doc: insert null set.add(SimpleKey.NULL_KEY); } return set; } }
public KeyValueCursor<Path, JsonNode> getNodes(Path relativePath, boolean returnMissingNodes) { return new JsonDoc(root).getAllNodes(contextPath.isEmpty() ? relativePath : new Path(contextPath, relativePath), returnMissingNodes); }
@Override public Set<Key> extract(JsonDoc doc,Set<Key> set) { if(set==null) set=new HashSet<>(); KeyValueCursor<Path,JsonNode> cursor=doc.getAllNodes(fullName); boolean hasData=false; while(cursor.hasNext()) { cursor.next(); set.add(new SimpleKey(type.fromJson(cursor.getCurrentValue()))); hasData=true; } if(!hasData) { // No value in doc: insert null set.add(SimpleKey.NULL_KEY); } return set; } }
/** * Initializes the document specific slots */ private void initializeSlots() { // Need to create a new slot for each array element for (ChildSlot blockSlot : block.getChildSlots()) { List<ChildSlot> childSlots = slots.get(blockSlot.getReference()); if (childSlots == null) { slots.put(blockSlot.getReference(), childSlots = new ArrayList<>()); } if (blockSlot.hasAnys()) { // Slot under array. Add one slot for each array element KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(blockSlot.getLocalContainerName()); while (cursor.hasNext()) { cursor.next(); ChildSlot newSlot = new ChildSlot(cursor.getCurrentKey(), blockSlot.getReference()); childSlots.add(newSlot); } } else { childSlots.add(blockSlot); } } }
/** * Initializes the document specific slots */ private void initializeSlots() { // Need to create a new slot for each array element for (ChildSlot blockSlot : block.getChildSlots()) { List<ChildSlot> childSlots = slots.get(blockSlot.getReference()); if (childSlots == null) { slots.put(blockSlot.getReference(), childSlots = new ArrayList<>()); } if (blockSlot.hasAnys()) { // Slot under array. Add one slot for each array element KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(blockSlot.getLocalContainerName()); while (cursor.hasNext()) { cursor.next(); ChildSlot newSlot = new ChildSlot(cursor.getCurrentKey(), blockSlot.getReference()); childSlots.add(newSlot); } } else { childSlots.add(blockSlot); } } }
/** * 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); }
@Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; if (numAny > 0) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(memento.expr.getField()); boolean b = cursor.hasNext(); while (b) { cursor.next(); Path currentKey = cursor.getCurrentKey(); JsonNode currentValue = cursor.getCurrentValue(); UpdateInfo updateInfoInstance = generateProcessedInfo(memento.context, memento.expr, currentKey, this.updateInfo.updater); if (update(doc, contextPath, updateInfoInstance)) { ret = true; } b = cursor.hasNext(); } return ret; } else { ret = update(doc, contextPath, this.updateInfo); return ret; } }
@Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; if (numAny > 0) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(memento.expr.getField()); boolean b = cursor.hasNext(); while (b) { cursor.next(); Path currentKey = cursor.getCurrentKey(); JsonNode currentValue = cursor.getCurrentValue(); UpdateInfo updateInfoInstance = generateProcessedInfo(memento.context, memento.expr, currentKey, this.updateInfo.updater); if (update(doc, contextPath, updateInfoInstance)) { ret = true; } b = cursor.hasNext(); } return ret; } else { ret = update(doc, contextPath, this.updateInfo); return ret; } }
boolean descending = sortFields[i].isDescending(); JsonDoc jd = new JsonDoc(node); KeyValueCursor<Path, JsonNode> cursor = jd.getAllNodes(sortFields[i].getName()); Object selected = null;