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);
}
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);
}
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);
}
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}");
}
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)");
}
Aggregations