Package org.modeshape.jcr.query.model

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


    @Test
    public void shouldParseConstraintFromStringWithOuterParentheses() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("( ISSAMENODE('/a/b') )"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)constraint;
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b"));
    }
View Full Code Here


    @Test
    public void shouldParseConstraintFromStringWithMultipleOuterParentheses() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("((( ISSAMENODE('/a/b') )))"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)constraint;
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b"));
    }
View Full Code Here

                                                       selector);
        assertThat(constraint, is(instanceOf(Or.class)));
        Or or = (Or)constraint;

        assertThat(or.left(), is(instanceOf(SameNode.class)));
        SameNode first = (SameNode)or.left();
        assertThat(first.selectorName(), is(selectorName("tableA")));
        assertThat(first.getPath(), is("/a/b"));

        assertThat(or.right(), is(instanceOf(And.class)));
        And and = (And)or.right();

        assertThat(and.left(), is(instanceOf(SameNode.class)));
        SameNode second = (SameNode)and.left();
        assertThat(second.selectorName(), is(selectorName("tableA")));
        assertThat(second.getPath(), is("/c/d"));

        assertThat(and.right(), is(instanceOf(SameNode.class)));
        SameNode third = (SameNode)and.right();
        assertThat(third.selectorName(), is(selectorName("tableA")));
        assertThat(third.getPath(), is("/e/f"));
    }
View Full Code Here

                                                       selector);
        assertThat(constraint, is(instanceOf(And.class)));
        And and = (And)constraint;

        assertThat(and.left(), is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)and.left();
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b/c"));

        assertThat(and.right(), is(instanceOf(FullTextSearch.class)));
        FullTextSearch search = (FullTextSearch)and.right();
        assertThat(search.selectorName(), is(selectorName("tableA")));
        assertThat(search.getPropertyName(), is("p1"));
View Full Code Here

                                                       selector);
        assertThat(constraint, is(instanceOf(And.class)));
        And and = (And)constraint;

        assertThat(and.left(), is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)and.left();
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b/c"));

        assertThat(and.right(), is(instanceOf(And.class)));
        And secondAnd = (And)and.right();

        assertThat(secondAnd.left(), is(instanceOf(FullTextSearch.class)));
View Full Code Here

        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b/c') OR CONTAINS(p1,term1)"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(Or.class)));
        Or or = (Or)constraint;

        assertThat(or.left(), is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)or.left();
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b/c"));

        assertThat(or.right(), is(instanceOf(FullTextSearch.class)));
        FullTextSearch search = (FullTextSearch)or.right();
        assertThat(search.selectorName(), is(selectorName("tableA")));
        assertThat(search.getPropertyName(), is("p1"));
View Full Code Here

    public void shouldParseConstraintFromStringWithNotSameNodeExpression() {
        Constraint constraint = parser.parseConstraint(tokens("NOT(ISSAMENODE(tableA,'/a/b/c'))"), typeSystem, mock(Source.class));
        assertThat(constraint, is(instanceOf(Not.class)));
        Not not = (Not)constraint;
        assertThat(not.getConstraint(), is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)not.getConstraint();
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b/c"));
    }
View Full Code Here

    @Test
    public void shouldParseConstraintFromStringWithIsSameNodeExpressionWithPathOnlyIfThereIsOneSelectorSource() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b/c')"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)constraint;
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b/c"));
    }
View Full Code Here

    @Test
    public void shouldParseConstraintFromStringWithIsSameNodeExpressionWithSelectorNameAndPath() {
        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE(tableA,'/a/b/c')"), typeSystem, mock(Source.class));
        assertThat(constraint, is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)constraint;
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b/c"));
    }
View Full Code Here

                    return "(filter " + Visitors.readable(constraint) + ")";
                }
            };
        }
        if (constraint instanceof SameNode) {
            SameNode sameNode = (SameNode)constraint;
            PathFactory paths = context.getExecutionContext().getValueFactories().getPathFactory();
            final Path path = paths.create(sameNode.getPath());
            final NodeCache cache = context.getNodeCache(sources.getWorkspaceName());
            final CachedNode node = sources.getNodeAtPath(path, cache);
            if (node == null) {
                return NodeSequence.NO_PASS_ROW_FILTER;
            }
            final NodeKey nodeKey = node.getKey();
            final String selectorName = sameNode.getSelectorName();
            final int index = columns.getSelectorIndex(selectorName);
            return new RowFilter() {
                @Override
                public boolean isCurrentRowValid( Batch batch ) {
                    CachedNode node = batch.getNode(index);
View Full Code Here

TOP

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

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.