Search in sources :

Example 16 with Filters

use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.

the class NodeQueryStatementsTest method testFindByNestedPropertyUndirected.

// DATAGRAPH-629
@Test
public void testFindByNestedPropertyUndirected() {
    Filter planetParam = new Filter("name", ComparisonOperator.EQUALS, "Earth");
    planetParam.setNestedPropertyName("collidesWith");
    planetParam.setNestedEntityTypeLabel("Planet");
    planetParam.setRelationshipType("COLLIDES");
    planetParam.setRelationshipDirection(Relationship.Direction.UNDIRECTED);
    assertThat(queryStatements.findByType("Asteroid", new Filters().add(planetParam), 1).getStatement()).isEqualTo("MATCH (n:`Asteroid`) MATCH (m0:`Planet`) WHERE m0.`name` = $`collidesWith_name_0` MATCH (n)-[:`COLLIDES`]-(m0) WITH DISTINCT n MATCH p=(n)-[*0..1]-(m) RETURN p, ID(n)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 17 with Filters

use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.

the class NodeQueryStatementsTest method testFindByMultipleNestedPropertiesOredDepth0.

// DATAGRAPH-662
@Test(expected = UnsupportedOperationException.class)
public void testFindByMultipleNestedPropertiesOredDepth0() {
    Filter diameterParam = new Filter("diameter", ComparisonOperator.GREATER_THAN, 60);
    Filter planetParam = new Filter("name", ComparisonOperator.EQUALS, "Earth");
    planetParam.setBooleanOperator(BooleanOperator.OR);
    planetParam.setNestedPropertyName("collidesWith");
    planetParam.setNestedEntityTypeLabel("Planet");
    planetParam.setRelationshipType("COLLIDES");
    planetParam.setRelationshipDirection(Relationship.Direction.OUTGOING);
    String statement = queryStatements.findByType("Asteroid", new Filters().add(diameterParam).add(planetParam), 0).getStatement();
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 18 with Filters

use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.

the class NodeQueryStatementsTest method testFindByDistance.

@Test
public void testFindByDistance() {
    DistanceComparison function = new DistanceComparison(new DistanceFromPoint(37.4d, 112.9d, 1000.0d));
    Filters filters = new Filters().add(new Filter(function, ComparisonOperator.EQUALS));
    String statement = queryStatements.findByType("Restaurant", filters, 4).getStatement();
    assertThat(statement).isEqualTo("MATCH (n:`Restaurant`) WHERE distance(point({latitude: n.latitude, longitude: n.longitude}),point({latitude: $lat, longitude: $lon})) = $distance WITH n MATCH p=(n)-[*0..4]-(m) RETURN p, ID(n)");
}
Also used : DistanceComparison(org.neo4j.ogm.cypher.function.DistanceComparison) DistanceFromPoint(org.neo4j.ogm.cypher.function.DistanceFromPoint) Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 19 with Filters

use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.

the class NodeQueryStatementsTest method testFindByChainedAndedProperties.

// DATAGRAPH-445
@Test
public void testFindByChainedAndedProperties() {
    Filter planetParam = collidesWithEarthFilter();
    Filter moonParam = orbitsMoonFilter();
    assertThat(queryStatements.findByType("Asteroid", new Filters().add(planetParam).and(moonParam), 1).getStatement()).isEqualTo("MATCH (n:`Asteroid`) MATCH (m0:`Planet`) WHERE m0.`name` = $`collidesWith_name_0` " + "MATCH (m1:`Moon`) WHERE m1.`name` = $`moon_name_1` MATCH (n)-[:`COLLIDES`]->(m0) " + "MATCH (n)<-[:`ORBITS`]-(m1) WITH DISTINCT n MATCH p=(n)-[*0..1]-(m) RETURN p, ID(n)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 20 with Filters

use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.

the class NodeQueryStatementsTest method testFindByNestedPropertySameEntityType.

// DATAGRAPH-904
@Test
public void testFindByNestedPropertySameEntityType() {
    Filter filter = new Filter("name", ComparisonOperator.EQUALS, "Vesta");
    filter.setNestedPropertyName("collidesWith");
    filter.setNestedEntityTypeLabel("Asteroid");
    filter.setRelationshipType("COLLIDES");
    filter.setRelationshipDirection(Relationship.Direction.OUTGOING);
    assertThat(queryStatements.findByType("Asteroid", new Filters().add(filter), 1).getStatement()).isEqualTo("MATCH (n:`Asteroid`) MATCH (m0:`Asteroid`) WHERE m0.`name` = $`collidesWith_name_0` MATCH (n)-[:`COLLIDES`]->(m0) WITH DISTINCT n MATCH p=(n)-[*0..1]-(m) RETURN p, ID(n)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Aggregations

Filters (org.neo4j.ogm.cypher.Filters)82 Filter (org.neo4j.ogm.cypher.Filter)78 Test (org.junit.Test)77 Restaurant (org.neo4j.ogm.domain.restaurant.Restaurant)10 Date (java.util.Date)6 CypherQuery (org.neo4j.ogm.cypher.query.CypherQuery)6 SortOrder (org.neo4j.ogm.cypher.query.SortOrder)4 Rating (org.neo4j.ogm.domain.cineasts.annotated.Rating)3 User (org.neo4j.ogm.domain.cineasts.annotated.User)3 Before (org.junit.Before)2 Pagination (org.neo4j.ogm.cypher.query.Pagination)2 Movie (org.neo4j.ogm.domain.cineasts.annotated.Movie)2 Pet (org.neo4j.ogm.domain.cineasts.annotated.Pet)2 Flight (org.neo4j.ogm.domain.gh851.Flight)2 Map (java.util.Map)1 UnaryOperator (java.util.function.UnaryOperator)1 PropertyValueTransformer (org.neo4j.ogm.cypher.PropertyValueTransformer)1 ContainsAnyComparison (org.neo4j.ogm.cypher.function.ContainsAnyComparison)1 DistanceComparison (org.neo4j.ogm.cypher.function.DistanceComparison)1 DistanceFromPoint (org.neo4j.ogm.cypher.function.DistanceFromPoint)1