executionContext.getReportContext(), executionContext.getSharedScope() );
executionContext, executionContext.getSharedScope( ) );
	private Collection createDynamicSelectionChoices( String dataSetName,			String labelStmt, String valueStmt, String dataType, int limit,			boolean fixedOrder )	{		ArrayList choices = new ArrayList( );		ReportDesignHandle report = ( ReportDesignHandle ) this.runnable				.getDesignHandle( );		DataSetHandle dataSet = report.findDataSet( dataSetName );		if ( dataSet != null )		{			try			{				DataEngine dataEngine = getDataEngine( );				// Define data source and data set				DataSourceHandle dataSource = dataSet.getDataSource( );				ModelDteApiAdapter adaptor = new ModelDteApiAdapter(						executionContext.getReportContext(), 						executionContext.getSharedScope() );				try				{					dataEngine.defineDataSource( adaptor.createDataSourceDesign( dataSource));					dataEngine.defineDataSet( adaptor.createDataSetDesign( dataSet));				} catch ( BirtException e )				{					log.log( Level.SEVERE, e.getMessage( ) );				}				ScriptExpression labelExpr = null;				if ( labelStmt != null && labelStmt.length( ) > 0 )				{					labelExpr = new ScriptExpression( labelStmt );				}				ScriptExpression valueExpr = new ScriptExpression( valueStmt );				QueryDefinition queryDefn = new QueryDefinition( );				queryDefn.setDataSetName( dataSetName );				// add parameters if have any				Iterator paramIter = dataSet.paramBindingsIterator( );				while ( paramIter.hasNext( ) )				{					ParamBindingHandle binding = ( ParamBindingHandle ) paramIter							.next( );					String paramName = binding.getParamName( );					String paramExpr = binding.getExpression( );					queryDefn.getInputParamBindings( ).add(							new InputParameterBinding( paramName,									new ScriptExpression( paramExpr ) ) );				}				if ( labelExpr != null )				{					queryDefn.getRowExpressions( ).add( labelExpr );				}				queryDefn.getRowExpressions( ).add( valueExpr );				// Create a group to skip all of the duplicate values				GroupDefinition groupDef = new GroupDefinition( );				groupDef.setKeyExpression( valueStmt );				queryDefn.addGroup( groupDef );				IPreparedQuery query = dataEngine.prepare( queryDefn );				IQueryResults result = query.execute( executionContext						.getSharedScope( ) );				IResultIterator iter = result.getResultIterator( );				int count = 0;				while ( iter.next( ) )				{					String label = null;					if ( labelExpr != null )					{						label = iter.getString( labelExpr );					}					Object value = iter.getValue( valueExpr );					choices.add( new SelectionChoice( label, convertToType(							value, dataType ) ) );					count++;					if ( ( limit != 0 ) && ( count >= limit ) )					{						break;					}					iter.skipToEnd( 1 ); // Skip all of the duplicate values				}			} catch ( BirtException ex )			{				ex.printStackTrace( );			}		}		if ( !fixedOrder )			Collections.sort( choices, new SelectionChoiceComparator( true ) );		return choices;	}