Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Getting parameters and setting them so report engine can render report
Getting parameters and setting them so report engine can render report [message #152385] Mon, 10 April 2006 22:41 Go to next message
Mike Boyersmith is currently offline Mike BoyersmithFriend
Messages: 143
Registered: July 2009
Senior Member
So I have gathered my promptable parameters from my report and shown
them in a UI and gotten input from the user. I however I'm at a lost as
to what to do next.

heres my code

IReportRunnable report = reportEngine.openReportDesign(strReportPath);
ModuleHandle MH = eport.getDesignHandle().getModule().getModuleHandle();
List parameters = MH.getFlattenParameters()
//...process the parameter list in a UI
//
//HELP HERE.....I somehow have to get these parameters in My UI assigned
// so report engine will use them
//
IRunAndRenderTask task = reportEngine.createRunAndRenderTask(report);
// generate the report
task.run();


At the moment when I go to run I get the following

org.eclipse.birt.report.engine.api.EngineException: Some required
parameter values are not set or set to incompatible data type.


Whats the glue piece I need here to get my prompting parameters assigned
in a way the report task will work with?
Re: Getting parameters and setting them so report engine can render report [message #152412 is a reply to message #152385] Tue, 11 April 2006 02:25 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

You have two options.
Use the task.setParmaeterValue(ParameterName, Value) Value is Object type
or
task.setParameterValues(parameterMap) /* just a map of name value pairs.

BTW you can use the engine api to retrieve the parameters as well.

I used the following two functions to print out all the parameter info
May be more than you want.

Jason



//info only method
public Hashtable getParameterDetails() throws Exception{
Hashtable parmDetails = new Hashtable();

try{
IGetParameterDefinitionTask task =
this.birtReportEngine.createGetParameterDefinitionTask(
this.currentBirtReport );
Collection params = task.getParameterDefns( true );


Iterator iter = params.iterator( );
while ( iter.hasNext( ) )
{
IParameterDefnBase param = (IParameterDefnBase) iter.next( );

if ( param instanceof IParameterGroupDefn )
{
IParameterGroupDefn group = (IParameterGroupDefn) param;
Iterator i2 = group.getContents( ).iterator( );
while ( i2.hasNext( ) )
{
IScalarParameterDefn scalar = (IScalarParameterDefn)
i2.next( );
//System.out.println("\t" + scalar.getName());
parmDetails.put( scalar.getName(), loadParameterDetails( task,
scalar, group));
}

}
else
{

IScalarParameterDefn scalar = (IScalarParameterDefn) param;
//System.out.println(param.getName());
parmDetails.put( scalar.getName(),loadParameterDetails( task,
scalar, null));

}
}

task.close();
} catch (Exception e1) {
logger.log( Level.SEVERE, e1.getMessage());
throw new Exception(e1);
}
return parmDetails;
}


private Hashtable loadParameterDetails(IGetParameterDefinitionTask task,
IScalarParameterDefn scalar, IParameterGroupDefn group) throws Exception{


Hashtable parameter = new Hashtable();
try{
if( group == null){
group = new ParameterGroupDefn();
}
if( scalar == null ){
scalar = new ScalarParameterDefn();
}
parameter.put("Parameter Group", checkIsNull(group.getName()));
parameter.put("Name", checkIsNull(scalar.getName()));
parameter.put("Help Text", checkIsNull(scalar.getHelpText()));
parameter.put("Display Name", checkIsNull(scalar.getDisplayName()));
//this is a format code such as > for UPPERCASE
parameter.put("Display Format", checkIsNull(scalar.getDisplayFormat()));

if( scalar.isHidden() ){
parameter.put("Hidden", "Yes");
}else{
parameter.put("Hidden", "No");
}
if( scalar.allowBlank() ){
parameter.put("Allow Blank", "Yes");
}else{
parameter.put("Allow Blank", "No");
}
if( scalar.allowNull() ){
parameter.put("Allow Null", "Yes");
}else{
parameter.put("Allow Null", "No");
}
if( scalar.isValueConcealed() ){
parameter.put("Conceal Entry", "Yes"); //ie passwords etc
}else{
parameter.put("Conceal Entry", "No");
}


switch (scalar.getControlType()) {
case IScalarParameterDefn.TEXT_BOX: parameter.put("Type", "Text Box");
break;
case IScalarParameterDefn.LIST_BOX: parameter.put("Type", "List Box");
break;
case IScalarParameterDefn.RADIO_BUTTON: parameter.put("Type", "Radio
Button"); break;
case IScalarParameterDefn.CHECK_BOX: parameter.put("Type", "Check Box");
break;
default: parameter.put("Type", "Text Box");break;
}


switch (scalar.getDataType()) {
case IScalarParameterDefn.TYPE_STRING: parameter.put("Data Type",
"String"); break;
case IScalarParameterDefn.TYPE_FLOAT: parameter.put("Data Type",
"Float"); break;
case IScalarParameterDefn.TYPE_DECIMAL: parameter.put("Data Type",
"Decimal"); break;
case IScalarParameterDefn.TYPE_DATE_TIME: parameter.put("Data Type",
"Date Time"); break;
case IScalarParameterDefn.TYPE_BOOLEAN: parameter.put("Data Type",
"Boolean"); break;
default: parameter.put("Data Type", "Any"); break;
}


//Get report design and find prompt text
ReportDesignHandle reportHandle = ( ReportDesignHandle )
this.currentBirtReport.getDesignHandle( );
ScalarParameterHandle parameterHandle = ( ScalarParameterHandle )
reportHandle.findParameter( scalar.getName() );




parameter.put("Default Value",
checkIsNull(parameterHandle.getDefaultValue()));
parameter.put("Prompt Text",
checkIsNull(parameterHandle.getPromptText()));
parameter.put("Data Set Expression",
checkIsNull(parameterHandle.getValueExpr()));

if(scalar.getControlType() != IScalarParameterDefn.TEXT_BOX)
{
//System.out.println("dynamic parameter");

if ( parameterHandle.getContainer( ) instanceof
CascadingParameterGroupHandle ){
Collection sList = Collections.EMPTY_LIST;
parameter.put("Cascaded Parameter", "Yes");
if ( parameterHandle.getContainer( ) instanceof
CascadingParameterGroupHandle )
{
int index = parameterHandle.getContainerSlotHandle( )
.findPosn( parameterHandle );
parameter.put("Cascaded Parameter Index", new Integer(index));

if( index == 0 ){
Object[] keyValue = new Object[0];

String groupName = parameterHandle.getContainer( ).getName( );
task.evaluateQuery( groupName );


//selectionList = task.getSelectionListForCascadingGroup(
groupName, keyValue );

sList = task.getSelectionListForCascadingGroup( groupName,
keyValue );

Hashtable dynamicList = new Hashtable();

for ( Iterator sl = sList.iterator( ); sl.hasNext( ); )
{
IParameterSelectionChoice sI = (IParameterSelectionChoice)
sl.next( );


Object value = sI.getValue( );
Object label = sI.getLabel( );
//System.out.println( label + "--" + value);
//Display label unless null then display value. Value is the
what should get passed to the report.
dynamicList.put(sI.getValue().toString(),checkIsNull(label)) ;

}
parameter.put("Selection List", checkIsNull(dynamicList));
}

}
}else{
parameter.put("Cascaded Parameter", "No");
Collection selectionList = task.getSelectionList(
scalar.getName() );

if ( selectionList != null )
{
Hashtable dynamicList = new Hashtable();

for ( Iterator sliter = selectionList.iterator( );
sliter.hasNext( ); )
{
IParameterSelectionChoice selectionItem =
(IParameterSelectionChoice) sliter.next( );

Object value = selectionItem.getValue( );
String label = selectionItem.getLabel( );
//System.out.println( label + "--" + value);
//Display label unless null then display value. Value is the
what should get passed to the report.

dynamicList.put(selectionItem.getValue( ).toString(),checkIsNull(label));

}
parameter.put("Selection List", checkIsNull(dynamicList));
}
}

}else{

parameter.put("Cascaded Parameter", "No");
}



Iterator iter = parameter.keySet().iterator();
System.out.println("======================Parameter =" +
scalar.getName());
while (iter.hasNext()) {
String name = (String) iter.next();
if( name.equals("Selection List")){
Hashtable selList = (Hashtable)parameter.get(name);
Iterator selIter = selList.keySet().iterator();
while (selIter.hasNext()) {
Object lbl = selIter.next();
System.out.println( "Selection List Entry ===== Key = " + lbl + "
Value = " + selList.get(lbl));
}

}else{
System.out.println( name + " = " + parameter.get(name));
}
}
} catch (Exception e1) {
logger.log( Level.SEVERE, e1.getMessage());
throw new Exception(e1);
}
return parameter;

}

"Mike Boyersmith" <mjboyers@us.ibm.com> wrote in message
news:e1emvr$scd$1@utils.eclipse.org...
> So I have gathered my promptable parameters from my report and shown them
> in a UI and gotten input from the user. I however I'm at a lost as to what
> to do next.
>
> heres my code
>
> IReportRunnable report = reportEngine.openReportDesign(strReportPath);
> ModuleHandle MH = eport.getDesignHandle().getModule().getModuleHandle();
> List parameters = MH.getFlattenParameters()
> //...process the parameter list in a UI
> //
> //HELP HERE.....I somehow have to get these parameters in My UI assigned
> // so report engine will use them
> //
> IRunAndRenderTask task = reportEngine.createRunAndRenderTask(report);
> // generate the report
> task.run();
>
>
> At the moment when I go to run I get the following
>
> org.eclipse.birt.report.engine.api.EngineException: Some required
> parameter values are not set or set to incompatible data type.
>
>
> Whats the glue piece I need here to get my prompting parameters assigned
> in a way the report task will work with?
>
>
>
>
Re: Getting parameters and setting them so report engine can render report [message #152591 is a reply to message #152412] Tue, 11 April 2006 15:52 Go to previous message
Mike Boyersmith is currently offline Mike BoyersmithFriend
Messages: 143
Registered: July 2009
Senior Member
Once again Thank you so much Jason.


Jason Weathersby wrote:
> Mike,
>
> You have two options.
> Use the task.setParmaeterValue(ParameterName, Value) Value is Object type
> or
> task.setParameterValues(parameterMap) /* just a map of name value pairs.
>
> BTW you can use the engine api to retrieve the parameters as well.
>
> I used the following two functions to print out all the parameter info
> May be more than you want.
>
> Jason
>
>
>
> //info only method
> public Hashtable getParameterDetails() throws Exception{
> Hashtable parmDetails = new Hashtable();
>
> try{
> IGetParameterDefinitionTask task =
> this.birtReportEngine.createGetParameterDefinitionTask(
> this.currentBirtReport );
> Collection params = task.getParameterDefns( true );
>
>
> Iterator iter = params.iterator( );
> while ( iter.hasNext( ) )
> {
> IParameterDefnBase param = (IParameterDefnBase) iter.next( );
>
> if ( param instanceof IParameterGroupDefn )
> {
> IParameterGroupDefn group = (IParameterGroupDefn) param;
> Iterator i2 = group.getContents( ).iterator( );
> while ( i2.hasNext( ) )
> {
> IScalarParameterDefn scalar = (IScalarParameterDefn)
> i2.next( );
> //System.out.println("\t" + scalar.getName());
> parmDetails.put( scalar.getName(), loadParameterDetails( task,
> scalar, group));
> }
>
> }
> else
> {
>
> IScalarParameterDefn scalar = (IScalarParameterDefn) param;
> //System.out.println(param.getName());
> parmDetails.put( scalar.getName(),loadParameterDetails( task,
> scalar, null));
>
> }
> }
>
> task.close();
> } catch (Exception e1) {
> logger.log( Level.SEVERE, e1.getMessage());
> throw new Exception(e1);
> }
> return parmDetails;
> }
>
>
> private Hashtable loadParameterDetails(IGetParameterDefinitionTask task,
> IScalarParameterDefn scalar, IParameterGroupDefn group) throws Exception{
>
>
> Hashtable parameter = new Hashtable();
> try{
> if( group == null){
> group = new ParameterGroupDefn();
> }
> if( scalar == null ){
> scalar = new ScalarParameterDefn();
> }
> parameter.put("Parameter Group", checkIsNull(group.getName()));
> parameter.put("Name", checkIsNull(scalar.getName()));
> parameter.put("Help Text", checkIsNull(scalar.getHelpText()));
> parameter.put("Display Name", checkIsNull(scalar.getDisplayName()));
> //this is a format code such as > for UPPERCASE
> parameter.put("Display Format", checkIsNull(scalar.getDisplayFormat()));
>
> if( scalar.isHidden() ){
> parameter.put("Hidden", "Yes");
> }else{
> parameter.put("Hidden", "No");
> }
> if( scalar.allowBlank() ){
> parameter.put("Allow Blank", "Yes");
> }else{
> parameter.put("Allow Blank", "No");
> }
> if( scalar.allowNull() ){
> parameter.put("Allow Null", "Yes");
> }else{
> parameter.put("Allow Null", "No");
> }
> if( scalar.isValueConcealed() ){
> parameter.put("Conceal Entry", "Yes"); //ie passwords etc
> }else{
> parameter.put("Conceal Entry", "No");
> }
>
>
> switch (scalar.getControlType()) {
> case IScalarParameterDefn.TEXT_BOX: parameter.put("Type", "Text Box");
> break;
> case IScalarParameterDefn.LIST_BOX: parameter.put("Type", "List Box");
> break;
> case IScalarParameterDefn.RADIO_BUTTON: parameter.put("Type", "Radio
> Button"); break;
> case IScalarParameterDefn.CHECK_BOX: parameter.put("Type", "Check Box");
> break;
> default: parameter.put("Type", "Text Box");break;
> }
>
>
> switch (scalar.getDataType()) {
> case IScalarParameterDefn.TYPE_STRING: parameter.put("Data Type",
> "String"); break;
> case IScalarParameterDefn.TYPE_FLOAT: parameter.put("Data Type",
> "Float"); break;
> case IScalarParameterDefn.TYPE_DECIMAL: parameter.put("Data Type",
> "Decimal"); break;
> case IScalarParameterDefn.TYPE_DATE_TIME: parameter.put("Data Type",
> "Date Time"); break;
> case IScalarParameterDefn.TYPE_BOOLEAN: parameter.put("Data Type",
> "Boolean"); break;
> default: parameter.put("Data Type", "Any"); break;
> }
>
>
> //Get report design and find prompt text
> ReportDesignHandle reportHandle = ( ReportDesignHandle )
> this.currentBirtReport.getDesignHandle( );
> ScalarParameterHandle parameterHandle = ( ScalarParameterHandle )
> reportHandle.findParameter( scalar.getName() );
>
>
>
>
> parameter.put("Default Value",
> checkIsNull(parameterHandle.getDefaultValue()));
> parameter.put("Prompt Text",
> checkIsNull(parameterHandle.getPromptText()));
> parameter.put("Data Set Expression",
> checkIsNull(parameterHandle.getValueExpr()));
>
> if(scalar.getControlType() != IScalarParameterDefn.TEXT_BOX)
> {
> //System.out.println("dynamic parameter");
>
> if ( parameterHandle.getContainer( ) instanceof
> CascadingParameterGroupHandle ){
> Collection sList = Collections.EMPTY_LIST;
> parameter.put("Cascaded Parameter", "Yes");
> if ( parameterHandle.getContainer( ) instanceof
> CascadingParameterGroupHandle )
> {
> int index = parameterHandle.getContainerSlotHandle( )
> .findPosn( parameterHandle );
> parameter.put("Cascaded Parameter Index", new Integer(index));
>
> if( index == 0 ){
> Object[] keyValue = new Object[0];
>
> String groupName = parameterHandle.getContainer( ).getName( );
> task.evaluateQuery( groupName );
>
>
> //selectionList = task.getSelectionListForCascadingGroup(
> groupName, keyValue );
>
> sList = task.getSelectionListForCascadingGroup( groupName,
> keyValue );
>
> Hashtable dynamicList = new Hashtable();
>
> for ( Iterator sl = sList.iterator( ); sl.hasNext( ); )
> {
> IParameterSelectionChoice sI = (IParameterSelectionChoice)
> sl.next( );
>
>
> Object value = sI.getValue( );
> Object label = sI.getLabel( );
> //System.out.println( label + "--" + value);
> //Display label unless null then display value. Value is the
> what should get passed to the report.
> dynamicList.put(sI.getValue().toString(),checkIsNull(label)) ;
>
> }
> parameter.put("Selection List", checkIsNull(dynamicList));
> }
>
> }
> }else{
> parameter.put("Cascaded Parameter", "No");
> Collection selectionList = task.getSelectionList(
> scalar.getName() );
>
> if ( selectionList != null )
> {
> Hashtable dynamicList = new Hashtable();
>
> for ( Iterator sliter = selectionList.iterator( );
> sliter.hasNext( ); )
> {
> IParameterSelectionChoice selectionItem =
> (IParameterSelectionChoice) sliter.next( );
>
> Object value = selectionItem.getValue( );
> String label = selectionItem.getLabel( );
> //System.out.println( label + "--" + value);
> //Display label unless null then display value. Value is the
> what should get passed to the report.
>
> dynamicList.put(selectionItem.getValue( ).toString(),checkIsNull(label));
>
> }
> parameter.put("Selection List", checkIsNull(dynamicList));
> }
> }
>
> }else{
>
> parameter.put("Cascaded Parameter", "No");
> }
>
>
>
> Iterator iter = parameter.keySet().iterator();
> System.out.println("======================Parameter =" +
> scalar.getName());
> while (iter.hasNext()) {
> String name = (String) iter.next();
> if( name.equals("Selection List")){
> Hashtable selList = (Hashtable)parameter.get(name);
> Iterator selIter = selList.keySet().iterator();
> while (selIter.hasNext()) {
> Object lbl = selIter.next();
> System.out.println( "Selection List Entry ===== Key = " + lbl + "
> Value = " + selList.get(lbl));
> }
>
> }else{
> System.out.println( name + " = " + parameter.get(name));
> }
> }
> } catch (Exception e1) {
> logger.log( Level.SEVERE, e1.getMessage());
> throw new Exception(e1);
> }
> return parameter;
>
> }
>
> "Mike Boyersmith" <mjboyers@us.ibm.com> wrote in message
> news:e1emvr$scd$1@utils.eclipse.org...
>
>>So I have gathered my promptable parameters from my report and shown them
>>in a UI and gotten input from the user. I however I'm at a lost as to what
>>to do next.
>>
>>heres my code
>>
>>IReportRunnable report = reportEngine.openReportDesign(strReportPath);
>>ModuleHandle MH = eport.getDesignHandle().getModule().getModuleHandle();
>>List parameters = MH.getFlattenParameters()
>>//...process the parameter list in a UI
>>//
>>//HELP HERE.....I somehow have to get these parameters in My UI assigned
>>// so report engine will use them
>>//
>>IRunAndRenderTask task = reportEngine.createRunAndRenderTask(report);
>>// generate the report
>>task.run();
>>
>>
>>At the moment when I go to run I get the following
>>
>>org.eclipse.birt.report.engine.api.EngineException: Some required
>>parameter values are not set or set to incompatible data type.
>>
>>
>>Whats the glue piece I need here to get my prompting parameters assigned
>>in a way the report task will work with?
>>
>>
>>
>>
>
>
>
Previous Topic:execute repport
Next Topic:PDF emitter not working in web viewer servlet
Goto Forum:
  


Current Time: Thu Apr 25 16:02:18 GMT 2024

Powered by FUDForum. Page generated in 0.02804 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top