private static void planQueryWithCriteria(MappingSourceNode contextNode, XMLPlannerEnvironment planEnv)
throws QueryPlannerException, TeiidComponentException, QueryMetadataException, QueryResolverException {
Map symbolMap = new HashMap();
ResultSetInfo rsInfo = contextNode.getResultSetInfo();
// this list of all the source nodes below the context, which are directly ro indirectly
// involved in the criteria
LinkedHashSet resultSets = new LinkedHashSet();
boolean singleParentage = getResultSets(contextNode, rsInfo.getCriteriaResultSets(), resultSets);
Query contextQuery = null;
if (rsInfo.isCriteriaRaised()) {
contextQuery = (Query)QueryUtil.getQueryFromQueryNode(rsInfo.getResultSetName(), planEnv);
String inlineViewName = planEnv.getAliasName(rsInfo.getResultSetName());
updateSymbolMap(symbolMap, rsInfo.getResultSetName(), inlineViewName, planEnv.getGlobalMetadata());
} else {
contextQuery = (Query)rsInfo.getCommand();
}
Query currentQuery = contextQuery;
for (Iterator i = resultSets.iterator(); i.hasNext();) {
MappingSourceNode rsNode = (MappingSourceNode)i.next();
ResultSetInfo childRsInfo = rsNode.getResultSetInfo();
QueryNode planNode = QueryUtil.getQueryNode(childRsInfo.getResultSetName(), planEnv.getGlobalMetadata());
Command command = QueryUtil.getQuery(childRsInfo.getResultSetName(), planNode, planEnv);
String inlineViewName = planEnv.getAliasName(childRsInfo.getResultSetName());
updateSymbolMap(symbolMap, childRsInfo.getResultSetName(), inlineViewName, planEnv.getGlobalMetadata());
// check if the criteria has been raised, if it is then we can update this as a join.
if (childRsInfo.isCriteriaRaised()) {
Query transformationQuery = (Query) command;
SubqueryFromClause sfc = (SubqueryFromClause)transformationQuery.getFrom().getClauses().get(0);
Criteria joinCriteria = ((Query)childRsInfo.getCommand()).getCriteria();
if (joinCriteria == null) {
joinCriteria = QueryRewriter.TRUE_CRITERIA;
}