use of javax.jcr.query.qom.Ordering in project jackrabbit by apache.
the class AbstractOrderByTest method createQOM.
/**
* @return a basic QOM to test order by queries.
* @throws RepositoryException if an error occurs.
*/
protected QueryObjectModel createQOM(boolean ascending) throws RepositoryException {
DynamicOperand op = createOrderingOperand();
Ordering ordering;
if (ascending) {
ordering = qf.ascending(op);
} else {
ordering = qf.descending(op);
}
return qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("s", testRoot), new Ordering[] { ordering }, null);
}
use of javax.jcr.query.qom.Ordering in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryFromSourceWithConstraintOrderingAndColumn.
public void testCreateQueryFromSourceWithConstraintOrderingAndColumn() throws RepositoryException {
Source selector = qf.selector(testNodeType, SELECTOR_NAME1);
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
Ordering ordering = qf.ascending(propValue);
Column column = qf.column(SELECTOR_NAME1, propertyName1, propertyName1);
QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, new Column[] { column });
assertTrue("Not a selector source", qom.getSource() instanceof Selector);
assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
assertEquals("Wrong size of orderings", 1, qom.getOrderings().length);
assertEquals("Wrong size of columns", 1, qom.getColumns().length);
}
use of javax.jcr.query.qom.Ordering in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryWithConstraintAndOrdering.
public void testCreateQueryWithConstraintAndOrdering() throws RepositoryException {
Selector selector = qf.selector(testNodeType, SELECTOR_NAME1);
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
Ordering ordering = qf.ascending(propValue);
QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, null);
assertTrue("Not a selector source", qom.getSource() instanceof Selector);
assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
assertEquals("Wrong size of orderings", 1, qom.getOrderings().length);
assertEquals("Wrong size of columns", 0, qom.getColumns().length);
}
use of javax.jcr.query.qom.Ordering in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryWithConstraintOrderingAndColumn.
public void testCreateQueryWithConstraintOrderingAndColumn() throws RepositoryException {
Selector selector = qf.selector(testNodeType, SELECTOR_NAME1);
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
Ordering ordering = qf.ascending(propValue);
Column column = qf.column(SELECTOR_NAME1, propertyName1, propertyName1);
QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, new Column[] { column });
assertTrue("Not a selector source", qom.getSource() instanceof Selector);
assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
assertEquals("Wrong size of orderings", 1, qom.getOrderings().length);
assertEquals("Wrong size of columns", 1, qom.getColumns().length);
}
use of javax.jcr.query.qom.Ordering in project jackrabbit by apache.
the class OrderingTest method testMultipleSelectors.
public void testMultipleSelectors() throws RepositoryException {
// ascending
Ordering[] orderings = new Ordering[] { qf.ascending(qf.propertyValue(LEFT, propertyName2)) };
QueryObjectModel qom = createQuery(orderings);
checkResultOrder(qom, SELECTOR_NAMES, new Node[][] { { n2, n2 }, { n1, n2 } });
// descending
orderings[0] = qf.descending(qf.propertyValue(LEFT, propertyName2));
qom = createQuery(orderings);
checkResultOrder(qom, SELECTOR_NAMES, new Node[][] { { n1, n2 }, { n2, n2 } });
}
Aggregations