Package org.modeshape.jcr.query.model

Examples of org.modeshape.jcr.query.model.Join


                context.getProblems().addError(GraphI18n.tableDoesNotExist, selector.name());
            }
            return node;
        }
        if (source instanceof Join) {
            Join join = (Join)source;
            JoinCondition joinCondition = join.getJoinCondition();
            // Set up new join node corresponding to this join predicate
            PlanNode node = new PlanNode(Type.JOIN);
            node.setProperty(Property.JOIN_TYPE, join.type());
            node.setProperty(Property.JOIN_ALGORITHM, JoinAlgorithm.NESTED_LOOP);
            node.setProperty(Property.JOIN_CONDITION, joinCondition);

            context.getHints().hasJoin = true;
            if (join.type() == JoinType.LEFT_OUTER) {
                context.getHints().hasOptionalJoin = true;
            }

            // Handle each child
            Source[] clauses = new Source[] {join.getLeft(), join.getRight()};
            for (int i = 0; i < 2; i++) {
                PlanNode sourceNode = createPlanNode(context, clauses[i], usedSelectors);
                node.addLastChild(sourceNode);
            }
View Full Code Here


            SelectorName selector1 = joinCondition.selector1Name();
            SelectorName selector2 = joinCondition.selector2Name();
            boolean found = false;
            ListIterator<Join> iter = joins.listIterator();
            while (iter.hasNext()) {
                Join next = iter.next();
                Join replacement = null;
                if (usesSelector(next, selector1)) {
                    Source right = joinableSources.getSelectors().get(selector2.name());
                    replacement = new Join(next, JoinType.INNER, right, joinCondition);
                } else if (usesSelector(next, selector2)) {
                    Source left = joinableSources.getSelectors().get(selector1.name());
                    replacement = new Join(left, JoinType.INNER, next, joinCondition);
                }
                if (replacement != null) {
                    iter.previous();
                    iter.remove();
                    joins.add(replacement);
                    found = true;
                    break;
                }
            }
            if (!found) {
                // Nothing matched, so add a new join ...
                Source left = joinableSources.getSelectors().get(selector1.name());
                Source right = joinableSources.getSelectors().get(selector2.name());
                if (left == null) {
                    Position pos = joinableSources.getJoinCriteriaPosition();
                    String msg = JcrI18n.selectorUsedInEquiJoinCriteriaDoesNotExistInQuery.text(selector1.name(),
                                                                                                pos.getLine(),
                                                                                                pos.getColumn());
                    throw new ParsingException(pos, msg);
                }
                if (right == null) {
                    Position pos = joinableSources.getJoinCriteriaPosition();
                    String msg = JcrI18n.selectorUsedInEquiJoinCriteriaDoesNotExistInQuery.text(selector2.name(),
                                                                                                pos.getLine(),
                                                                                                pos.getColumn());
                    throw new ParsingException(pos, msg);
                }
                joins.add(new Join(left, JoinType.INNER, right, joinCondition));
            }
        }
        if (joins.size() == 1) {
            return joins.get(0);
        }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.query.model.Join

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.