use of org.neo4j.ogm.cypher.Filter in project neo4j-ogm by neo4j.
the class NodeQueryStatementsTest method testFindByMultipleAndPropertiesWithMissingBooleanOperator.
// GH-73
@Test(expected = MissingOperatorException.class)
public void testFindByMultipleAndPropertiesWithMissingBooleanOperator() {
Filter nameParam = new Filter("name", ComparisonOperator.EQUALS, "AST-1");
Filter diameterParam = new Filter("diameter", ComparisonOperator.LESS_THAN, 60);
queryStatements.findByType("Asteroid", new Filters().add(nameParam).add(diameterParam), 2).getStatement();
}
use of org.neo4j.ogm.cypher.Filter in project neo4j-ogm by neo4j.
the class NodeQueryStatementsTest method testFindByChainedOredProperties.
// DATAGRAPH-445
@Test
public void testFindByChainedOredProperties() {
Filter planetParam = new Filter("name", ComparisonOperator.EQUALS, "Earth");
Filter moonParam = new Filter("name", ComparisonOperator.EQUALS, "Moon");
assertThat(queryStatements.findByType("Asteroid", new Filters().add(planetParam).or(moonParam), 1).getStatement()).isEqualTo("MATCH (n:`Asteroid`) WHERE n.`name` = $`name_0` " + "OR n.`name` = $`name_1` WITH n MATCH p=(n)-[*0..1]-(m) RETURN p, ID(n)");
}
use of org.neo4j.ogm.cypher.Filter in project neo4j-ogm by neo4j.
the class NodeQueryBuilder method build.
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 (principalClause != null) {
// 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);
}
use of org.neo4j.ogm.cypher.Filter in project neo4j-ogm by neo4j.
the class BasicDriverTest method shouldLoadByProperty.
@Test
public void shouldLoadByProperty() {
User user = new User("Bilbo Baggins");
session.save(user);
session.clear();
User userByProperty = session.loadAll(User.class, new Filter("name", ComparisonOperator.EQUALS, "Bilbo Baggins")).iterator().next();
assertThat(userByProperty).isNotNull();
}
use of org.neo4j.ogm.cypher.Filter in project neo4j-ogm by neo4j.
the class CypherContextTest method shouldDeregisterRelationshipEntities.
// GH-576
@Test
public void shouldDeregisterRelationshipEntities() {
Collection<DataItem> dataItems;
FormulaItem formulaItem;
Filter filter = new Filter("nodeId", ComparisonOperator.EQUALS, "m1");
dataItems = session.loadAll(DataItem.class, filter);
assertThat(dataItems).hasSize(1);
formulaItem = (FormulaItem) dataItems.iterator().next();
assertThat(formulaItem.getVariables()).hasSize(3);
Predicate<Variable> isVariableAWithDataItemM2 = v -> v.getVariable().equals("A") && v.getDataItem().getNodeId().equals("m2");
formulaItem.getVariables().removeIf(isVariableAWithDataItemM2);
assertThat(formulaItem.getVariables()).hasSize(2);
session.save(formulaItem);
dataItems = session.loadAll(DataItem.class, filter);
assertThat(dataItems).hasSize(1);
formulaItem = (FormulaItem) dataItems.iterator().next();
assertThat(formulaItem.getVariables()).hasSize(2);
}
Aggregations