@Test public void one_$parent_array_foreach_removeall() throws Exception { UpdateExpression expr = EvalTestContext.updateExpressionFromJson("{ '$foreach' : { 'field6.$parent.field7' : '$all', '$update' : '$remove' } }"); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); Assert.assertEquals(0, jsonDoc.get(new Path("field7")).size()); Assert.assertEquals(0, jsonDoc.get(new Path("field7#")).asInt()); }
@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; } }
ForEachExpressionEvaluator extends Updater { @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; } } }
ForEachExpressionEvaluator extends Updater { @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; } } ForEachExpressionEvaluator(JsonNodeFactory factory, FieldTreeNode context, ForEachExpression expr); }
ForEachExpressionEvaluator extends Updater { @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; } } ForEachExpressionEvaluator(JsonNodeFactory factory, FieldTreeNode context, ForEachExpression expr); @Override void getUpdateFields(Set<Path> fields); @Override boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath); }
ForEachExpressionEvaluator extends Updater { @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; } } ForEachExpressionEvaluator(JsonNodeFactory factory, FieldTreeNode context, ForEachExpression expr); @Override void getUpdateFields(Set<Path> fields); @Override boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath);  }