@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; }
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++; }
Filter.NestedPathSegment lastNestedPathSegment = nestedPath.get(nestedPath.size() - 1); startNestedEntityTypeLabel = firstNestedPathSegment.getNestedEntityTypeLabel(); endNestedEntityTypeLabel = lastNestedPathSegment.getNestedEntityTypeLabel(); relationshipDirection = firstNestedPathSegment.getRelationshipDirection();