Search in sources :

Example 41 with Filter

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

the class NodeQueryStatementsTest method testFindByDifferentNestedPropertiesOred.

// DATAGRAPH-662
@Test(expected = UnsupportedOperationException.class)
public void testFindByDifferentNestedPropertiesOred() {
    Filter planetParam = collidesWithEarthFilter();
    Filter moonParam = orbitsMoonFilter();
    moonParam.setBooleanOperator(BooleanOperator.OR);
    queryStatements.findByType("Asteroid", new Filters().add(planetParam).add(moonParam), 1).getStatement();
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 42 with Filter

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

the class NodeQueryStatementsTest method testFindByMultipleNestedPropertiesInfiniteDepth.

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

Example 43 with Filter

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

the class NodeQueryStatementsTest method testFindByNestedREProperty.

// DATAGRAPH-632
@Test
public void testFindByNestedREProperty() {
    Filter planetParam = new Filter("totalDestructionProbability", ComparisonOperator.EQUALS, "20");
    planetParam.setNestedPropertyName("collision");
    // Collision is an RE
    planetParam.setNestedEntityTypeLabel("Collision");
    planetParam.setNestedRelationshipEntity(true);
    // assume COLLIDES is the RE type
    planetParam.setRelationshipType("COLLIDES");
    planetParam.setRelationshipDirection(Relationship.Direction.OUTGOING);
    planetParam.setNestedRelationshipEntity(true);
    assertThat(queryStatements.findByType("Asteroid", new Filters().add(planetParam), 1).getStatement()).isEqualTo("MATCH (n:`Asteroid`) MATCH (n)-[r0:`COLLIDES`]->(m0) " + "WHERE r0.`totalDestructionProbability` = $`collision_totalDestructionProbability_0` " + "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 44 with Filter

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

the class NodeQueryStatementsTest method testFindByNestedPropertiesOnTheSameEntityOred.

// Would be something like findByMoonSomethingAndFindByPlanetXOrFindByPlanetY
@Test
public void testFindByNestedPropertiesOnTheSameEntityOred() {
    Filter planetParam = collidesWithEarthFilter();
    planetParam.setBooleanOperator(BooleanOperator.AND);
    Filter planetParam2 = collidesWithMarsFilter();
    planetParam2.setBooleanOperator(BooleanOperator.OR);
    Filter moonParam = orbitsMoonFilter();
    assertThat(queryStatements.findByType("Asteroid", new Filters().add(moonParam).add(planetParam).add(planetParam2), 1).getStatement()).isEqualTo("MATCH (n:`Asteroid`) MATCH (m0:`Moon`) WHERE m0.`name` = $`moon_name_0` " + "MATCH (m1:`Planet`) WHERE m1.`name` = $`collidesWith_name_1` OR m1.`name` = $`collidesWith_name_2` " + "MATCH (n)<-[:`ORBITS`]-(m0) MATCH (n)-[:`COLLIDES`]->(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 45 with Filter

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

the class NodeQueryStatementsTest method testFindByNestedPropertiesOnTheSameEntityOredWithAnotherFilter.

// Would be something like findByMoonSomethingORFindByPlanetXOrFindByPlanetY
@Test(expected = UnsupportedOperationException.class)
public void testFindByNestedPropertiesOnTheSameEntityOredWithAnotherFilter() {
    Filter planetParam = collidesWithEarthFilter();
    planetParam.setBooleanOperator(BooleanOperator.OR);
    Filter planetParam2 = collidesWithMarsFilter();
    planetParam2.setBooleanOperator(BooleanOperator.OR);
    Filter moonParam = orbitsMoonFilter();
    queryStatements.findByType("Asteroid", new Filters().add(moonParam).add(planetParam).add(planetParam2), 1).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