Package org.jboss.dna.graph.query.QueryBuilder

Examples of org.jboss.dna.graph.query.QueryBuilder.OrderByBuilder


        where.end();

        // Process the order-by clause ...
        OrderBy orderBy = pathExpression.getOrderBy();
        if (orderBy != null) {
            OrderByBuilder orderByBuilder = builder.orderBy();
            for (OrderBySpec spec : orderBy) {
                OrderByOperandBuilder operandBuilder = null;
                switch (spec.getOrder()) {
                    case ASCENDING:
                        operandBuilder = orderByBuilder.ascending();
                        break;
                    case DESCENDING:
                        operandBuilder = orderByBuilder.descending();
                        break;
                }
                assert operandBuilder != null;
                if (spec.getAttributeName() != null) {
                    // This order by is defined by an attribute ...
                    NameTest attribute = spec.getAttributeName();
                    assert !attribute.isWildcard();
                    operandBuilder.propertyValue(tableName, attribute.toString());
                    builder.select(tableName + "." + attribute.toString());
                } else {
                    // This order-by is defined by a "jcr:score" function ...
                    FunctionCall scoreFunction = spec.getScoreFunction();
                    assert scoreFunction != null;
                    List<Component> args = scoreFunction.getParameters();
                    String nameOfTableToScore = tableName;
                    if (!args.isEmpty()) {
                        if (args.size() == 1 && args.get(0) instanceof NameTest) {
                            // Just the table name ...
                            NameTest tableNameTest = (NameTest)args.get(0);
                            nameOfTableToScore = tableNameTest.toString();
                        }
                    }
                    operandBuilder.fullTextSearchScore(nameOfTableToScore);
                }
            }
            orderByBuilder.end();
        }
        // Try building this query, because we need to check the # of columns selected and the # of sources ...
        Query query = (Query)builder.query();
        if (query.getColumns().isEmpty() && query.getSource() instanceof AllNodes) {
            // This is basically 'SELECT * FROM __ALLNODES__", which means that no type was explicitly specified and
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.query.QueryBuilder.OrderByBuilder

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.