protected JoinMerger( Join join, Map<String, PropertyValue> columns, OperandEvaluator evaluator, QueryObjectModelFactory factory) throws RepositoryException { this.type = join.getJoinType(); this.leftSelectors = getSelectorNames(join.getLeft()); this.rightSelectors = getSelectorNames(join.getRight()); Set<String> selectors = new LinkedHashSet<String>(); selectors.addAll(leftSelectors); selectors.addAll(rightSelectors); this.selectorNames = selectors.toArray(new String[selectors.size()]); this.columns = columns; this.columnNames = columns.keySet().toArray(new String[columns.size()]); this.evaluator = evaluator; this.factory = factory; }
protected JoinMerger( Join join, Map<String, PropertyValue> columns, OperandEvaluator evaluator, QueryObjectModelFactory factory) throws RepositoryException { this.type = join.getJoinType(); this.leftSelectors = getSelectorNames(join.getLeft()); this.rightSelectors = getSelectorNames(join.getRight()); Set<String> selectors = new LinkedHashSet<String>(); selectors.addAll(leftSelectors); selectors.addAll(rightSelectors); this.selectorNames = selectors.toArray(new String[selectors.size()]); this.columns = columns; this.columnNames = columns.keySet().toArray(new String[columns.size()]); this.evaluator = evaluator; this.factory = factory; }
private Set<String> getSelectorNames(Source source) throws RepositoryException { if (source instanceof Selector) { Selector selector = (Selector) source; return Collections.singleton(selector.getSelectorName()); } else if (source instanceof Join) { Join join = (Join) source; Set<String> set = new LinkedHashSet<String>(); set.addAll(getSelectorNames(join.getLeft())); set.addAll(getSelectorNames(join.getRight())); return set; } else { throw new UnsupportedRepositoryOperationException( "Unknown source type: " + source); } }
private Set<String> getSelectorNames(Source source) throws RepositoryException { if (source instanceof Selector) { Selector selector = (Selector) source; return Collections.singleton(selector.getSelectorName()); } else if (source instanceof Join) { Join join = (Join) source; Set<String> set = new LinkedHashSet<String>(); set.addAll(getSelectorNames(join.getLeft())); set.addAll(getSelectorNames(join.getRight())); return set; } else { throw new UnsupportedRepositoryOperationException( "Unknown source type: " + source); } }
private Map<String, NodeType> getSelectorNames(Source source) throws RepositoryException { if (source instanceof Selector) { Selector selector = (Selector) source; return Collections.singletonMap(selector.getSelectorName(), getNodeType(selector)); } else if (source instanceof Join) { Join join = (Join) source; Map<String, NodeType> map = new LinkedHashMap<String, NodeType>(); map.putAll(getSelectorNames(join.getLeft())); map.putAll(getSelectorNames(join.getRight())); return map; } else { throw new UnsupportedRepositoryOperationException( "Unknown source type: " + source); } }
private Map<String, NodeType> getSelectorNames(Source source) throws RepositoryException { if (source instanceof Selector) { Selector selector = (Selector) source; return Collections.singletonMap(selector.getSelectorName(), getNodeType(selector)); } else if (source instanceof Join) { Join join = (Join) source; Map<String, NodeType> map = new LinkedHashMap<String, NodeType>(); map.putAll(getSelectorNames(join.getLeft())); map.putAll(getSelectorNames(join.getRight())); return map; } else { throw new UnsupportedRepositoryOperationException( "Unknown source type: " + source); } }
private Set<Row> buildLeftRowsJoin(ConstraintSplitInfo csi, Comparator<Row> comparator, int printIndentation) throws RepositoryException { if (csi.isMultiple()) { if (log.isDebugEnabled()) { log.debug(genString(printIndentation) + "SQL2 JOIN LEFT SIDE there are multiple inner splits."); } Set<Row> leftRows = new TreeSet<Row>(comparator); leftRows.addAll(buildLeftRowsJoin(csi.getLeftInnerConstraints(), comparator, printIndentation + printIndentStep)); leftRows.addAll(buildLeftRowsJoin(csi.getRightInnerConstraints(), comparator, printIndentation + printIndentStep)); return leftRows; } Set<Row> leftRows = new TreeSet<Row>(comparator); QueryResult leftResult = execute(null, csi.getSource().getLeft(), csi.getLeftConstraint(), null, 0, -1, printIndentation); for (Row row : JcrUtils.getRows(leftResult)) { leftRows.add(row); } return leftRows; }
private Set<Row> buildLeftRowsJoin(ConstraintSplitInfo csi, Comparator<Row> comparator, int printIndentation) throws RepositoryException { if (csi.isMultiple()) { if (log.isDebugEnabled()) { log.debug(genString(printIndentation) + "SQL2 JOIN LEFT SIDE there are multiple inner splits."); } Set<Row> leftRows = new TreeSet<Row>(comparator); leftRows.addAll(buildLeftRowsJoin(csi.getLeftInnerConstraints(), comparator, printIndentation + printIndentStep)); leftRows.addAll(buildLeftRowsJoin(csi.getRightInnerConstraints(), comparator, printIndentation + printIndentStep)); return leftRows; } Set<Row> leftRows = new TreeSet<Row>(comparator); QueryResult leftResult = execute(null, csi.getSource().getLeft(), csi.getLeftConstraint(), null, 0, -1, printIndentation); for (Row row : JcrUtils.getRows(leftResult)) { leftRows.add(row); } return leftRows; }
/** * 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); } }
private Constraint getAuthorizationConstraint(final HippoQueryObjectModelFactoryImpl factory, final Source source) throws RepositoryException { final Constraint constraint; if (source instanceof Join) { final Join join = (Join) source; final Constraint leftAuthorization = getAuthorizationConstraint(factory, join.getLeft()); final Constraint rightAuthorization = getAuthorizationConstraint(factory, join.getRight()); constraint = factory.and(leftAuthorization, rightAuthorization); } else { final Selector selector = (Selector) source; constraint = new AuthorizationConstraint(sessionContext, selector.getSelectorName()); } return constraint; }
"{} SQL2 RIGHT OUTER JOIN transformed to LEFT OUTER JOIN.", genString(printIndentation)); Join betterJoin = qomFactory.join(join.getRight(), join.getLeft(), JCR_JOIN_TYPE_LEFT_OUTER, join.getJoinCondition()); return execute(columns, betterJoin, constraint, orderings, offset,
"{} SQL2 RIGHT OUTER JOIN transformed to LEFT OUTER JOIN.", genString(printIndentation)); Join betterJoin = qomFactory.join(join.getRight(), join.getLeft(), JCR_JOIN_TYPE_LEFT_OUTER, join.getJoinCondition()); return execute(columns, betterJoin, constraint, orderings, offset,
private void append(Join join) { append(join.getLeft()); append(" "); appendJoinType(join.getJoinType()); append(" JOIN "); append(join.getRight()); append(" ON "); append(join.getJoinCondition()); }
private void append(Join join) { append(join.getLeft()); append(" "); appendJoinType(join.getJoinType()); append(" JOIN "); append(join.getRight()); append(" ON "); append(join.getJoinCondition()); }
private void append(Join join) { append(join.getLeft()); append(" "); appendJoinType(join.getJoinType()); append(" JOIN "); append(join.getRight()); append(" ON "); append(join.getJoinCondition()); }
@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()); }