use of org.neo4j.ogm.cypher.query.SortOrder in project neo4j-ogm by neo4j.
the class NodeEntityQuerySortingTest method testMultipleSortOrders.
@Test
public void testMultipleSortOrders() {
String cypher = "MATCH (n:`Raptor`) WITH n ORDER BY n.age DESC,n.name DESC RETURN n";
check(cypher, query.findByType("Raptor", 0).setSortOrder(sortOrder.add(DESC, "age", "name")).getStatement());
check(cypher, query.findByType("Raptor", 0).setSortOrder(new SortOrder(DESC, "age", "name")).getStatement());
check(cypher, query.findByType("Raptor", 0).setSortOrder(new SortOrder().desc("age", "name")).getStatement());
}
use of org.neo4j.ogm.cypher.query.SortOrder in project framework by dynamiatools.
the class Neo4jCrudService method find.
@Override
public <T> List<T> find(Class<T> type, QueryParameters parameters) {
parameters.setType(type);
fireListeners(parameters, EventType.BEFORE_QUERY);
Filters filters = buildFilters(parameters);
SortOrder sortOrder = new SortOrder();
Pagination pagination = null;
int depth = getDepth(parameters);
if (parameters.getPaginator() != null) {
long totalSize = s().count(type, filters);
parameters.getPaginator().setTotalSize(totalSize);
pagination = buildPagination(parameters);
}
if (parameters.getSorter() != null) {
BeanSorter s = parameters.getSorter();
sortOrder.add(s.isAscending() ? SortOrder.Direction.ASC : SortOrder.Direction.DESC, s.getColumnName());
}
List<T> result = new ArrayList<>(s().loadAll(type, filters, sortOrder, pagination, depth));
fireListeners(parameters, EventType.AFTER_QUERY);
return result;
}
use of org.neo4j.ogm.cypher.query.SortOrder in project framework by dynamiatools.
the class Neo4jCrudService method findSingle.
@Override
public <T> T findSingle(Class<T> entityClass, QueryParameters params) {
Optional<T> result;
if (params.size() == 1 && params.containsKey("id")) {
result = Optional.of(s().load(entityClass, (Serializable) params.get("id"), params.getDepth()));
} else {
params.setType(entityClass);
fireListeners(params, EventType.BEFORE_QUERY);
Filters filters = buildFilters(params);
SortOrder sortOrder = new SortOrder();
Pagination pagination = new Pagination(0, 1);
int depth = getDepth(params);
Collection<T> data = s().loadAll(entityClass, filters, sortOrder, pagination, depth);
result = data.stream().findFirst();
fireListeners(params, EventType.AFTER_QUERY);
}
return result.orElse(null);
}
use of org.neo4j.ogm.cypher.query.SortOrder in project framework by dynamiatools.
the class Neo4jCrudService method findAll.
@Override
public <T> List<T> findAll(Class<T> type, String orderBy) {
SortOrder order = new SortOrder();
order.add(orderBy);
return new ArrayList<>(s().loadAll(type, order));
}
Aggregations