use of org.neo4j.ogm.cypher.Filters 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.Filters 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);
}
Aggregations