Package org.modeshape.jcr.query.model

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


                    node.getSelectors().clear();
                    for (Ordering ordering : orderings) {
                        DynamicOperand operand = ordering.getOperand();
                        DynamicOperand newOperand = replaceViewReferences(context, operand, mappings, node);
                        if (newOperand != operand) {
                            ordering = new Ordering(newOperand, ordering.order(), ordering.nullOrder());
                        }
                        node.addSelectors(Visitors.getSelectorsReferencedBy(ordering));
                        newOrderings.add(ordering);
                    }
                    node.setProperty(Property.SORT_ORDER_BY, newOrderings);
View Full Code Here


    }

    protected Ordering ordering( DynamicOperand operand,
                                 Order order,
                                 NullOrder nullOrder ) {
        return new Ordering(operand, order, nullOrder);
    }
View Full Code Here

    @Test
    public void shouldParserOrderByWithOneOrdering() {
        List<Ordering> orderBy = parser.parseOrderBy(tokens("ORDER BY NAME(tableA) ASC"), typeSystem, mock(Source.class));
        assertThat(orderBy.size(), is(1));
        Ordering first = orderBy.get(0);
        assertThat(first.getOperand(), is(instanceOf(NodeName.class)));
        assertThat(first.order(), is(Order.ASCENDING));
    }
View Full Code Here

    public void shouldParserOrderByWithTwoOrderings() {
        List<Ordering> orderBy = parser.parseOrderBy(tokens("ORDER BY NAME(tableA) ASC, SCORE(tableB) DESC"),
                                                     typeSystem,
                                                     mock(Source.class));
        assertThat(orderBy.size(), is(2));
        Ordering first = orderBy.get(0);
        assertThat(first.getOperand(), is(instanceOf(NodeName.class)));
        assertThat(first.order(), is(Order.ASCENDING));
        Ordering second = orderBy.get(1);
        assertThat(second.getOperand(), is(instanceOf(FullTextSearchScore.class)));
        assertThat(second.order(), is(Order.DESCENDING));
    }
View Full Code Here

    public void shouldParserOrderByWithMultipleOrderings() {
        List<Ordering> orderBy = parser.parseOrderBy(tokens("ORDER BY NAME(tableA) ASC, SCORE(tableB) DESC, LENGTH(tableC.id) ASC"),
                                                     typeSystem,
                                                     mock(Source.class));
        assertThat(orderBy.size(), is(3));
        Ordering first = orderBy.get(0);
        assertThat(first.getOperand(), is(instanceOf(NodeName.class)));
        assertThat(first.order(), is(Order.ASCENDING));
        Ordering second = orderBy.get(1);
        assertThat(second.getOperand(), is(instanceOf(FullTextSearchScore.class)));
        assertThat(second.order(), is(Order.DESCENDING));
        Ordering third = orderBy.get(2);
        assertThat(third.getOperand(), is(instanceOf(Length.class)));
        assertThat(third.order(), is(Order.ASCENDING));
    }
View Full Code Here

    // parseOrdering
    // ----------------------------------------------------------------------------------------------------------------

    @Test
    public void shouldParseOrderingFromDynamicOperandFollowedByAscendingKeyword() {
        Ordering ordering = parser.parseOrdering(tokens("NAME(tableA) ASC"), typeSystem, mock(Source.class));
        assertThat(ordering.getOperand(), is(instanceOf(NodeName.class)));
        assertThat(ordering.order(), is(Order.ASCENDING));
    }
View Full Code Here

        assertThat(ordering.order(), is(Order.ASCENDING));
    }

    @Test
    public void shouldParseOrderingFromDynamicOperandFollowedByDecendingKeyword() {
        Ordering ordering = parser.parseOrdering(tokens("NAME(tableA) DESC"), typeSystem, mock(Source.class));
        assertThat(ordering.getOperand(), is(instanceOf(NodeName.class)));
        assertThat(ordering.order(), is(Order.DESCENDING));
    }
View Full Code Here

        assertThat(ordering.order(), is(Order.DESCENDING));
    }

    @Test
    public void shouldParseOrderingFromDynamicOperandAndDefaultToAscendingWhenNotFollowedByAscendingOrDescendingKeyword() {
        Ordering ordering = parser.parseOrdering(tokens("NAME(tableA) OTHER"), typeSystem, mock(Source.class));
        assertThat(ordering.getOperand(), is(instanceOf(NodeName.class)));
        assertThat(ordering.order(), is(Order.ASCENDING));
    }
View Full Code Here

TOP

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

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.