}
private SpiMetaQuery newsetupByVisitingTreeImpl(String query, String targetTable, MetaLoader mgr, String errorMsg) {
SpiMetaQueryImpl spiMetaQuery = factory.get();
InfoForWiring wiring = new InfoForWiring(query, targetTable);
MetaFacade facade = new MetaFacadeImpl(mgr, metaInfo);
ExpressionNode newTree = compiler.compileSql(query, wiring, facade);
List<ViewInfo> allViews = wiring.getAllViews();
List<ViewInfo> joinedViews = wiring.getJoinedViews();
List<ViewInfo> notYetJoinedViews = new ArrayList<ViewInfo>();
for(ViewInfo view : allViews) {
if(!joinedViews.contains(view))
notYetJoinedViews.add(view);
}
spiMetaQuery.setASTTree(newTree, joinedViews, notYetJoinedViews);
spiMetaQuery.setQuery(query);
spiMetaQuery.setParameterFieldMap(wiring.getParameterFieldMap());
spiMetaQuery.setUpdateList(wiring.getUpdateList());
spiMetaQuery.setQueryType(wiring.getQueryType());
return spiMetaQuery;
}