@Test public void one_$parent_project_field_without_recursion() throws Exception { Projection p = EvalTestContext.projectionFromJson("[{'field':'field7.$parent.field2'},{'field':'field7.$parent.field6.*'}]"); Projector projector = Projector.getInstance(p, md); JsonNode expectedNode = JsonUtils.json("{'field2':'value2','field6':{'nf1':'nvalue1','nf2':'nvalue2','nf3':4,'nf4':false,'nf11':null}}".replace('\'', '\"')); JsonDoc pdoc = projector.project(jsonDoc, JSON_NODE_FACTORY); Assert.assertEquals(expectedNode.toString(), pdoc.toString()); }
@Override public Projection.Inclusion project(Path p, QueryEvaluationContext ctx) { if (p.matchingPrefix(field)) { if (include) { return Projection.Inclusion.explicit_inclusion; } else if (p.matches(field)) { return Projection.Inclusion.explicit_exclusion; } } else if (recursive && p.numSegments() > field.numSegments() && p.prefix(field.numSegments()).matches(field) ) { return include ? Projection.Inclusion.implicit_inclusion : Projection.Inclusion.implicit_exclusion; } return Projection.Inclusion.undecided; }
FieldProjector extends Projector { @Override public Projection.Inclusion project(Path p, QueryEvaluationContext ctx) { if (p.matchingPrefix(field)) { if (include) { return Projection.Inclusion.explicit_inclusion; } else if (p.matches(field)) { return Projection.Inclusion.explicit_exclusion; } } else if (recursive && p.numSegments() > field.numSegments() && p.prefix(field.numSegments()).matches(field) ) { return include ? Projection.Inclusion.implicit_inclusion : Projection.Inclusion.implicit_exclusion; } return Projection.Inclusion.undecided; } }
FieldProjector extends Projector { @Override public Projection.Inclusion project(Path p, QueryEvaluationContext ctx) { if (p.matchingPrefix(field)) { if (include) { return Projection.Inclusion.explicit_inclusion; } else if (p.matches(field)) { return Projection.Inclusion.explicit_exclusion; } } else if (recursive && p.numSegments() > field.numSegments() && p.prefix(field.numSegments()).matches(field) ) { return include ? Projection.Inclusion.implicit_inclusion : Projection.Inclusion.implicit_exclusion; } return Projection.Inclusion.undecided; } FieldProjector(FieldProjection p, Path ctxPath, FieldTreeNode ctx); }
FieldProjector extends Projector { @Override public Projection.Inclusion project(Path p, QueryEvaluationContext ctx) { if (p.matchingPrefix(field)) { if (include) { return Projection.Inclusion.explicit_inclusion; } else if (p.matches(field)) { return Projection.Inclusion.explicit_exclusion; } } else if (recursive && p.numSegments() > field.numSegments() && p.prefix(field.numSegments()).matches(field) ) { return include ? Projection.Inclusion.implicit_inclusion : Projection.Inclusion.implicit_exclusion; } return Projection.Inclusion.undecided; } FieldProjector(FieldProjection p, Path ctxPath, FieldTreeNode ctx); @Override Projector getNestedProjector(); @Override Projection.Inclusion project(Path p, QueryEvaluationContext ctx); }
FieldProjector extends Projector { @Override public Projection.Inclusion project(Path p, QueryEvaluationContext ctx) { if (p.matchingPrefix(field)) { if (include) { return Projection.Inclusion.explicit_inclusion; } else if (p.matches(field)) { return Projection.Inclusion.explicit_exclusion; } } else if (recursive && p.numSegments() > field.numSegments() && p.prefix(field.numSegments()).matches(field) ) { return include ? Projection.Inclusion.implicit_inclusion : Projection.Inclusion.implicit_exclusion; } return Projection.Inclusion.undecided; } FieldProjector(FieldProjection p, Path ctxPath, FieldTreeNode ctx); @Override Projector getNestedProjector(); @Override Projection.Inclusion project(Path p, QueryEvaluationContext ctx);  }