Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How not generate Birt Report after calling runAndRenderTask.run()
DavidJ
Greetings,
I have Birt integrated into my app. My app is making a call for a report, however, the report has some criteria to evaluate to see if it should generate the report. Is there a way for the Birt Report to indicate back to my Java program that it should not generate a report. (This is based on the parameter info).
The following is a section of my embeded code:
try {
IRunAndRenderTask task = getEngine(ctx).createRunAndRenderTask(report);
if (task != null) {
try {
IRenderOption options = new RenderOption();
options.setOutputFormat(docType.label());
options.setOutputStream(out);
task.setRenderOption(options);
task.setParameterValues(parmValues != null ? parmValues : new HashMap());
task.run();
} finally {
// Release the resources for the BIRT task (this closes the DB connection)
task.close();
} ...
My goal is to make sure that no report is sent to the printer when processing based on criteria inside the Birt report. I will be making several requests with different parameter values and want the report to determine which ones should actually be printed.
If anyone could point me to instructions or an explanation of how I can make the request, and then have the report handle not generating (or printing anything if going to a printer). I assume that there is something that I can set in the report, but I am not finding how to do this anywhere I have looked.
Thanks for any help offered.
Find more posts tagged with
Comments
johnw
Don't use a RunAndRender Task since it will do everything in one single pass. use a IRunTask to generate the rptDocument file, then use the IRenderTask to to generate the rendered output based on your criteria. This way, if the BIRT report doesn't meet that criteria, it will still make a rptDocument, just not send it to its final output.
DavidJ
Thanks for the suggestion. If I split out the run and render task, what is the standard way for the report to indicate that there was nothing for it to do (i.e. don't render the report)? Seems like it should be straight forward after that. Also does anyone know if there is a large performance impact by spliting out the tasks?<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'johnw'" data-cid="73216" data-time="1297415872" data-date="11 February 2011 - 02:17 AM"><p>
Don't use a RunAndRender Task since it will do everything in one single pass. use a IRunTask to generate the rptDocument file, then use the IRenderTask to to generate the rendered output based on your criteria. This way, if the BIRT report doesn't meet that criteria, it will still make a rptDocument, just not send it to its final output.<br /></p></blockquote>
johnw
There isn't really any performance impact, the RunAndRender task is just a combination of the RunTask and the RenderTask, its just there for convenience. RunAndRender is also not nearly as flexible.
I am not sure what your business logic is to determine if it needs to render (if its based off data, a parameter, etc), but you can get all of those from the rptDocument file that is the result of the RunTask. If its based off data, you would create a DataExtractionTask, and pull the data that way. If its based off of a parameter, you would use the parameters stored in the rptDocument (I dont remember, but there I think there is a parameter extraction task as well, been a while since I needed to use it though). Once you have your logic, its just as simple as a if/then statement to create your RenderTask.
John
DavidJ
I think that I am still missing something as far as the report generation goes. My engine calls a generic report that any client can produce and we will attempt to run. I am trying to determine if there is a standard mechanism that everyone creating a report will have access to that I can check on my rptDocument or something after the run task (i.e. a cancel report flag or something) that can be checked, as I doing the call will need to ask the report if it was successfull. Also, we will need to comunicate to all of the report developers, if they do not want the report generated, what they need to set when creating the report. Once they have a mechanism to set something I can check, then I can skip the render task.<br />
<br />
Thanks for the info, and the suggestions.<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'johnw'" data-cid="73249" data-time="1297449195" data-date="11 February 2011 - 11:33 AM"><p>
There isn't really any performance impact, the RunAndRender task is just a combination of the RunTask and the RenderTask, its just there for convenience. RunAndRender is also not nearly as flexible. <br />
<br />
I am not sure what your business logic is to determine if it needs to render (if its based off data, a parameter, etc), but you can get all of those from the rptDocument file that is the result of the RunTask. If its based off data, you would create a DataExtractionTask, and pull the data that way. If its based off of a parameter, you would use the parameters stored in the rptDocument (I dont remember, but there I think there is a parameter extraction task as well, been a while since I needed to use it though). Once you have your logic, its just as simple as a if/then statement to create your RenderTask.<br />
<br />
John<br /></p></blockquote>
johnw
There is nothing standard, out of the box. But what you can do is define a Named Expression or User Property called doPrint in the report design, set to type boolean. This is defined in the Property Editor/Named Expressions or User Properties tab.
In your render code, what your going to do is something like:
//get the defined property from the report design. you should already have the reportRunnable object
//that you will pass to your RunAndRenderTask or RunTask opened.
boolean doRenderReport = reportRunnable.getProperty("doPrint");
if (doRenderReport)
{
//do all your render code here
}
else
{
//do not render code here
}