Bug 319902 Internal API Usage of the ODA framework components
data/org.eclipse.birt.report.data.oda.jdbc.dbprofile.ui/src/org/eclipse/birt/report/data/oda/jdbc/dbprofile/ui/internal/sqb/SQLQueryUtility.java
if( ! (valueExpr instanceof ValueExpressionColumn) )
            return valueExpr.getSQL();
        String columnName = valueExpr.getName();    
        
        QueryExpressionRoot qRoot = selectStmt.getQueryExpr();
        QueryExpressionBody qBody = qRoot != null ? qRoot.getQuery() : null;
        
         
        
        ResultColumn resultColumn = TableHelper.getResultColumnForAliasOrColumnName( qBody, columnName );
        if( resultColumn != null && resultColumn.getName() != null )
            return resultColumn.getName();  
        return columnName;
    }
    
    
    private static String resolveResultColumnOrdinal( int ordinal, final ResultSetDefinition resultSetDefn )
        throws OdaException
    {        
        if( ordinal <= 0 ||     
                ordinal > resultSetDefn.getResultSetColumns().getResultColumnDefinitions().size() )  
            return EMPTY_STRING;
        
        ColumnDefinition columnDefn =
            resultSetDefn.getResultSetColumns().getResultColumnDefinitions().get( ordinal - 1 );   
        return ( columnDefn != null && columnDefn.getAttributes().getPosition() == ordinal ) ? 
                columnDefn.getAttributes().getName() : EMPTY_STRING;
    }
    
    @SuppressWarnings("unchecked")