Package org.modeshape.jcr.query.model

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


            return addOrdering(new ChildCount(selector(table)));
        }

        @Override
        public OrderByBuilder depth( String table ) {
            return addOrdering(new NodeDepth(selector(table)));
        }
View Full Code Here


            SelectorName replacement = rewrittenSelectors.get(value.selectorName());
            if (replacement == null) return operand;
            return new ReferenceValue(replacement, value.getPropertyName());
        }
        if (operand instanceof NodeDepth) {
            NodeDepth depth = (NodeDepth)operand;
            SelectorName replacement = rewrittenSelectors.get(depth.selectorName());
            if (replacement == null) return operand;
            return new NodeDepth(replacement);
        }
        if (operand instanceof NodePath) {
            NodePath path = (NodePath)operand;
            SelectorName replacement = rewrittenSelectors.get(path.selectorName());
            if (replacement == null) return operand;
View Full Code Here

            if (sourceColumn == null) return value;
            node.addSelector(sourceColumn.selectorName());
            return new ReferenceValue(sourceColumn.selectorName(), sourceColumn.getPropertyName());
        }
        if (operand instanceof NodeDepth) {
            NodeDepth depth = (NodeDepth)operand;
            if (!mapping.getOriginalName().equals(depth.selectorName())) return depth;
            if (!mapping.isMappedToSingleSelector()) return depth;
            node.addSelector(mapping.getSingleMappedSelectorName());
            return new NodeDepth(mapping.getSingleMappedSelectorName());
        }
        if (operand instanceof NodePath) {
            NodePath path = (NodePath)operand;
            if (!mapping.getOriginalName().equals(path.selectorName())) return path;
            if (!mapping.isMappedToSingleSelector()) return path;
View Full Code Here

            }
            if ("mode:localName".equals(property) || "jcr:localName".equals(property)) {
                return new NodeLocalName(propValue.selectorName());
            }
            if ("mode:depth".equals(property) || "jcr:depth".equals(property)) {
                return new NodeDepth(propValue.selectorName());
            }
            if ("mode:id".equals(property)) {
                return new NodeId(propValue.selectorName());
            }
            if ("jcr:score".equals(property)) {
View Full Code Here

                    return "(uppercase " + delegate + ")";
                }
            };
        }
        if (operand instanceof NodeDepth) {
            final NodeDepth nodeDepth = (NodeDepth)operand;
            final int indexInRow = columns.getSelectorIndex(nodeDepth.getSelectorName());
            final NodeCache cache = context.getNodeCache(sources.getWorkspaceName());
            final TypeFactory<?> longType = context.getTypeSystem().getLongFactory();
            return new ExtractFromRow() {
                @Override
                public TypeFactory<?> getType() {
                    return longType; // depth is always a long type
                }

                @Override
                public Object getValueInRow( RowAccessor row ) {
                    CachedNode node = row.getNode(indexInRow);
                    if (node == null) return null;
                    return new Long(node.getDepth(cache));
                }

                @Override
                public String toString() {
                    return "(nodeDepth " + nodeDepth.getSelectorName() + ")";
                }
            };
        }
        if (operand instanceof ChildCount) {
            final ChildCount childCount = (ChildCount)operand;
View Full Code Here

    protected NodeLocalName nodeLocalName( SelectorName selector ) {
        return new NodeLocalName(selector);
    }

    protected NodeDepth nodeDepth( SelectorName selector ) {
        return new NodeDepth(selector);
    }
View Full Code Here

            return comparisonBuilder(new ChildCount(selector(table)));
        }

        @Override
        public ComparisonBuilder depth( String table ) {
            return comparisonBuilder(new NodeDepth(selector(table)));
        }
View Full Code Here

         * @param table the name of the table; may not be null and must refer to a valid name or alias of a table appearing in the
         *        FROM clause
         * @return the interface for completing the value portion of the criteria specification; never null
         */
        public ComparisonBuilder depth( String table ) {
            return comparisonBuilder(new NodeDepth(selector(table)));
        }
View Full Code Here

    @Test
    public void shouldParseDynamicOperandFromStringContainingDepthOfSelector() {
        DynamicOperand operand = parser.parseDynamicOperand(tokens("DEPTH(tableA)"), typeSystem, mock(Source.class));
        assertThat(operand, is(instanceOf(NodeDepth.class)));
        NodeDepth depth = (NodeDepth)operand;
        assertThat(depth.selectorName(), is(selectorName("tableA")));
    }
View Full Code Here

    @Test
    public void shouldParseDynamicOperandFromStringContainingDepthWithNoSelectorOnlyIfThereIsOneSelectorAsSource() {
        Source source = new NamedSelector(selectorName("tableA"));
        DynamicOperand operand = parser.parseDynamicOperand(tokens("DEPTH()"), typeSystem, source);
        assertThat(operand, is(instanceOf(NodeDepth.class)));
        NodeDepth depth = (NodeDepth)operand;
        assertThat(depth.selectorName(), is(selectorName("tableA")));
    }
View Full Code Here

TOP

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

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.