use of javax.jcr.query.qom.Selector in project jackrabbit by apache.
the class Parser method parseSource.
private Source parseSource() throws RepositoryException {
Selector selector = parseSelector();
selectors.add(selector);
Source source = selector;
while (true) {
JoinType type;
if (readIf("RIGHT")) {
read("OUTER");
type = JoinType.RIGHT;
} else if (readIf("LEFT")) {
read("OUTER");
type = JoinType.LEFT;
} else if (readIf("INNER")) {
type = JoinType.INNER;
} else {
break;
}
read("JOIN");
selector = parseSelector();
selectors.add(selector);
read("ON");
JoinCondition on = parseJoinCondition();
source = type.join(factory, source, selector, on);
}
return source;
}
use of javax.jcr.query.qom.Selector 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.Selector in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testJoin.
/**
* Test case for {@link QueryObjectModelFactory#join(Source, Source, String, JoinCondition)}
*/
public void testJoin() throws RepositoryException {
Selector s1 = qf.selector(ntBase, SELECTOR_NAME1);
Selector s2 = qf.selector(testNodeType, SELECTOR_NAME1);
JoinCondition cond = qf.equiJoinCondition(ntBase, jcrPrimaryType, testNodeType, jcrPrimaryType);
for (Iterator<String> it = JOIN_TYPES.iterator(); it.hasNext(); ) {
String joinType = it.next();
Join join = qf.join(s1, s2, joinType, cond);
assertTrue("Not a selector source", join.getLeft() instanceof Selector);
assertTrue("Not a selector source", join.getRight() instanceof Selector);
assertEquals("Wrong join type", joinType, join.getJoinType());
assertTrue("Not an EquiJoinCondition", join.getJoinCondition() instanceof EquiJoinCondition);
}
}
use of javax.jcr.query.qom.Selector in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testSelector.
/**
* Test case for {@link QueryObjectModelFactory#selector(String, String)}
*/
public void testSelector() throws RepositoryException {
Selector selector = qf.selector(ntBase, SELECTOR_NAME1);
assertEquals("Wrong node type name", ntBase, selector.getNodeTypeName());
assertEquals("Wrong selector name", SELECTOR_NAME1, selector.getSelectorName());
}
use of javax.jcr.query.qom.Selector 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);
}
Aggregations