Search in sources :

Example 71 with Filter

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

the class DistanceComparisonTestBase method filterForGeographicPoint2d.

@Test
public void filterForGeographicPoint2d() {
    Session session = sessionFactory.openSession();
    SomethingSpatial spatial = new SomethingSpatial();
    GeographicPoint2d centralStationLocation = new GeographicPoint2d(55.6093093, 13.0004377);
    spatial.setGeographicPoint2d(centralStationLocation);
    session.save(spatial);
    GeographicPoint2d office = new GeographicPoint2d(55.611851, 12.9949028);
    DistanceFromNativePoint distanceFromNativePoint = new DistanceFromNativePoint(office, 449);
    Filter filter = new Filter("geographicPoint2d", distanceComparisonFor(distanceFromNativePoint));
    filter.setOwnerEntityType(SomethingSpatial.class);
    Collection<SomethingSpatial> somethingSpatials = session.loadAll(SomethingSpatial.class, filter);
    assertThat(somethingSpatials).hasSize(1);
}
Also used : Filter(org.neo4j.ogm.cypher.Filter) GeographicPoint2d(org.neo4j.ogm.types.spatial.GeographicPoint2d) SomethingSpatial(org.neo4j.ogm.persistence.types.nativetypes.SomethingSpatial) DistanceFromNativePoint(org.neo4j.ogm.cypher.function.DistanceFromNativePoint) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Example 72 with Filter

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

the class DistanceComparisonTestBase method filterForGeographicPoint3dNoMatch.

@Test
public void filterForGeographicPoint3dNoMatch() {
    Session session = sessionFactory.openSession();
    SomethingSpatial spatial = new SomethingSpatial();
    GeographicPoint3d centralStationLocation = new GeographicPoint3d(55.6093093, 13.0004377, -5);
    spatial.setGeographicPoint3d(centralStationLocation);
    session.save(spatial);
    GeographicPoint3d office = new GeographicPoint3d(55.611851, 12.9949028, 15);
    DistanceFromNativePoint distanceFromNativePoint = new DistanceFromNativePoint(office, 448.950);
    Filter filter = new Filter("geographicPoint3d", distanceComparisonFor(distanceFromNativePoint));
    filter.setOwnerEntityType(SomethingSpatial.class);
    Collection<SomethingSpatial> somethingSpatials = session.loadAll(SomethingSpatial.class, filter);
    assertThat(somethingSpatials).hasSize(0);
}
Also used : Filter(org.neo4j.ogm.cypher.Filter) GeographicPoint3d(org.neo4j.ogm.types.spatial.GeographicPoint3d) SomethingSpatial(org.neo4j.ogm.persistence.types.nativetypes.SomethingSpatial) DistanceFromNativePoint(org.neo4j.ogm.cypher.function.DistanceFromNativePoint) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Example 73 with Filter

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

the class RelationshipEntityQuerySortingTest method testFindByProperty.

@Test
public void testFindByProperty() {
    filters.add(new Filter("distance", EQUALS, 60.2));
    sortOrder.add("aphelion");
    String expected = "MATCH (n)-[r0:`ORBITS`]->(m) WHERE r0.`distance` = $`distance_0`  " + "WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m ORDER BY r0.aphelion " + "MATCH p1 = (n)-[*0..1]-() WITH r0, COLLECT(DISTINCT p1) AS startPaths, m " + "MATCH p2 = (m)-[*0..1]-() WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths  AS paths UNWIND paths AS p RETURN DISTINCT p, ID(r0)";
    assertThat(query.findByType("ORBITS", filters, 1).setSortOrder(sortOrder).getStatement()).isEqualTo(expected);
}
Also used : Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 74 with Filter

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

the class CountStatementsTest method testCountNodesWithLabelAndFilters.

@Test
public void testCountNodesWithLabelAndFilters() throws Exception {
    CypherQuery query = statements.countNodes("Person", new Filters().add(new Filter("name", ComparisonOperator.EQUALS, "Jim")));
    assertThat(query.getStatement()).isEqualTo("MATCH (n:`Person`) WHERE n.`name` = $`name_0` WITH n RETURN COUNT(n)");
    assertThat(query.getParameters().toString()).isEqualTo("{name_0=Jim}");
}
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 75 with Filter

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

the class NodeDeleteStatementsTest method testDeleteWithLabelAndFiltersAndList.

@Test
public void testDeleteWithLabelAndFiltersAndList() throws Exception {
    CypherQuery query = statements.deleteAndList("INFLUENCE", new Filters().add(new Filter("score", ComparisonOperator.EQUALS, -12.2)));
    assertThat(query.getStatement()).isEqualTo("MATCH (n:`INFLUENCE`) " + "WHERE n.`score` = $`score_0` " + "WITH n " + "OPTIONAL MATCH (n)-[r0]-() " + "DELETE r0, n RETURN ID(n)");
}
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)

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