use of org.unipop.query.predicates.PredicatesHolder in project unipop by unipop-graph.
the class DocEdgeSchema method getVertexPredicates.
protected PredicatesHolder getVertexPredicates(List<Vertex> vertices, Direction direction) {
PredicatesHolder outPredicates = this.outVertexSchema.toPredicates(vertices);
PredicatesHolder inPredicates = this.inVertexSchema.toPredicates(vertices);
if (direction.equals(Direction.OUT) && outPredicates.notAborted())
return outPredicates;
if (direction.equals(Direction.IN) && inPredicates.notAborted())
return inPredicates;
if (outPredicates.notAborted() && inPredicates.notAborted())
return PredicatesHolderFactory.or(inPredicates, outPredicates);
else if (outPredicates.isAborted())
return inPredicates;
else if (inPredicates.isAborted())
return outPredicates;
else
return PredicatesHolderFactory.abort();
}
use of org.unipop.query.predicates.PredicatesHolder in project unipop by unipop-graph.
the class AbstractDocSchema method getSearch.
@Override
public QueryBuilder getSearch(SearchQuery<E> query) {
PredicatesHolder predicatesHolder = this.toPredicates(query.getPredicates());
if (predicatesHolder.getClause().equals(PredicatesHolder.Clause.Abort))
return null;
QueryBuilder queryBuilder = createQueryBuilder(predicatesHolder);
return queryBuilder;
// return createSearch(query, queryBuilder);
}
use of org.unipop.query.predicates.PredicatesHolder 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);
}
use of org.unipop.query.predicates.PredicatesHolder in project unipop by unipop-graph.
the class RowEdgeSchema method getVertexPredicates.
protected PredicatesHolder getVertexPredicates(List<Vertex> vertices, Direction direction) {
PredicatesHolder outPredicates = this.outVertexSchema.toPredicates(vertices);
PredicatesHolder inPredicates = this.inVertexSchema.toPredicates(vertices);
if (direction.equals(Direction.OUT))
return outPredicates;
if (direction.equals(Direction.IN))
return inPredicates;
return PredicatesHolderFactory.or(inPredicates, outPredicates);
}
use of org.unipop.query.predicates.PredicatesHolder in project unipop by unipop-graph.
the class UniGraph method createIdPredicate.
public static <E extends Element> PredicatesHolder createIdPredicate(Object[] ids, Class<E> returnType) {
ElementHelper.validateMixedElementIds(returnType, ids);
// if (ids.length > 0 && Vertex.class.isAssignableFrom(ids[0].getClass())) return new ArrayIterator<>(ids);
if (ids.length > 0) {
List<Object> collect = Stream.of(ids).map(id -> {
if (id instanceof Element)
return ((Element) id).id();
return id;
}).collect(Collectors.toList());
HasContainer idPredicate = new HasContainer(T.id.getAccessor(), P.within(collect));
return PredicatesHolderFactory.predicate(idPredicate);
}
return PredicatesHolderFactory.empty();
}
Aggregations