use of org.unipop.jdbc.utils.JdbcPredicatesTranslator in project unipop by unipop-graph.
the class AbstractRowSchema method getSearch.
@Override
public Select getSearch(SearchQuery<E> query, PredicatesHolder predicatesHolder) {
if (predicatesHolder.isAborted()) {
return null;
}
Condition conditions = new JdbcPredicatesTranslator().translate(predicatesHolder);
int finalLimit = query.getLimit() < 0 ? Integer.MAX_VALUE : query.getLimit();
SelectConditionStep<Record> where = createSqlQuery(query.getPropertyKeys()).where(conditions);
List<Pair<String, Order>> orders = query.getOrders();
if (orders != null) {
List<SortField<Object>> orderValues = orders.stream().filter(order -> !order.getValue1().equals(Order.shuffle)).filter(order -> getFieldByPropertyKey(order.getValue0()) != null).map(order -> order.getValue1().equals(Order.incr) ? field(getFieldByPropertyKey(order.getValue0())).asc() : field(getFieldByPropertyKey(order.getValue0())).desc()).collect(Collectors.toList());
if (orderValues.size() > 0)
return where.orderBy(orderValues).limit(finalLimit);
}
return where.limit(finalLimit);
}
Aggregations