// first tree of them without collection navigation
Map fields = sqvv.getFields();
QueryBuilder qb = sqvv.getQueryBuilder();
QueryTree qt = sqvv.getQueryTree();
SelectProject sp = new SelectProject("");
if (!filter.equals("(true)") && !filter.equals("true")) {
//Ther is a filter and potentialy collection navigation
if (debug) {
logger.log(BasicLevel.DEBUG, "filter = " + qd.filter);
}
// start the query filter visitor, to build and expression tree of
// the filter expression
SpeedoQLQueryFilterVisitor sqfv = new SpeedoQLQueryFilterVisitor(
fields, sp, (ASTSpeedoQL) node,
filterParserLogger, hparams, hvars,
qd.candidateClass,
qb, jf);
sp.setQueryFilter(sqfv.getQueryFilter());
}
assignMapper(sp);
assignMapper(qt);
JDOQueryEvalContext qec = new JDOQueryEvalContext(sp, this);
SelectGroupByVisitor sgv = new SelectGroupByVisitor(
sp, qt, mapper, sqvv, qec, classLoader);
sgv.visit(qd);
selectedFieldTypes = sgv.getSelectFieldTypes();
assignMapper(qec.query);
//Specify the ordering
if (qd.order != null && qd.order.size() > 0) {
OrderField[] ofs = new OrderField[qd.order.size()];
for(int i=0; i<ofs.length; i++) {
String o = (String) qd.order.get(i);
int idx = o.indexOf(' ');
boolean desc = false;
if (idx != -1) {
desc = o.substring(idx + 1).trim().equals("descending");
o = o.substring(0, idx);
}
o = "this." + o;
ofs[i] = new BasicOrderField((QueryTreeField)
qt.getTupleStructure().getField(o), desc);
}
sp.setOrderBy(ofs);
}
logger.log(BasicLevel.INFO, "QueryTree built");
if (debug) {
QueryTreePrinter.printQueryTree(qec.query, logger);
}
//check for the use of the userCache
if (qd.result == null && qd.variables == null) {
//no variable used and the result is the candidate class
Map field2value = new HashMap();
if (getFieldComparaison(sp.getQueryFilter(), field2value)) {
HomeItf sh = null;
try {
sh = (HomeItf) jf.getPClassMapping(
qd.candidateClass.getName(),
classLoader);