temporaryComputedColumns.add( new ComputedColumn( "_{$TEMP_GROUP_" + i + "$}_",
temporaryComputedColumns.add( new ComputedColumn( groupName,
	protected void populateOdiQuery( ) throws DataException	{		assert odiQuery != null;		assert this.baseQueryDefn != null;				Context cx = Context.enter();		try		{			// Set grouping			List groups = this.baseQueryDefn.getGroups();			if ( groups != null && ! groups.isEmpty() )			{				IQuery.GroupSpec[] groupSpecs = new IQuery.GroupSpec[ groups.size() ];				Iterator it = groups.iterator();				for ( int i = 0; it.hasNext(); i++ )				{					IGroupDefinition src = (IGroupDefinition) it.next();										if( (src.getKeyColumn( ) == null || src.getKeyColumn( ).trim( ).length( ) == 0)&&						(src.getKeyExpression( ) == null || src.getKeyExpression( ).trim( ).length( ) == 0)	)						throw new DataException( ResourceConstants.BAD_GROUP_EXPRESSION );					//TODO does the index of column significant?					IQuery.GroupSpec dest = QueryExecutorUtil.groupDefnToSpec( cx,							src,							"_{$TEMP_GROUP_" + i + "$}_",							-1 );					groupSpecs[i] = dest;					String expr = src.getKeyColumn();					if( expr == null )					{						expr = src.getKeyExpression();					}else					{						expr = getColumnRefExpression(expr);					}										temporaryComputedColumns.add( new ComputedColumn( "_{$TEMP_GROUP_"						+ i + "$}_",						expr,						QueryExecutorUtil.getTempComputedColumnType( groupSpecs[i].getInterval( ) ) ) );				}				odiQuery.setGrouping( Arrays.asList( groupSpecs));			}					// Set sorting			List sorts = this.baseQueryDefn.getSorts();			if ( sorts != null && !sorts.isEmpty( ) )			{				IQuery.SortSpec[] sortSpecs = new IQuery.SortSpec[ sorts.size() ];				Iterator it = sorts.iterator();				for ( int i = 0; it.hasNext(); i++ )				{					ISortDefinition src = (ISortDefinition) it.next();					int sortIndex = -1;					String sortKey = src.getColumn();					if( sortKey == null )						sortKey = src.getExpression().getText();					else 					{						sortKey = getColumnRefExpression(sortKey);					}					temporaryComputedColumns.add(new ComputedColumn( "_{$TEMP_SORT_"+i+"$}_", sortKey, DataType.ANY_TYPE));					sortIndex = -1; 					sortKey = String.valueOf("_{$TEMP_SORT_"+i+"$}_");										IQuery.SortSpec dest = new IQuery.SortSpec( sortIndex,							sortKey,							src.getSortDirection( ) == ISortDefinition.SORT_ASC );					sortSpecs[i] = dest;				}				odiQuery.setOrdering( Arrays.asList( sortSpecs));			}			// set filter event		    List dataSetFilters = new ArrayList( );		    List queryFilters = new ArrayList( );		    if ( dataSet.getFilters( ) != null )			{				dataSetFilters = dataSet.getFilters( );			}		    		    if ( this.baseQueryDefn.getFilters( ) != null )			{		    	queryFilters = this.baseQueryDefn.getFilters( );			}		    		    //When prepare filters, the temporaryComputedColumns would also be effect.		    List multipassFilters = prepareFilters( cx, dataSetFilters, queryFilters, temporaryComputedColumns );		   		   			  		    //******************populate the onFetchEvent below**********************/		    		    List computedColumns = null;		    // set computed column event			computedColumns = this.dataSet.getComputedColumns( );			if ( computedColumns == null )				computedColumns = new ArrayList();			if ( computedColumns.size() > 0 || temporaryComputedColumns.size( ) > 0 )			{				IResultObjectEvent objectEvent = new ComputedColumnHelper( this.dataSet, computedColumns, temporaryComputedColumns);				odiQuery.addOnFetchEvent( objectEvent );				this.dataSet.getComputedColumns().addAll(temporaryComputedColumns);			}	    	if ( dataSet.getEventHandler() != null )	    	{	    		OnFetchScriptHelper event = new OnFetchScriptHelper( dataSet ); 	    		odiQuery.addOnFetchEvent( event );		    }	    			    if ( dataSetFilters.size( ) + queryFilters.size( ) + multipassFilters.size() > 0 )		    {		    	IResultObjectEvent objectEvent = new FilterByRow( dataSetFilters, queryFilters, multipassFilters,		    			dataSet );		    	odiQuery.addOnFetchEvent( objectEvent );		    }		    			// specify max rows the query should fetch		    odiQuery.setMaxRows( this.baseQueryDefn.getMaxRows() );		}		finally		{			Context.exit();		}	}