public void testRightOuterJoin() throws RepositoryException { JoinCondition c = qf.descendantNodeJoinCondition(LEFT, RIGHT); QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER, c); checkQOM(qom, new Node[][]{{n2, n1}, {null, n2}}); }
public void testInnerJoin() throws RepositoryException { JoinCondition c = qf.descendantNodeJoinCondition(LEFT, RIGHT); QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, c); checkQOM(qom, new Node[][]{{n2, n1}}); }
public void testLeftOuterJoin() throws RepositoryException { JoinCondition c = qf.descendantNodeJoinCondition(LEFT, RIGHT); QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, c); List<Node[]> result = new ArrayList<Node[]>(); result.add(new Node[]{n2, n1}); // for each ancestor-or-self of testRootNode check // whether it is of type testNodeType and add // two matches in that case Node n = testRootNode; for (;;) { if (n.isNodeType(testNodeType)) { result.add(new Node[]{n1, n}); result.add(new Node[]{n2, n}); } if (n.getDepth() == 0) { break; } else { n = n.getParent(); } } if (result.size() == 1) { // n1 not yet covered result.add(new Node[]{n1, null}); } checkQOM(qom, result.toArray(new Node[result.size()][])); } }
/** * Test case for {@link QueryObjectModelFactory#descendantNodeJoinCondition(String, String)} */ public void testDescendantNodeJoinCondition() throws RepositoryException { DescendantNodeJoinCondition cond = qf.descendantNodeJoinCondition(SELECTOR_NAME1, SELECTOR_NAME2); assertEquals("Wrong selector name", SELECTOR_NAME1, cond.getDescendantSelectorName()); assertEquals("Wrong selector name", SELECTOR_NAME2, cond.getAncestorSelectorName()); }
@Test public void descendantNodeJoinCondition() throws RepositoryException { DescendantNodeJoinCondition d = f.descendantNodeJoinCondition("descendantSelectorName", "ancestorSelectorName"); assertEquals("descendantSelectorName", d.getDescendantSelectorName()); assertEquals("ancestorSelectorName", d.getAncestorSelectorName()); assertEquals("ISDESCENDANTNODE([descendantSelectorName], [ancestorSelectorName])", d.toString()); }
public void testDuplicateNodeType() throws RepositoryException { try { Query q = qf.createQuery( qf.join( qf.selector(testNodeType, "nt"), qf.selector(testNodeType, "nt"), QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, qf.descendantNodeJoinCondition("nt", "nt")), null, null, null); q.execute(); fail("Selector with two identical selector names must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } try { String stmt = "SELECT * FROM [" + testNodeType + "] AS nt, [" + testNodeType + "] AS nt nt INNER JOIN nt ON ISDESCENDANTNODE(nt, nt)"; qm.createQuery(stmt, Query.JCR_SQL2).execute(); fail("selectorName with syntactically invalid name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } } }
String descendantSelector = readName(); read(","); c = factory.descendantNodeJoinCondition(descendantSelector, readName()); } else { throw getSyntaxError("ISSAMENODE, ISCHILDNODE, or ISDESCENDANTNODE");
String descendantSelector = readName(); read(","); c = factory.descendantNodeJoinCondition(descendantSelector, readName()); } else { throw getSyntaxError("ISSAMENODE, ISCHILDNODE, or ISDESCENDANTNODE");
String descendantSelector = readName(); read(","); c = factory.descendantNodeJoinCondition(descendantSelector, readName()); } else { throw getSyntaxError("ISSAMENODE, ISCHILDNODE, or ISDESCENDANTNODE");