raq.addPartialAttribute(((SelectionImpl)selection).currentNode);
}
query = raq;
}else{
if (this.roots == null || this.roots.isEmpty()) throw new IllegalStateException(ExceptionLocalization.buildMessage("CRITERIA_NO_ROOT_FOR_COMPOUND_QUERY"));
ReportQuery reportQuery = null;
if (this.queryResult.equals(ResultType.CONSTRUCTOR)){
reportQuery = new ReportQuery();
reportQuery.addConstructorReportItem(((ConstructorSelectionImpl)this.selection).translate());
reportQuery.setShouldReturnSingleAttribute(true);
}else {
if (this.queryResult.equals(ResultType.TUPLE)){
reportQuery = new TupleQuery(this.selection==null?new ArrayList():this.selection.getCompoundSelectionItems());
}else{
reportQuery = new ReportQuery();
reportQuery.setShouldReturnWithoutReportQueryResult(true);
}
if (this.selection != null){
if (this.selection.isCompoundSelection()){
for (Selection nested: this.selection.getCompoundSelectionItems()){
if (((SelectionImpl)nested).isCompoundSelection()){
reportQuery.addConstructorReportItem(((ConstructorSelectionImpl)nested).translate());
}else{
reportQuery.addItem(nested.getAlias(), ((SelectionImpl)nested).getCurrentNode());
}
}
}else{
reportQuery.addAttribute(this.selection.getAlias(), ((SelectionImpl)this.selection).getCurrentNode(), ((SelectionImpl)this.selection).getJavaType());
}
}
}
if (this.where != null && ((InternalSelection)this.where).getCurrentNode() != null){
reportQuery.setReferenceClass(((InternalSelection)this.where).getCurrentNode().getBuilder().getQueryClass());
reportQuery.setExpressionBuilder(((InternalSelection)this.where).getCurrentNode().getBuilder());
}else{
Root root = this.getRoots().iterator().next();
reportQuery.setReferenceClass(root.getJavaType());
reportQuery.setExpressionBuilder(((RootImpl)root).getCurrentNode().getBuilder());
}
query = reportQuery;
}
if (this.where != null){
query.setSelectionCriteria(((InternalSelection)this.where).getCurrentNode());