public boolean isDeepNested() { return getNestedPath() != null && !getNestedPath().isEmpty(); }
private boolean isLastSegment(Filter filter, Filter.NestedPathSegment segment) { return filter.getNestedPath().indexOf(segment) == filter.getNestedPath().size() - 1; }
private void appendDeepNestedFilter(Filter filter) { if (filter.getBooleanOperator().equals(BooleanOperator.OR)) { throw new UnsupportedOperationException("OR is not supported for nested properties on an entity"); } Filter.NestedPathSegment lastPathSegment = filter.getNestedPath().get(filter.getNestedPath().size() - 1); MatchClause clause = new NestedPropertyPathMatchClause(matchClauseId, lastPathSegment.getNestedEntityTypeLabel(), lastPathSegment.isNestedRelationshipEntity()); pathClauses.add(new NestedPathMatchClause(matchClauseId).append(filter)); nestedClauses.add(clause); clause.append(filter); matchClauseId++; }
@Override public MatchClause append(Filter filter) { boolean wasPreviousSegmentRelationshipEntity = false; for (Filter.NestedPathSegment segment : filter.getNestedPath()) { boolean nestedRelationshipEntity = segment.isNestedRelationshipEntity(); if (!wasPreviousSegmentRelationshipEntity) { if (segment.getRelationshipDirection().equals(Relationship.INCOMING)) { clause.append("<"); } clause.append( String.format("-[%s:`%s`]-", nestedRelationshipEntity && isLastSegment(filter, segment) ? "r" + index : "", segment.getRelationshipType())); if (segment.getRelationshipDirection().equals(Relationship.OUTGOING)) { clause.append(">"); } } if (!nestedRelationshipEntity && !isLastSegment(filter, segment)) { clause.append(String.format("(:`%s`)", segment.getNestedEntityTypeLabel())); } wasPreviousSegmentRelationshipEntity = nestedRelationshipEntity; } clause.append(String.format("(%s) ", "m" + index)); return this; }
List<Filter.NestedPathSegment> nestedPath = filter.getNestedPath(); Filter.NestedPathSegment firstNestedPathSegment = nestedPath.get(0); Filter.NestedPathSegment lastNestedPathSegment = nestedPath.get(nestedPath.size() - 1);
for (Filter.NestedPathSegment nestedPathSegment : filter.getNestedPath()) { resolveRelationshipType(parentOwnerType, nestedPathSegment); ClassInfo nestedClassInfo = session.metaData().classInfo(nestedPathSegment.getPropertyType().getName());