use of org.neo4j.ogm.cypher.query.SortOrder in project neo4j-ogm by neo4j.
the class CineastsRelationshipEntityTest method testFilterOnRelatedNode.
@Test
public void testFilterOnRelatedNode() throws Exception {
User frantisek = new User();
frantisek.setName("Frantisek");
frantisek.setLogin("frantisek");
User michal = new User();
michal.setName("Michal");
michal.setLogin("michal");
User ottoH = new User();
ottoH.setName("Otto");
ottoH.setLogin("otto");
User ottoB = new User();
ottoB.setName("Otto von Bismarc");
ottoB.setLogin("ottob");
frantisek.addFriends(ottoH, ottoB);
session.save(frantisek);
michal.addFriends(ottoH, ottoB);
session.save(michal);
// name contains ' '
Filter filter = new Filter("name", ComparisonOperator.CONTAINING, "Otto");
filter.setNestedPropertyName("friends");
filter.setNestedPropertyType(User.class);
SortOrder sortOrder = new SortOrder();
sortOrder.add("name");
Collection<User> users = session.loadAll(User.class, filter, sortOrder, new Pagination(0, 2));
assertThat(users).hasSize(2);
}
use of org.neo4j.ogm.cypher.query.SortOrder in project neo4j-ogm by neo4j.
the class SatelliteIntegrationTest method shouldReturnProgramsSortedByRefDesc.
@Test
public void shouldReturnProgramsSortedByRefDesc() {
Collection<Program> objects = session.loadAll(Program.class, new SortOrder().add(SortOrder.Direction.DESC, "ref"));
Iterator<Program> iter = objects.iterator();
Program first = iter.next();
while (iter.hasNext()) {
Program next = iter.next();
assertThat(first.getRef().compareTo(next.getRef()) > 0).isTrue();
first = next;
}
}
use of org.neo4j.ogm.cypher.query.SortOrder in project neo4j-ogm by neo4j.
the class SatelliteIntegrationTest method shouldLoadActiveSatellitesByPropertySorted.
@Test
public void shouldLoadActiveSatellitesByPropertySorted() {
Collection<Satellite> satellites = session.loadAll(Satellite.class, new Filter("manned", ComparisonOperator.EQUALS, "Y"), new SortOrder().add("ref"));
Iterator<Satellite> iter = satellites.iterator();
Satellite first = iter.next();
while (iter.hasNext()) {
Satellite next = iter.next();
assertThat(first.getRef().compareTo(next.getRef()) < 0).isTrue();
first = next;
}
}
use of org.neo4j.ogm.cypher.query.SortOrder in project neo4j-ogm by neo4j.
the class RelationshipEntityQuerySortingTest method setUp.
@Before
public void setUp() {
sortOrder = new SortOrder();
filters = new Filters();
}
use of org.neo4j.ogm.cypher.query.SortOrder in project neo4j-ogm by neo4j.
the class RelationshipEntityQuerySortingTest method testDefaultMultipleSortOrders.
@Test
public void testDefaultMultipleSortOrders() {
String cypher = "MATCH ()-[r0:`ORBITS`]-() WITH DISTINCT(r0) as r0,startnode(r0) AS n, " + "endnode(r0) AS m ORDER BY r0.distance,r0.aphelion " + "MATCH p1 = (n)-[*0..3]-() WITH r0, COLLECT(DISTINCT p1) AS startPaths, m " + "MATCH p2 = (m)-[*0..3]-() WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths AS paths UNWIND paths AS p RETURN DISTINCT p, ID(r0)";
PagingAndSortingQuery orbitsQuery = query.findByType("ORBITS", 3);
check(cypher, orbitsQuery.setSortOrder(sortOrder.add("distance", "aphelion")).getStatement());
check(cypher, orbitsQuery.setSortOrder(new SortOrder("distance", "aphelion")).getStatement());
check(cypher, orbitsQuery.setSortOrder(new SortOrder().asc("distance", "aphelion")).getStatement());
}
Aggregations