@Override public List<Constraint> getRightJoinConstraints(Collection<Row> leftRows) throws RepositoryException { Set<String> paths = new HashSet<String>(); for (Row row : leftRows) { paths.addAll(getLeftValues(row)); } List<Constraint> constraints = new ArrayList<Constraint>(); for (String path : paths) { if (rightSelectors.contains(selector1)) { constraints.add(factory.sameNode(selector1, path)); } else { constraints.add(factory.sameNode(selector2, path)); } } return constraints; }
@Test public void escapedName() throws RepositoryException { assertEquals("[[n]]]", f.selector("[n]", null).toString()); assertEquals("[[s]]].[[p]]]", f.propertyValue("[s]", "[p]").toString()); assertEquals("ISSAMENODE([[s1]]], [[s2]]], [[p]]])", f.sameNodeJoinCondition("[s1]", "[s2]", "[p]").toString()); assertEquals("ISSAMENODE([[s]]], [[p]]])", f.sameNode("[s]", "[p]").toString()); } }
@Override public List<Constraint> getRightJoinConstraints(Collection<Row> leftRows) throws RepositoryException { Set<String> paths = new HashSet<String>(); for (Row row : leftRows) { paths.addAll(getLeftValues(row)); } List<Constraint> constraints = new ArrayList<Constraint>(); for (String path : paths) { if (rightSelectors.contains(selector1)) { constraints.add(factory.sameNode(selector1, path)); } else { constraints.add(factory.sameNode(selector2, path)); } } return constraints; }
@Override public List<Constraint> getRightJoinConstraints(Collection<Row> leftRows) throws RepositoryException { Set<String> paths = new HashSet<String>(); for (Row row : leftRows) { paths.addAll(getLeftValues(row)); } List<Constraint> constraints = new ArrayList<Constraint>(); for (String path: paths) { if (rightSelectors.contains(childSelector)) { constraints.add(factory.childNode(childSelector, path)); } else { constraints.add(factory.sameNode(parentSelector, path)); } } return constraints; }
@Override public List<Constraint> getRightJoinConstraints(Collection<Row> leftRows) throws RepositoryException { Set<String> paths = new HashSet<String>(); for (Row row : leftRows) { paths.addAll(getLeftValues(row)); } List<Constraint> constraints = new ArrayList<Constraint>(); for (String path: paths) { if (rightSelectors.contains(childSelector)) { constraints.add(factory.childNode(childSelector, path)); } else { constraints.add(factory.sameNode(parentSelector, path)); } } return constraints; }
@Override public List<Constraint> getRightJoinConstraints(Collection<Row> leftRows) throws RepositoryException { Set<String> paths = new HashSet<String>(); for (Row row : leftRows) { paths.addAll(getLeftValues(row)); } List<Constraint> constraints = new ArrayList<Constraint>(); for (String path : paths) { if (rightSelectors.contains(descendantSelector)) { constraints.add( factory.descendantNode(descendantSelector, path)); } else { constraints.add(factory.sameNode(ancestorSelector, path)); } } return constraints; }
@Override public List<Constraint> getRightJoinConstraints(Collection<Row> leftRows) throws RepositoryException { Set<String> paths = new HashSet<String>(); for (Row row : leftRows) { paths.addAll(getLeftValues(row)); } List<Constraint> constraints = new ArrayList<Constraint>(); for (String path : paths) { if (rightSelectors.contains(descendantSelector)) { constraints.add( factory.descendantNode(descendantSelector, path)); } else { constraints.add(factory.sameNode(ancestorSelector, path)); } } return constraints; }
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}); }
/** * Test case for {@link QueryObjectModelFactory#sameNode(String, String)} */ public void testSameNodeWithSelector() throws RepositoryException { SameNode sameNode = qf.sameNode(SELECTOR_NAME1, testRootNode.getPath()); assertEquals("Wrong selector name", SELECTOR_NAME1, sameNode.getSelectorName()); assertEquals("Wrong path", testRootNode.getPath(), sameNode.getPath()); }
/** * Test case for {@link QueryObjectModelFactory#sameNode(String, String)} */ public void testSameNode() throws RepositoryException { SameNode sameNode = qf.sameNode(SELECTOR_NAME1, testRootNode.getPath()); assertEquals("Wrong selector name", SELECTOR_NAME1, sameNode.getSelectorName()); assertEquals("Wrong path", testRootNode.getPath(), sameNode.getPath()); }
public void testPathDoesNotExist() throws RepositoryException { QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.sameNode("s", testRoot + "/" + nodeName1), null, null); checkQOM(qom, new Node[]{}); }
@Test public void sameNode() throws RepositoryException { SameNode s = f.sameNode("selectorName", "path"); assertEquals("selectorName", s.getSelectorName()); assertEquals("path", s.getPath()); assertEquals("ISSAMENODE([selectorName], [path])", s.toString()); assertEquals("ISSAMENODE([path])", f.sameNode(null, "path").toString()); assertEquals("ISSAMENODE([s], [path])", f.sameNode("s", "path").toString()); }
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"); }
public void testRelativePath() throws RepositoryException { try { Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.sameNode("s", testPath), null, null); q.execute(); fail("SameNode with relative path argument must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } try { String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE ISSAMENODE(s, [" + testPath + "]"; qm.createQuery(stmt, Query.JCR_SQL2).execute(); fail("ISSAMENODE() with relative path argument must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } }
public void testSyntacticallyInvalidPath() throws RepositoryException { String invalidPath = testRoot + "/" + nodeName1 + "["; try { Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.sameNode("s", invalidPath), null, null); q.execute(); fail("SameNode with syntactically invalid path argument must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } try { String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE ISSAMENODE(s, [" + invalidPath + "]"; qm.createQuery(stmt, Query.JCR_SQL2).execute(); fail("ISSAMENODE() with syntactically invalid path argument must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } }
public void testNotASelectorName() throws RepositoryException { try { Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.sameNode("x", testRoot), null, null); q.execute(); fail("SameNode with an invalid selector name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } try { String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE ISSAMENODE(x, [" + testRoot + "]"; qm.createQuery(stmt, Query.JCR_SQL2).execute(); fail("ISSAMENODE with an invalid selector name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } } }