Search in sources :

Example 61 with Filter

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

the class RelationshipDeleteStatementsTest method testDeleteWithTypeAndFilters.

@Test
public void testDeleteWithTypeAndFilters() {
    CypherQuery query = statements.delete("INFLUENCE", new Filters().add(new Filter("score", ComparisonOperator.EQUALS, -12.2)));
    assertThat(query.getStatement()).isEqualTo("MATCH (n)-[r0:`INFLUENCE`]->(m) WHERE r0.`score` = $`score_0`  DELETE r0");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) CypherQuery(org.neo4j.ogm.cypher.query.CypherQuery) Test(org.junit.Test)

Example 62 with Filter

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

the class RelationshipQueryStatementsTest method testFindByNestedPropertyOutgoing.

// DATAGRAPH-632
@Test
public void testFindByNestedPropertyOutgoing() {
    Filter planetFilter = new Filter("name", ComparisonOperator.EQUALS, "Earth");
    planetFilter.setNestedPropertyName("world");
    planetFilter.setNestedEntityTypeLabel("Planet");
    planetFilter.setRelationshipType("ORBITS");
    planetFilter.setRelationshipDirection(Relationship.Direction.OUTGOING);
    assertThat(query.findByType("ORBITS", new Filters().add(planetFilter), 4).getStatement()).isEqualTo("MATCH (n:`Planet`) WHERE n.`name` = $`world_name_0` " + "MATCH (n)-[r0:`ORBITS`]->(m)  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 63 with Filter

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

the class RelationshipQueryStatementsTest method testFindByMultipleNestedPropertiesMissingBooleanOperator.

// GH-73
@Test(expected = MissingOperatorException.class)
public void testFindByMultipleNestedPropertiesMissingBooleanOperator() {
    Filter planetNameFilter = new Filter("name", ComparisonOperator.EQUALS, "Earth");
    planetNameFilter.setNestedPropertyName("world");
    planetNameFilter.setNestedEntityTypeLabel("Planet");
    planetNameFilter.setRelationshipType("ORBITS");
    planetNameFilter.setRelationshipDirection(Relationship.Direction.OUTGOING);
    Filter planetMoonsFilter = new Filter("moons", ComparisonOperator.EQUALS, "Earth");
    planetMoonsFilter.setNestedPropertyName("moons");
    planetMoonsFilter.setNestedEntityTypeLabel("Planet");
    planetMoonsFilter.setRelationshipType("ORBITS");
    planetMoonsFilter.setRelationshipDirection(Relationship.Direction.OUTGOING);
    query.findByType("ORBITS", new Filters().add(planetNameFilter, planetMoonsFilter), 4).getStatement();
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 64 with Filter

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

the class RelationshipQueryStatementsTest method testFindByPropertiesOred.

// DATAGRAPH-632
@Test
public void testFindByPropertiesOred() {
    Filter distance = new Filter("distance", ComparisonOperator.EQUALS, 60.2);
    Filter time = new Filter("time", ComparisonOperator.EQUALS, 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 65 with Filter

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

the class RelationshipQueryStatementsTest method testFindByPropertiesAndedWithMissingBooleanOperator.

// GH-73
@Test(expected = MissingOperatorException.class)
public void testFindByPropertiesAndedWithMissingBooleanOperator() {
    Filter distance = new Filter("distance", ComparisonOperator.EQUALS, 60.2);
    Filter time = new Filter("time", ComparisonOperator.EQUALS, 3600);
    query.findByType("ORBITS", new Filters().add(distance, time), 4).getStatement();
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Aggregations

Filter (org.neo4j.ogm.cypher.Filter)155 Test (org.junit.Test)146 Filters (org.neo4j.ogm.cypher.Filters)78 User (org.neo4j.ogm.domain.cineasts.annotated.User)19 Rating (org.neo4j.ogm.domain.cineasts.annotated.Rating)18 Movie (org.neo4j.ogm.domain.cineasts.annotated.Movie)17 Restaurant (org.neo4j.ogm.domain.restaurant.Restaurant)12 Date (java.util.Date)10 Session (org.neo4j.ogm.session.Session)10 DistanceFromNativePoint (org.neo4j.ogm.cypher.function.DistanceFromNativePoint)8 SomethingSpatial (org.neo4j.ogm.persistence.types.nativetypes.SomethingSpatial)8 HashSet (java.util.HashSet)7 CypherQuery (org.neo4j.ogm.cypher.query.CypherQuery)7 GroupMember (org.neo4j.ogm.domain.gh824.GroupMember)7 ArrayList (java.util.ArrayList)4 Actor (org.neo4j.ogm.domain.cineasts.annotated.Actor)4 User (org.neo4j.ogm.domain.gh824.User)4 UserGroup (org.neo4j.ogm.domain.gh824.UserGroup)4 Studio (org.neo4j.ogm.domain.music.Studio)4 Collections (java.util.Collections)2