Search in sources :

Example 76 with Filters

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

the class RelationshipQueryStatementsTest method testFindByPropertiesAnded.

// DATAGRAPH-632
@Test
public void testFindByPropertiesAnded() {
    Filter distance = new Filter("distance", ComparisonOperator.EQUALS, 60.2);
    Filter time = new Filter("time", ComparisonOperator.EQUALS, 3600);
    time.setBooleanOperator(BooleanOperator.AND);
    assertThat(query.findByType("ORBITS", new Filters().add(distance, time), 4).getStatement()).isEqualTo("MATCH (n)-[r0:`ORBITS`]->(m) WHERE r0.`distance` = $`distance_0` AND r0.`time` = $`time_1`  " + "WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m MATCH p1 = (n)-[*0..4]-() " + "WITH r0, COLLECT(DISTINCT p1) AS startPaths, m MATCH p2 = (m)-[*0..4]-() " + "WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths  AS paths UNWIND paths AS p RETURN DISTINCT p, ID(r0)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 77 with Filters

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

the class RelationshipQueryStatementsTest method testFindByBaseAndNestedPropertyIncoming.

// DATAGRAPH-632
@Test
public void testFindByBaseAndNestedPropertyIncoming() {
    Filter planetFilter = new Filter("name", ComparisonOperator.EQUALS, "Earth");
    planetFilter.setNestedPropertyName("world");
    planetFilter.setNestedEntityTypeLabel("Planet");
    planetFilter.setRelationshipType("ORBITS");
    planetFilter.setRelationshipDirection(Relationship.Direction.INCOMING);
    Filter time = new Filter("time", ComparisonOperator.EQUALS, 3600);
    assertThat(query.findByType("ORBITS", new Filters().add(planetFilter, time), 4).getStatement()).isEqualTo("MATCH (m:`Planet`) WHERE m.`name` = $`world_name_0` " + "MATCH (n)<-[r0:`ORBITS`]-(m) WHERE r0.`time` = $`time_1`  " + "WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m MATCH p1 = (n)-[*0..4]-() " + "WITH r0, COLLECT(DISTINCT p1) AS startPaths, m MATCH p2 = (m)-[*0..4]-() " + "WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths  AS paths UNWIND paths AS p RETURN DISTINCT p, ID(r0)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 78 with Filters

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

the class RelationshipQueryStatementsTest method testFindByBaseAndMultipleNestedPropertiesOnBothEnds.

// DATAGRAPH-632
@Test
public void testFindByBaseAndMultipleNestedPropertiesOnBothEnds() {
    Filter moonFilter = new Filter("name", ComparisonOperator.EQUALS, "Earth");
    moonFilter.setNestedPropertyName("world");
    moonFilter.setNestedEntityTypeLabel("Moon");
    moonFilter.setRelationshipType("ORBITS");
    moonFilter.setRelationshipDirection(Relationship.Direction.OUTGOING);
    Filter planetFilter = new Filter("colour", ComparisonOperator.EQUALS, "Red");
    planetFilter.setNestedPropertyName("colour");
    planetFilter.setNestedEntityTypeLabel("Planet");
    planetFilter.setRelationshipType("ORBITS");
    planetFilter.setRelationshipDirection(Relationship.Direction.INCOMING);
    Filter time = new Filter("time", ComparisonOperator.EQUALS, 3600);
    time.setBooleanOperator(BooleanOperator.AND);
    assertThat(query.findByType("ORBITS", new Filters().add(moonFilter, planetFilter, time), 4).getStatement()).isEqualTo("MATCH (n:`Moon`) WHERE n.`name` = $`world_name_0` MATCH (m:`Planet`) WHERE m.`colour` = $`colour_colour_1` " + "MATCH (n)-[r0:`ORBITS`]->(m) WHERE r0.`time` = $`time_2`  " + "WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m MATCH p1 = (n)-[*0..4]-() " + "WITH r0, COLLECT(DISTINCT p1) AS startPaths, m MATCH p2 = (m)-[*0..4]-() " + "WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths WITH r0,startPaths + endPaths  AS paths " + "UNWIND paths AS p RETURN DISTINCT p, ID(r0)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 79 with Filters

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

the class RelationshipQueryStatementsTest method testFindByPropertiesWithDifferentComparisonOperatorsOred.

// DATAGRAPH-632
@Test
public void testFindByPropertiesWithDifferentComparisonOperatorsOred() {
    Filter distance = new Filter("distance", ComparisonOperator.EQUALS, 60.2);
    Filter time = new Filter("time", ComparisonOperator.GREATER_THAN, 3600);
    time.setBooleanOperator(BooleanOperator.OR);
    assertThat(query.findByType("ORBITS", new Filters().add(distance, time), 4).getStatement()).isEqualTo("MATCH (n)-[r0:`ORBITS`]->(m) WHERE r0.`distance` = $`distance_0` OR r0.`time` > $`time_1`  " + "WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m MATCH p1 = (n)-[*0..4]-() " + "WITH r0, COLLECT(DISTINCT p1) AS startPaths, m MATCH p2 = (m)-[*0..4]-() " + "WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths  AS paths UNWIND paths AS p RETURN DISTINCT p, ID(r0)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 80 with Filters

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

the class RelationshipQueryStatementsTest method testFindByBaseAndNestedPropertyOutgoing.

// DATAGRAPH-632
@Test
public void testFindByBaseAndNestedPropertyOutgoing() {
    Filter planetFilter = new Filter("name", ComparisonOperator.EQUALS, "Earth");
    planetFilter.setNestedPropertyName("world");
    planetFilter.setNestedEntityTypeLabel("Planet");
    planetFilter.setRelationshipType("ORBITS");
    planetFilter.setRelationshipDirection(Relationship.Direction.OUTGOING);
    Filter time = new Filter("time", ComparisonOperator.EQUALS, 3600);
    time.setBooleanOperator(BooleanOperator.AND);
    assertThat(query.findByType("ORBITS", new Filters().add(planetFilter, time), 4).getStatement()).isEqualTo("MATCH (n:`Planet`) WHERE n.`name` = $`world_name_0` " + "MATCH (n)-[r0:`ORBITS`]->(m) WHERE r0.`time` = $`time_1`  " + "WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m MATCH p1 = (n)-[*0..4]-() " + "WITH r0, COLLECT(DISTINCT p1) AS startPaths, m MATCH p2 = (m)-[*0..4]-() " + "WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths  AS paths UNWIND paths AS p RETURN DISTINCT p, ID(r0)");
}
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