Skip to main content



      Home
Home » Archived » BIRT » how to set parameter values via BIRT API
how to set parameter values via BIRT API [message #77342] Tue, 27 September 2005 11:08 Go to next message
Eclipse UserFriend
Originally posted by: gerald.zaynard.ids-scheer.com

How can i set the value of a parameter?

Using setValue in IGetParameterDefinitionTask doesn't work. I can retrieve
any informations of all parameters (as shown in the examples) but i can't
set any value.

How can this be done?
Re: how to set parameter values via BIRT API [message #77387 is a reply to message #77342] Tue, 27 September 2005 12:14 Go to previous messageGo to next message
Eclipse UserFriend
Gerald

Have you looked at the
IRunAndRenderTask. It has a method setParameterValues( Hashmap).

Jason Weathersby
BIRT PMC
"Gerald Zaynard" <gerald.zaynard@ids-scheer.com> wrote in message
news:d3309f1c63b92694d132967b96c68c9c$1@www.eclipse.org...
> How can i set the value of a parameter?
>
> Using setValue in IGetParameterDefinitionTask doesn't work. I can retrieve
> any informations of all parameters (as shown in the examples) but i can't
> set any value.
>
> How can this be done?
>
Re: how to set parameter values via BIRT API [message #77464 is a reply to message #77387] Wed, 28 September 2005 09:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gerald.zaynard.ids-scheer.com

Great, thx. Sorry for being blind ;-)
Re: how to set parameter values via BIRT API [message #82711 is a reply to message #77464] Thu, 20 October 2005 15:28 Go to previous messageGo to next message
Eclipse UserFriend
I was stumped by this also until I saw Jason's reply. While my code now
seems to work, could we get a bit more explanation.

I also found that IGetParameterDefinitionTask.setValue() doesn't work.
While IRunAndRenderTask.setParameterValue(String, Object) does work,
IRunAndRenderTask.getParameterValues() always seems to return an empty map.

Thus, I can read the parameters using IGetParameterDefinitionTask but I
must use IRunAndRenderTask to set them even though both tasks appear to be
capable of both get and set operations.

I haven't tried IRunAndRenderTask.setParameterValues(map) yet.

Am I missing something?

thanks

Mike
Re: how to set parameter values via BIRT API [message #84189 is a reply to message #82711] Wed, 26 October 2005 11:07 Go to previous messageGo to next message
Eclipse UserFriend
Mike,
Sorry for the delay on this message. I missed it with my News Reader.
I know that programmatically setting the reports is a bit confusing, but we
are working on better docs for this area. The basic steps should be like
the following.
1 - ReportEngine.createGetParameterDefinitionTask( )
2 - .If you want the defaults for your report to work
set IGetParameterDefnTask.evaluateDefaults( ). This prevents you from
having to setvalue on every parameter.
3 - call IGetParameterDefnTask.getDefaultValues( ), which will return a
hashmap.
This hashmap will be empty if you didnt call evaluateDefaults.
4 -You should be able to then call IGetParameterDefnTask.setValue( ), to set
individual
parameter values.
5 - If you call IGetParameterDefnTask.getDefaultValues( ), it should return
a HashMap that
has the default values, plus the ones set using SetValue(). This HashMap
can then be passed to the IRunAndRenderTask.setParameterValues() function

You have to use IRunAndRenderTask to set values to pass the modifed
parameters to the engine.
Hope this makes sense.

Jason Weathesby
BIRT PMC



"Mike Fox" <foxm@us.ibm.com> wrote in message
news:1e11d794981349a65a9c585a9efcd330$1@www.eclipse.org...
>I was stumped by this also until I saw Jason's reply. While my code now
>seems to work, could we get a bit more explanation.
>
> I also found that IGetParameterDefinitionTask.setValue() doesn't work.
> While IRunAndRenderTask.setParameterValue(String, Object) does work,
> IRunAndRenderTask.getParameterValues() always seems to return an empty
> map.
>
> Thus, I can read the parameters using IGetParameterDefinitionTask but I
> must use IRunAndRenderTask to set them even though both tasks appear to be
> capable of both get and set operations.
>
> I haven't tried IRunAndRenderTask.setParameterValues(map) yet.
>
> Am I missing something?
>
> thanks
>
> Mike
>
>
Re: how to set parameter values via BIRT API [message #89417 is a reply to message #84189] Wed, 09 November 2005 15:30 Go to previous message
Eclipse UserFriend
This has changed significantly in BIRT V2M2.

IGetParameterDefnTask.evaluateDefaults() is deprecated. when you look in
the javadoc, it says to use getDefaultParameterValues(), but that is also
deprecated.

IEngineTask.setParameterValues() is deprecated.

Also, IGetParameterDefnTGask.setValue() doesn't seem to do much that I can
see.

The following code seems to work for me:

IGetParameterDefinitionTask paramTask =
rptEngine.createGetParameterDefinitionTask(report);
paramTask.setLocale(locale);
Iterator paramIter = paramTask.getParameterDefns(false).iterator();
//returns all entries
Map birtParamDef = paramTask.getDefaultValues(); //default values
while(paramIter.hasNext())
{
IParameterDefnBase rptParam = (IParameterDefnBase)paramIter.next();
if (rptParam.getParameterType() != IParameterDefnBase.SCALAR_PARAMETER)
{
continue; //only process scalar parameters
}
String paramName = rptParam.getName();
IScalarParameterDefn paramDef = (IScalarParameterDefn)rptParam; //cast
to scalar type
String userValue = (String)getUserValue(paramName); //user's prompt
response

//process appropriate data type for parameter
Object valueObj = prepParameter( //returns java type, String, Double,
Date, etc.
paramDef,
paramName,
userValue,
birtParamDef.get(paramName),
locale);
birtParamDef.remove(paramName);
birtParamDef.put(paramName, valueObj);
} //end while
rrTask.setValues((HashMap)birtParamDef); //rrTask is type IRunAndRenderTask



Note that rrTask.setValues requires a HashMap argument, not a Map. Strange.

Has anybody else made this work with the M2 build?
thanks

Mike Fox
Previous Topic:Metadata for dataset creation
Next Topic:Get display name out of database
Goto Forum:
  


Current Time: Fri May 09 20:54:33 EDT 2025

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

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

Back to the top