Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » How can I get the parameter datatypes from a Report Definition/Design
How can I get the parameter datatypes from a Report Definition/Design [message #1044165] Thu, 18 April 2013 15:06 Go to next message
Sebastiaan Hendriks is currently offline Sebastiaan Hendriks
Messages: 13
Registered: March 2013
Location: Netherlands
Junior Member
I've been working with BIRT to provide reporting capability in a Eclipse Scout project.

As part of the requirements, I've constructed the functionality where users can produce reports based upon their own input (limited by the parameters given by the system).

In order to get the parameters of the Report in question, I run the createGetParameterDefinitionTask() function on the engine to get a list of ScalarParameterDefn's. From which I then pluck things like the parameter defaultvalue, name and datatype.

Relevant function shown here:
private List<ReportParameter> _getReportParameters(IReportRunnable design, ReportEngine engine)
  {
    List<ReportParameter> reportParameterList = new ArrayList<ReportParameter>();

    IGetParameterDefinitionTask parameterDefinitionTask = engine.createGetParameterDefinitionTask(design);
    Collection<ScalarParameterDefn> parameterDefinitionCollection = parameterDefinitionTask.getParameterDefns(true);
    Iterator<ScalarParameterDefn> parameterDefinitionIterator = parameterDefinitionCollection.iterator();
    while (parameterDefinitionIterator.hasNext())
    {
      ScalarParameterDefn parameterDefiniton = parameterDefinitionIterator.next();

      String dataType = BIRTDataType.getBIRTDataType(parameterDefiniton.getDataType());
      Object value = parameterDefiniton.getDefaultValue();
      String name = parameterDefiniton.getName();
      
      //Further handeling of these values snipped.
 }

My problem is the following. The Datatype is returned as a int, and since I had no luck to locate any documentation, finding out which number stood for which datatype was trail and error based. Sadly, today with a new report, I found out that the function getDataType() returned a different number for a Date parameter then previous.

Is there any documentation available where I can read up on how to understand how the datatype of the parameter translates to which int result, or, is there a much better way at getting the Datatypes of the parameters out of a report definition?

Thank you in advance.
Re: How can I get the parameter datatypes from a Report Definition/Design [message #1044174 is a reply to message #1044165] Thu, 18 April 2013 15:16 Go to previous messageGo to next message
Andrew Aiken is currently offline Andrew Aiken
Messages: 4
Registered: March 2013
Junior Member
The interface IParameterDefn contains constants which defines which data type is what int. In the version of BIRT I'm using, 3.7.2, these values are:

        public static final int TYPE_ANY = 0;
	public static final int TYPE_STRING = 1;
	public static final int TYPE_FLOAT = 2;
	public static final int TYPE_DECIMAL = 3;
	public static final int TYPE_DATE_TIME = 4;
	public static final int TYPE_BOOLEAN = 5;
	public static final int TYPE_INTEGER = 6;
	public static final int TYPE_DATE = 7;
	public static final int TYPE_TIME = 8;


Hope this helps.
Re: How can I get the parameter datatypes from a Report Definition/Design [message #1044712 is a reply to message #1044174] Fri, 19 April 2013 08:35 Go to previous message
Sebastiaan Hendriks is currently offline Sebastiaan Hendriks
Messages: 13
Registered: March 2013
Location: Netherlands
Junior Member
Andrew,

That was indeed helpfull. Thank you.
Previous Topic:java.lang.IllegalStateException: The viewing session is not available or has expired.
Next Topic:How to turn text in label or label for 90grad ?
Goto Forum:
  


Current Time: Wed Sep 03 04:52:24 GMT 2014

Powered by FUDForum. Page generated in 0.01593 seconds