Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Selecting .properties file based on report parameter value
Selecting .properties file based on report parameter value [message #1386326] Mon, 16 June 2014 15:08 Go to next message
Juliane Steinberg is currently offline Juliane SteinbergFriend
Messages: 3
Registered: June 2014
Junior Member
Hi all,

I have created a generic BIRT report that displays data for one of a number of different scenarios. The report is generated via an interface where you select the scenario using a drop-down menu, which sets the BIRT report parameter "Scenario" (and thus affects the database queries). What I would like to do is customize the report further by using one .properties file per scenario, such that the .properties file used is selected within the report depending on the value of the parameter "Scenario".
Right now it seems to me like this cannot be done, as the resources are defined right at the top of the report file, before parameters even become available. Is this true, or do you see any way a .properties file can be selected based on a report parameter without ever spelling out an explicit resource file name (I want the report to be able to handle future scenarios as well, so including all .properties files as resources and somehow choosing between them later on would not be an option)?
At the moment I have one generic .rptdesign file per scenario with the corresponding .properties file name hardwired into it, which seems a little redundant.

Thanks in advance,
Juliane
Re: Selecting .properties file based on report parameter value [message #1388924 is a reply to message #1386326] Fri, 27 June 2014 05:19 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Have you already solved this? If not, can you explain in more detail what you're trying to do? Thanks.

Michael

Developer Evangelist, Silanis
Re: Selecting .properties file based on report parameter value [message #1391069 is a reply to message #1388924] Mon, 30 June 2014 12:00 Go to previous messageGo to next message
Juliane Steinberg is currently offline Juliane SteinbergFriend
Messages: 3
Registered: June 2014
Junior Member
Hi Michael,

no, I haven't solved this issue, but I have created a workaround which I don't really like a lot. I'll try to describe my issue in more detail first:

We have several web applications running on the same server for which we would like to generate performance reports. Through an interface you can select the app you would like to generate the report for, hit a button, and you get the BIRT report specifically for that app's performance.

This is done using a single .rptdesign file on that web server. This report receives the name of the selected app as a report parameter and uses that string to retrieve database connection properties in order to access the app's actual performance data. This works just fine if you want the report to look the same for all web apps. However, I've added the possibility to configure the contents of the report using a .properties file. There are a number of keys in this file which need to have different values for each app (we are for example talking about sets of app-specific database entries that are used as filters on tables in the report), and my question is how I can deal with this issue.

One option would be to create one .rptdesign file per web app, each one having its own .properties file. That's annoying and hard to maintain if I need to make a change to the generic report.
Another option, which my question was referring to, would be to have a single .rptdesign file and one .properties file per webapp, and to select the correct .properties file using the above-mentioned app name report parameter (probably by naming the properties files APP1.properties, APP2.properties etc). I don't know if this can be done, seeing as I don't seem to be able to access report parameters at the stage of the report where the .properties file is linked. However, I think that something like this would be the most elegant solution.
A third option, which I have implemented and which works, is to have a single .rptdesign file and a single corresponding .properties file which contains a separate set of keys for each application like APP1.key1 = valueA, APP1.key2 = valueB, APP2.key1 = valueC, APP2.key2 = valueD, ... Whenever the BIRT report accesses a key from the .properties file it creates that key on the fly by concatenating the app name report parameter and the hard-wired generic second half of the key.

If you think that there is some way to implement the second solution, i.e. one .rptdesign and several .properties files one of which can be selected at runtime, I'd be grateful for your suggestions.

Thanks,
Juliane
Re: Selecting .properties file based on report parameter value [message #1391582 is a reply to message #1391069] Tue, 01 July 2014 05:28 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

If you have separate properties files for each app (App1.properties, App2.properties, etc) and they're all in the folder with the single design. You could use a line of code like the following in the initialize method of the design to switch what properties file to use:

reportContext.getDesignHandle().setIncludeResource(params["Application"]);

This assumes that the value of the parameter would be the same as the name of the properties file (for example "App1").

Hope this helps. Let me know if I'm misunderstanding something.


Michael

Developer Evangelist, Silanis
Re: Selecting .properties file based on report parameter value [message #1391789 is a reply to message #1391582] Tue, 01 July 2014 12:14 Go to previous messageGo to next message
Juliane Steinberg is currently offline Juliane SteinbergFriend
Messages: 3
Registered: June 2014
Junior Member
Hi Michael,
this is exactly what I meant and it works just fine.
Thank you so much!
Juliane
Re: Selecting .properties file based on report parameter value [message #1391863 is a reply to message #1391789] Tue, 01 July 2014 14:20 Go to previous message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Great to hear! You're welcome!

Michael

Developer Evangelist, Silanis
Previous Topic:waitforexecution.jsp is missing from the birtviewer toolkit
Next Topic:Vulnerabilities in Eclipse BIRT jars
Goto Forum:
  


Current Time: Mon Sep 23 09:14:45 GMT 2024

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

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

Back to the top