use of javax.jcr.query.qom.Source in project jackrabbit-oak by apache.
the class QomTest method join.
@Test
public void join() throws RepositoryException {
Source left = f.selector("nodeTypeName", "selectorName");
Source right = f.selector("nodeTypeName2", "selectorName2");
ChildNodeJoinCondition jc = f.childNodeJoinCondition("childSelectorName", "parentSelectorName");
Join j = f.join(left, right, QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, jc);
assertEquals(left, j.getLeft());
assertEquals(right, j.getRight());
assertEquals(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, j.getJoinType());
assertEquals(jc, j.getJoinCondition());
assertEquals("ISCHILDNODE([childSelectorName], [parentSelectorName])", jc.toString());
}
use of javax.jcr.query.qom.Source in project jackrabbit by apache.
the class SQL2PathEscapingTest method testGetChildrenApiDirect.
/**
* will build a query directly via the api using a spaced path
*
* @throws Exception
*/
public void testGetChildrenApiDirect() throws Exception {
QueryObjectModelFactory qomf = qm.getQOMFactory();
Source source1 = qomf.selector(NodeType.NT_BASE, "selector");
Column[] columns = new Column[] { qomf.column("selector", null, null) };
Constraint constraint2 = qomf.childNode("selector", n1.getPath());
QueryObjectModel qom = qomf.createQuery(source1, constraint2, null, columns);
checkResult(qom.execute(), 2);
}
use of javax.jcr.query.qom.Source in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryFromSourceWithConstraintAndOrdering.
public void testCreateQueryFromSourceWithConstraintAndOrdering() 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);
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.Source in project jackrabbit-oak by apache.
the class QomTest method jcrNameConversion.
@Test
public void jcrNameConversion() throws RepositoryException {
assertEquals("[nt:base]", f.column(null, NodeType.NT_BASE, null).toString());
assertEquals("[s1].[nt:base] = [s2].[nt:base]", f.equiJoinCondition("s1", NodeType.NT_BASE, "s2", NodeType.NT_BASE).toString());
assertEquals("CONTAINS([nt:base], null)", f.fullTextSearch(null, NodeType.NT_BASE, null).toString());
assertEquals("CAST('nt:base' AS NAME)", f.literal(vf.createValue(NodeType.NT_BASE, PropertyType.NAME)).toString());
assertEquals("[nt:base] IS NOT NULL", f.propertyExistence(null, NodeType.NT_BASE).toString());
assertEquals("[nt:base]", f.propertyValue(null, NodeType.NT_BASE).toString());
assertEquals("[nt:base]", f.selector(NodeType.NT_BASE, null).toString());
Source source1 = f.selector(NodeType.NT_BASE, "selector");
Column[] columns = new Column[] { f.column("selector", null, null) };
Constraint constraint2 = f.childNode("selector", "/");
QueryObjectModel qom = f.createQuery(source1, constraint2, null, columns);
assertEquals("select [selector].* from " + "[nt:base] AS [selector] " + "where ISCHILDNODE([selector], [/])", qom.toString());
}
use of javax.jcr.query.qom.Source in project jackrabbit by apache.
the class SQL2PathEscapingTest method testGetChildrenApiStatement.
/**
* the statement behind the api should be consistent, and return a similar
* query. in our case it should escape the paths that have spaces in them by
* enclosing them in single quotes
*
* @throws Exception
*/
public void testGetChildrenApiStatement() throws Exception {
QueryObjectModelFactory qomf = qm.getQOMFactory();
Source source1 = qomf.selector(NodeType.NT_BASE, "selector");
Column[] columns = new Column[] { qomf.column("selector", null, null) };
Constraint constraint2 = qomf.childNode("selector", n1.getPath());
QueryObjectModel qom = qomf.createQuery(source1, constraint2, null, columns);
checkResult(executeSQL2Query(qom.getStatement()), 2);
}
Aggregations