private JsonNode projectObjectField(JsonNode fieldNode, ObjectNode ret, Path fieldPath, JsonNodeCursor cursor, Projector projector, FieldTreeNode mdContext, Path contextPath, JsonNodeFactory factory, QueryEvaluationContext ctx) { if (fieldNode instanceof ObjectNode) { LOGGER.debug("projecting object node {}",fieldPath); if (cursor.firstChild()) { ObjectNode newNode = projectObject(projector, factory, mdContext, contextPath, cursor, ctx); ret.set(fieldPath.tail(0), newNode); cursor.parent(); } else { ret.set(fieldPath.tail(0), factory.objectNode()); } } else { LOGGER.warn("Expecting object node, found {} for {}", fieldNode.getClass().getName(), fieldPath); } return null; }
cursor.parent(); return ret; } else {
/** * @param cursor The cursor, pointing to the first element of the array */ @SuppressWarnings({"rawtypes", "unchecked"}) private List arrayToBson(JsonNodeCursor cursor, ArrayElement el, EntityMetadata md,ResultMetadata rmd) { List l = new ArrayList(); if (el instanceof SimpleArrayElement) { Type t = el.getType(); do { Object value = toValue(t, cursor.getCurrentNode()); l.add(value); } while (cursor.nextSibling()); } else { do { JsonNode node = cursor.getCurrentNode(); if (node == null || node instanceof NullNode) { l.add(null); } else if (cursor.firstChild()) { l.add(objectToBson(cursor, md,rmd)); cursor.parent(); } else { l.add(null); } } while (cursor.nextSibling()); } return l; }
/** * @param cursor The cursor, pointing to the first element of the array */ @SuppressWarnings({"rawtypes", "unchecked"}) private List arrayToBson(JsonNodeCursor cursor, ArrayElement el, EntityMetadata md) { List l = new ArrayList(); if (el instanceof SimpleArrayElement) { Type t = el.getType(); do { Object value = toValue(t, cursor.getCurrentNode()); l.add(value); } while (cursor.nextSibling()); } else { do { JsonNode node = cursor.getCurrentNode(); if (node == null || node instanceof NullNode) { l.add(null); } else { if (cursor.firstChild()) { l.add(objectToBson(cursor, md)); cursor.parent(); } else { l.add(null); } } } while (cursor.nextSibling()); } return l; }
cursor.parent(); if(deciding instanceof ArrayProjector&& ((ArrayProjector)deciding).getSort()!=null) {
protected void translate(ObjectField field, JsonNodeCursor cursor, Object target) { if(!cursor.firstChild()){ throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, cursor.getCurrentPath().toString()); } do { translate(cursor, target); } while (cursor.nextSibling()); cursor.parent(); }
protected void translate(ObjectField field, JsonNodeCursor cursor, Object target) { if(!cursor.firstChild()){ throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, cursor.getCurrentPath().toString()); } do { translate(cursor, target); } while (cursor.nextSibling()); cursor.parent(); }
private void translate(ArrayField field, JsonNodeCursor cursor, Object target) { if(!cursor.firstChild()){ throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, cursor.getCurrentPath().toString()); } ArrayElement arrayElement = field.getElement(); if (arrayElement instanceof SimpleArrayElement) { List<Object> items = new ArrayList<>(); do { items.add(fromJson(arrayElement.getType(), cursor.getCurrentNode())); } while (cursor.nextSibling()); translate(field, items, target); } else if(arrayElement instanceof ObjectArrayElement){ List<Object> items = new ArrayList<>(); do { Object item = createInstanceFor(arrayElement.getFullPath()); translate((ObjectArrayElement) arrayElement, cursor.getCurrentNode(), item); items.add(item); } while (cursor.nextSibling()); translate(field, items, target); } else{ throw Error.get(MetadataConstants.ERR_UNSUPPORTED_FEATURE + arrayElement.getClass().getName(), field.getFullPath().toString()); } cursor.parent(); }
private void translate(ArrayField field, JsonNodeCursor cursor, Object target) { if(!cursor.firstChild()){ throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, cursor.getCurrentPath().toString()); } ArrayElement arrayElement = field.getElement(); if (arrayElement instanceof SimpleArrayElement) { List<Object> items = new ArrayList<>(); do { items.add(fromJson(arrayElement.getType(), cursor.getCurrentNode())); } while (cursor.nextSibling()); translate(field, items, target); } else if(arrayElement instanceof ObjectArrayElement){ List<Object> items = new ArrayList<>(); do { Object item = createInstanceFor(arrayElement.getFullPath()); translate((ObjectArrayElement) arrayElement, cursor.getCurrentNode(), item); items.add(item); } while (cursor.nextSibling()); translate(field, items, target); } else{ throw Error.get(MetadataConstants.ERR_UNSUPPORTED_FEATURE + arrayElement.getClass().getName(), field.getFullPath().toString()); } cursor.parent(); }
newNode = (getNestedProjector() == null ? this : getNestedProjector()). project(factory, contextPath, cursor, ctx, fieldNode instanceof ArrayNode); cursor.parent(); } else { newNode = null; newNode = (getNestedProjector() == null ? this : getNestedProjector()). project(factory, contextPath, cursor, ctx, false); cursor.parent(); LOGGER.debug("Child object:{}", newNode); newNode = (getNestedProjector() == null ? this : getNestedProjector()). project(factory, contextPath, cursor, ctx, true); cursor.parent(); LOGGER.debug("Child object:{}", newNode); } else {
newNode = (getNestedProjector() == null ? this : getNestedProjector()). project(factory, contextPath, cursor, ctx, fieldNode instanceof ArrayNode); cursor.parent(); } else { newNode = null; newNode = (getNestedProjector() == null ? this : getNestedProjector()). project(factory, contextPath, cursor, ctx, false); cursor.parent(); LOGGER.debug("Child object:{}", newNode); newNode = (getNestedProjector() == null ? this : getNestedProjector()). project(factory, contextPath, cursor, ctx, true); cursor.parent(); LOGGER.debug("Child object:{}", newNode); } else {
private void convertObjectFieldToBson(JsonNode node, JsonNodeCursor cursor, BasicDBObject ret, Path path, EntityMetadata md,ResultMetadata rmd) { if (node != null) { if (node instanceof ObjectNode) { if (cursor.firstChild()) { ret.append(path.tail(0), objectToBson(cursor, md,rmd)); cursor.parent(); } } else if (node instanceof NullNode) { ret.append(path.tail(0), null); } else { throw Error.get(ERR_INVALID_FIELD, path.toString()); } } }
private void convertArrayFieldToBson(JsonNode node, JsonNodeCursor cursor, BasicDBObject ret, FieldTreeNode fieldMdNode, Path path, EntityMetadata md,ResultMetadata rmd) { if (node != null) { if (node instanceof ArrayNode) { if (cursor.firstChild()) { ret.append(path.tail(0), arrayToBson(cursor, ((ArrayField) fieldMdNode).getElement(), md,rmd)); cursor.parent(); } else { // empty array! add an empty list. ret.append(path.tail(0), new ArrayList()); } } else if (node instanceof NullNode) { ret.append(path.tail(0), null); } else { throw Error.get(ERR_INVALID_FIELD, path.toString()); } } }
private void convertObjectFieldToBson(JsonNode node, JsonNodeCursor cursor, BasicDBObject ret, Path path, EntityMetadata md) { if (node != null) { if (node instanceof ObjectNode) { if (cursor.firstChild()) { ret.append(path.tail(0), objectToBson(cursor, md)); cursor.parent(); } } else if(node instanceof NullNode) { ret.append(path.tail(0),null); } else { throw Error.get(ERR_INVALID_FIELD, path.toString()); } } }
private void convertArrayFieldToBson(JsonNode node, JsonNodeCursor cursor, BasicDBObject ret, FieldTreeNode fieldMdNode, Path path, EntityMetadata md) { if (node != null) { if (node instanceof ArrayNode) { if (cursor.firstChild()) { ret.append(path.tail(0), arrayToBson(cursor, ((ArrayField) fieldMdNode).getElement(), md)); cursor.parent(); } else { // empty array! add an empty list. ret.append(path.tail(0), new ArrayList()); } } else if(node instanceof NullNode) { ret.append(path.tail(0),null); } else { throw Error.get(ERR_INVALID_FIELD, path.toString()); } } }