IReportRunnable template = openCached(templateName);
// Update report reference details
String title = nonNull((String)template.getProperty(IReportRunnable.TITLE), "No title");
String description = nonNull((String)template.getProperty(IReportRunnable.DESCRIPTION), "No description");
ReportReference reportRef = reports.get(templateName);
reportRef.setTitle(title);
reportRef.setDescription(description);
Map<String, Map<String,Serializable>> paramDetails =
new HashMap<String, Map<String, Serializable>>();
//Create Parameter Definition Task and retrieve parameter definitions
IGetParameterDefinitionTask task = engine.createGetParameterDefinitionTask( template );
Collection params = task.getParameterDefns( true );
//Iterate over each parameter
Iterator iter = params.iterator( );
while ( iter.hasNext( ) )
{
IParameterDefnBase param = (IParameterDefnBase) iter.next( );
if ( param instanceof IParameterGroupDefn )
{
IParameterGroupDefn group = (IParameterGroupDefn) param;
// Do something with the parameter group.
// Iterate over group contents.
Iterator i2 = group.getContents( ).iterator( );
while ( i2.hasNext( ) )
{
IScalarParameterDefn scalar = (IScalarParameterDefn) i2.next( );
//Get details on the parameter
paramDetails.put( scalar.getName(), BirtUtil.loadParameterDetails( task, scalar, template, group));
}
}
else
{
IScalarParameterDefn scalar = (IScalarParameterDefn) param;
//get details on the parameter
paramDetails.put( scalar.getName(), BirtUtil.loadParameterDetails( task, scalar, template, null));
}
// cleanup
task.close();
}
// update ReportReference.parameters
ReportReference ref = reports.get(templateName);
Iterator<String> paramNames = paramDetails.keySet().iterator();
while(paramNames.hasNext())
{
Map<String, Serializable> map = paramDetails.get(paramNames.next());
ReportParameter paramRef = new ReportParameter(
(String)map.get("Name"), ReportParameter.Type.valueOf((String)map.get("Type"))
);
paramRef.setDataType(ReportParameter.DataType.valueOf((String)map.get("DataType")));
paramRef.setHelptext((String)map.get("Help Text"));
paramRef.setPromptText((String)map.get("Prompt Text"));
ref.getParameterMetaData().add(paramRef);
}
}