use of com.developmentontheedge.sql.model.AstSelectList in project be5 by DevelopmentOnTheEdge.
the class ColumnsApplier method keepOnlyOutColumns.
public void keepOnlyOutColumns(AstBeSqlSubQuery subQuery) {
List<String> outColumns = Arrays.asList(subQuery.getOutColumns().split(","));
AstSelect select = (AstSelect) subQuery.getQuery().child(0);
AstSelectList selectList = select.getSelectList();
if (selectList.isAllColumns()) {
throw new IllegalStateException("All columns not support " + selectList.getNodeContent());
} else {
for (int i = selectList.jjtGetNumChildren() - 1; i >= 0; i--) {
AstDerivedColumn derivedColumn = (AstDerivedColumn) selectList.jjtGetChild(i);
if (!outColumns.contains(derivedColumn.getAlias().replace("\"", ""))) {
derivedColumn.remove();
}
}
}
}
Aggregations