use of org.neo4j.ogm.cypher.Filter in project neo4j-ogm by neo4j.
the class RelationshipQueryStatementsTest method testFindByPropertiesWithDifferentComparisonOperatorsAnded.
// DATAGRAPH-632
@Test
public void testFindByPropertiesWithDifferentComparisonOperatorsAnded() {
Filter distance = new Filter("distance", ComparisonOperator.LESS_THAN, 60.2);
Filter time = new Filter("time", ComparisonOperator.EQUALS, 3600);
time.setBooleanOperator(BooleanOperator.AND);
assertThat(query.findByType("ORBITS", new Filters().add(distance, time), 4).getStatement()).isEqualTo("MATCH (n)-[r0:`ORBITS`]->(m) WHERE r0.`distance` < $`distance_0` AND 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)");
}
use of org.neo4j.ogm.cypher.Filter in project neo4j-ogm by neo4j.
the class RelationshipQueryStatementsTest method testFindByNestedPropertyIncoming.
// DATAGRAPH-632
@Test
public void testFindByNestedPropertyIncoming() {
Filter planetFilter = new Filter("name", ComparisonOperator.EQUALS, "Earth");
planetFilter.setNestedPropertyName("world");
planetFilter.setNestedEntityTypeLabel("Planet");
planetFilter.setRelationshipType("ORBITS");
planetFilter.setRelationshipDirection(Relationship.Direction.INCOMING);
assertThat(query.findByType("ORBITS", new Filters().add(planetFilter), 4).getStatement()).isEqualTo("MATCH (m:`Planet`) WHERE m.`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)");
}
use of org.neo4j.ogm.cypher.Filter in project neo4j-ogm by neo4j.
the class ConcurrentSessionTest method multipleThreadsResultsGetMixedUp.
@Test
public void multipleThreadsResultsGetMixedUp() throws Exception {
World world1 = new World("world 1", 1);
Session session = sessionFactory.openSession();
session.save(world1, 0);
World world2 = new World("world 2", 2);
session.save(world2, 0);
int iterations = 1000;
ExecutorService service = Executors.newFixedThreadPool(2);
final CountDownLatch countDownLatch = new CountDownLatch(iterations * 2);
for (int i = 0; i < iterations; i++) {
service.execute(() -> {
Session session1 = sessionFactory.openSession();
World world = session1.loadAll(World.class, new Filter("name", ComparisonOperator.EQUALS, "world 1")).iterator().next();
if (!"world 1".equals(world.getName())) {
failed = true;
}
countDownLatch.countDown();
});
service.execute(() -> {
Session session2 = sessionFactory.openSession();
World world = session2.loadAll(World.class, new Filter("name", ComparisonOperator.EQUALS, "world 2")).iterator().next();
if (!"world 2".equals(world.getName())) {
failed = true;
}
countDownLatch.countDown();
});
}
countDownLatch.await();
assertThat(failed).isFalse();
}
use of org.neo4j.ogm.cypher.Filter in project neo4j-ogm by neo4j.
the class DistanceComparisonTestBase method filterForCartesianPoint3d.
@Test
public void filterForCartesianPoint3d() {
Session session = sessionFactory.openSession();
SomethingSpatial spatial = new SomethingSpatial();
CartesianPoint3d point = new CartesianPoint3d(1, 2, 3);
spatial.setCartesianPoint3d(point);
session.save(spatial);
DistanceFromNativePoint distanceFromNativePoint = new DistanceFromNativePoint(new CartesianPoint3d(2, 2, 3), 2);
Filter filter = new Filter("cartesianPoint3d", 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 filterForGeographicPoint3d.
@Test
public void filterForGeographicPoint3d() {
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.9591);
Filter filter = new Filter("geographicPoint3d", distanceComparisonFor(distanceFromNativePoint));
filter.setOwnerEntityType(SomethingSpatial.class);
Collection<SomethingSpatial> somethingSpatials = session.loadAll(SomethingSpatial.class, filter);
assertThat(somethingSpatials).hasSize(1);
}
Aggregations