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