private String cypherPrefix(boolean addWhereClause) { StringBuilder cypher = new StringBuilder(); if (addWhereClause) { cypher.append("WHERE "); } else { if (!getBooleanOperator().equals(BooleanOperator.NONE)) { cypher.append(getBooleanOperator().getValue()).append(" "); } } return cypher.toString(); }
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++; }
if (filter.getBooleanOperator().equals(BooleanOperator.OR)) { throw new UnsupportedOperationException( "OR is not supported for nested properties on a relationship entity"); if (filter.getBooleanOperator().equals(BooleanOperator.NONE)) { if (noneOperatorEncounteredInStartFilters) { throw new MissingOperatorException( if (filter.getBooleanOperator().equals(BooleanOperator.NONE)) { if (noneOperatorEncounteredInEndFilters) { throw new MissingOperatorException( if (filter.getBooleanOperator().equals(BooleanOperator.NONE)) { throw new MissingOperatorException( "BooleanOperator missing for filter with property name " + filter.getPropertyName());
private void appendNestedFilter(Filter filter) { if (filter.getBooleanOperator().equals(BooleanOperator.OR)) { throw new UnsupportedOperationException("OR is not supported for nested properties on an entity"); } if (filter.isNestedRelationshipEntity()) { MatchClause clause = relationshipPropertyClauseFor(filter.getRelationshipType()); if (clause == null) { clause = new RelationshipPropertyMatchClause(matchClauseId, filter.getRelationshipType()); nestedClauses.add(clause); } clause.append(filter); } else { MatchClause clause = relatedNodeClauseFor(filter.getNestedEntityTypeLabel()); if (clause == null) { clause = new RelatedNodePropertyMatchClause(filter.getNestedEntityTypeLabel(), matchClauseId); nestedClauses.add(clause); pathClauses.add(new PathMatchClause(matchClauseId).append(filter)); } clause.append(filter); } matchClauseId++; }
public FilteredQuery build() { if (!built) { int i = 0; for (Filter filter : filters) { if (i != 0 && filter.getBooleanOperator().equals(BooleanOperator.NONE)) { throw new MissingOperatorException("BooleanOperator missing for filter with property name " + filter.getPropertyName() + ". Only the first filter may not specify the BooleanOperator."); } if (filter.isNested()) { appendNestedFilter(filter); hasRelationshipMatch = true; } else if (filter.isDeepNested()) { appendDeepNestedFilter(filter); hasRelationshipMatch = true; } else { //If the filter is not nested, it belongs to the node we're returning principalClause().append(filter); } parameters.putAll(filter.parameters()); i++; } built = true; } return new FilteredQuery(toCypher(), parameters); }