use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class SameNodeTest method testChildNodesDoNotMatchSelector.
public void testChildNodesDoNotMatchSelector() throws RepositoryException, NotExecutableException {
testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
NodeType testNt = ntMgr.getNodeType(testNodeType);
while (it.hasNext()) {
NodeType nt = it.nextNodeType();
if (!testNt.isNodeType(nt.getName())) {
// perform test
QueryObjectModel qom = qf.createQuery(qf.selector(nt.getName(), "s"), qf.sameNode("s", testRoot + "/" + nodeName1), null, null);
checkQOM(qom, new Node[] {});
return;
}
}
throw new NotExecutableException("No suitable node type found to " + "perform test against '" + testNodeType + "' nodes");
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class SameNodeTest method testSameNode.
public void testSameNode() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.sameNode("s", testRoot + "/" + nodeName1), null, null);
checkQOM(qom, new Node[] { n });
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class EquiJoinConditionTest method testLeftOuterJoin2.
public void testLeftOuterJoin2() throws RepositoryException {
JoinCondition c = qf.equiJoinCondition(LEFT, propertyName2, RIGHT, propertyName1);
QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, c);
checkQOM(qom, new Node[][] { { n1, null }, { n2, n1 }, { n2, n2 } });
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class GetQueryTest method testGetQuery.
public void testGetQuery() throws RepositoryException, NotExecutableException {
checkNtQuery();
Node n = testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
List<Query> queries = new ArrayList<Query>();
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("s", testRoot), null, null);
queries.add(qom);
queries.add(qm.createQuery(qom.getStatement(), Query.JCR_SQL2));
if (isSupportedLanguage(qsXPATH)) {
String xpath = testPath + "/element(*, " + testNodeType + ")";
queries.add(qm.createQuery(xpath, qsXPATH));
}
if (isSupportedLanguage(qsSQL)) {
String sql = "select * from " + testNodeType + " where jcr:path like '" + testRoot + "/%'";
queries.add(qm.createQuery(sql, qsSQL));
}
for (Iterator<Query> it = queries.iterator(); it.hasNext(); ) {
Query q = it.next();
String lang = q.getLanguage();
checkResult(q.execute(), new Node[] { n });
Node stored = q.storeAsNode(testRoot + "/storedQuery");
q = qm.getQuery(stored);
assertEquals("language of stored query does not match", lang, q.getLanguage());
checkResult(q.execute(), new Node[] { n });
stored.remove();
}
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class NodeLocalNameTest method testNameLiteral.
public void testNameLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(nodeLocalName, PropertyType.NAME);
QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);
checkQOM(qom, new Node[] { node1 });
}
Aggregations