use of com.enonic.xp.query.expr.FieldOrderExpr in project xp by enonic.
the class ReorderChildNodeCommand method createFirstNodeBeforeInsertQuery.
private NodeQuery createFirstNodeBeforeInsertQuery(final Long nodeAfterOrderValue) {
final CompareExpr orderGreaterThanNodeToMoveBefore = CompareExpr.gt(FieldExpr.from(NodeIndexPath.MANUAL_ORDER_VALUE), ValueExpr.number(nodeAfterOrderValue));
final CompareExpr parentPathEqualToParent = CompareExpr.eq(FieldExpr.from(NodeIndexPath.PARENT_PATH), ValueExpr.string(parentNode.path().toString()));
final LogicalExpr constraint = LogicalExpr.and(orderGreaterThanNodeToMoveBefore, parentPathEqualToParent);
final FieldOrderExpr orderManuallyDesc = FieldOrderExpr.create(NodeIndexPath.MANUAL_ORDER_VALUE, OrderExpr.Direction.ASC);
return NodeQuery.create().query(QueryExpr.from(constraint, orderManuallyDesc)).size(1).build();
}
use of com.enonic.xp.query.expr.FieldOrderExpr in project xp by enonic.
the class SortBuilderFactoryTest method createFieldSort.
@Test
public void createFieldSort() {
final Set<OrderExpr> orderExprs = new HashSet<>();
orderExprs.add(new FieldOrderExpr(FieldExpr.from("myField"), OrderExpr.Direction.ASC));
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(new SearchQueryFieldNameResolver()).create(orderExprs);
assertEquals(1, sortBuilders.size());
assertTrue(sortBuilders.iterator().next() instanceof FieldSortBuilder);
}
use of com.enonic.xp.query.expr.FieldOrderExpr in project xp by enonic.
the class SortBuilderFactoryTest method createFieldWithoutDirectionSort.
@Test
public void createFieldWithoutDirectionSort() {
final Set<OrderExpr> orderExprs = new HashSet<>();
orderExprs.add(new FieldOrderExpr(FieldExpr.from("myField"), null));
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(new SearchQueryFieldNameResolver()).create(orderExprs);
assertEquals(1, sortBuilders.size());
assertTrue(sortBuilders.iterator().next() instanceof FieldSortBuilder);
}
use of com.enonic.xp.query.expr.FieldOrderExpr in project xp by enonic.
the class SortBuilderFactoryTest method createMultipleFieldSort.
@Test
public void createMultipleFieldSort() {
final Set<OrderExpr> orderExprs = new HashSet<>();
orderExprs.add(new FieldOrderExpr(FieldExpr.from("myField"), OrderExpr.Direction.ASC));
orderExprs.add(new FieldOrderExpr(FieldExpr.from("mySecondField"), OrderExpr.Direction.DESC));
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(new SearchQueryFieldNameResolver()).create(orderExprs);
assertEquals(2, sortBuilders.size());
assertTrue(sortBuilders.iterator().next() instanceof FieldSortBuilder);
assertTrue(sortBuilders.iterator().next() instanceof FieldSortBuilder);
}
Aggregations