Search in sources :

Example 51 with Filter

use of org.neo4j.ogm.cypher.Filter 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)

Example 52 with Filter

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

the class NodeQueryStatementsTest method testFindByPropertyLessThan.

// DATAGRAPH-629
@Test
public void testFindByPropertyLessThan() {
    Filter parameter = new Filter("diameter", ComparisonOperator.LESS_THAN, 60);
    assertThat(queryStatements.findByType("Asteroid", new Filters().add(parameter), 4).getStatement()).isEqualTo("MATCH (n:`Asteroid`) WHERE n.`diameter` < $`diameter_0` " + "WITH n MATCH p=(n)-[*0..4]-(m) RETURN p, ID(n)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 53 with Filter

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

the class NodeQueryStatementsTest method testFindByMultipleNestedProperties.

// DATAGRAPH-629
@Test
public void testFindByMultipleNestedProperties() {
    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..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 54 with Filter

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

the class NodeQueryStatementsTest method testFindByPropertyLessThanEqual.

// DATAGRAPH-904
@Test
public void testFindByPropertyLessThanEqual() {
    Filter parameter = new Filter("diameter", ComparisonOperator.LESS_THAN_EQUAL, 60);
    assertThat(queryStatements.findByType("Asteroid", new Filters().add(parameter), 4).getStatement()).isEqualTo("MATCH (n:`Asteroid`) WHERE n.`diameter` <= $`diameter_0` " + "WITH n MATCH p=(n)-[*0..4]-(m) RETURN p, ID(n)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 55 with Filter

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

the class NodeQueryStatementsTest method testFindByPropertyWithInfiniteValue.

// DATAGRAPH-781
@Test
public void testFindByPropertyWithInfiniteValue() {
    PagingAndSortingQuery pagingAndSortingQuery = queryStatements.findByType("Asteroid", new Filters().add(new Filter("albedo", ComparisonOperator.EQUALS, -12.2)), 0);
    assertThat(pagingAndSortingQuery.getStatement()).isEqualTo("MATCH (n:`Asteroid`) WHERE n.`albedo` = $`albedo_0` WITH n RETURN n");
    assertThat((double) pagingAndSortingQuery.getParameters().get("albedo_0")).isEqualTo(-12.2, within(0.005));
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery) 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