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)
PDF Auto Drill-through
riyaz_itls
Hi,
Lets say I have two reports master & detail. The master hyperlinks to the detail report as drill-down.
Is is possible to generate the drill down reports automatically in PDF format on render of the master report?
Thanks in advance
Riyaz
Find more posts tagged with
Comments
mwilliams
So, when you open the master report, you want the detail report to automatically open as well?
riyaz_itls
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="85669" data-time="1322064649" data-date="23 November 2011 - 09:10 AM"><p>
So, when you open the master report, you want the detail report to automatically open as well?<br /></p></blockquote>
<br />
Yes. For eg: if I run the master report via commandline with format=PDF the detail report pdfs have to be generated.
mwilliams
Ok, so a separate detail report for each group in the master must be ran? You could probably create a java file that uses the Engine API to run the detail reports and call this somewhere within your report where you know what different values you'll need to run it for that you can pass to your java code. I haven't done it, but I don't see why it wouldn't work!
riyaz_itls
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="85679" data-time="1322068001" data-date="23 November 2011 - 10:06 AM"><p>
Ok, so a separate detail report for each group in the master must be ran? You could probably create a java file that uses the Engine API to run the detail reports and call this somewhere within your report where you know what different values you'll need to run it for that you can pass to your java code. I haven't done it, but I don't see why it wouldn't work!<br /></p></blockquote>
<br />
Thanks Michael. Will try this and let you know.
riyaz_itls
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="85679" data-time="1322068001" data-date="23 November 2011 - 10:06 AM"><p>
Ok, so a separate detail report for each group in the master must be ran? You could probably create a java file that uses the Engine API to run the detail reports and call this somewhere within your report where you know what different values you'll need to run it for that you can pass to your java code. I haven't done it, but I don't see why it wouldn't work!<br /></p></blockquote>
<br />
Your recipe worked. <br />
The master report has a table. Also I have defined a drill-down hyperlink from the dataItem in the table to the detail report. OnRender() event of the dataItem I call the below method drillDown().<br />
<br />
The only thing am not sure is the way I parse the parameters. The paramsBinding map from IDrillThroughInstance return a Map<String, List<String>>. Am not sure why the value is a list though the parameter to my detail-report is just string.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public static void drillDown(IReportContext reportContext,
IDrillThroughInstance drillThrough) throws EngineException,
URISyntaxException {
logger.debug("drillDown(IReportContext, IDrillThroughInstance)");
IRenderOption masterOption = reportContext.getRenderOption();
// compile paths
String detailDesignPath = getDetailReportDesignPath(reportContext, drillThrough);
String detailOutputPath = getDetailReportOutputPath(masterOption, detailDesignPath);
// compile renderoption
IRenderOption detailOption = new RenderOption();
detailOption.setOutputFormat(masterOption.getOutputFormat());
detailOption.setOutputFileName(detailOutputPath);
// setup runandrender task
IReportEngine engine = reportContext.getReportRunnable().getReportEngine();
IReportRunnable runnable = engine.openReportDesign(detailDesignPath);
IRunAndRenderTask task = engine.createRunAndRenderTask(runnable);
task.setParameterValues(drillThrough.getParameterBindings());
task.setRenderOption(detailOption);
// compile params (TODO: check if this works for all types of params)
Map paramBindings = drillThrough.getParameterBindings();
Set<Map.Entry> paramEntrySet = paramBindings.entrySet();
for (Entry entry : paramEntrySet) {
String name = (String) entry.getKey();
Object value = entry.getValue();
if (value instanceof Collection) {
Iterator valuesItr = ((Collection) value).iterator();
while(valuesItr.hasNext()) {
task.setParameterValue(name, valuesItr.next());
}
} else {
task.setParameterValue(name, value);
}
}
task.run();
}
private static String getDetailReportDesignPath(IReportContext reportContext,
IDrillThroughInstance drillThrough) throws URISyntaxException {
String masterDesignPath = reportContext.getReportRunnable().getReportName();
logger.debug("Master-Report Design Path: " + masterDesignPath);
String masterDesignRawPath = new URI(masterDesignPath).getRawPath(); // removes 'file:/' prefix
File masterDesignDir = new File(masterDesignRawPath).getParentFile();
// relative path to detailReport from masterReport
String detailReportName = drillThrough.getReportName();
String detailDesignPath = new File(masterDesignDir, detailReportName).getAbsolutePath();
logger.debug("Detail-Report Design Path: " + detailDesignPath);
return detailDesignPath;
}
private static String getDetailReportOutputPath(IRenderOption masterOption, String detailDesignPath) {
String masterOutputPath = masterOption.getOutputFileName();
String outputFormat = masterOption.getOutputFormat();
logger.debug("Master-Report Output Path: " + masterOutputPath);
String detailOuputPath = null;
if (masterOutputPath != null) {
File masterOutputDir = new File(masterOutputPath).getParentFile();
File detailDesignFile = new File(detailDesignPath);
String detailFileName = detailDesignFile.getName();
int n = detailFileName.lastIndexOf('.');
if (n != -1) {
detailFileName = detailFileName.substring(0, n);
}
detailFileName += "_" + System.currentTimeMillis() + "." + outputFormat;
detailOuputPath = new File(masterOutputDir, detailFileName).getAbsolutePath();
}
logger.debug("Detail-Report Output Path: " + masterOutputPath);
return detailOuputPath;
}
</pre>
<br />
Regards<br />
Riyaz
mwilliams
Your parameter is just your list of values from your table that you need to create detail reports for, right? How are you setting this parameter? Could you do this slightly differently by calling your drill down in your onCreate of your element, so that you can pass the current row data directly to your drill down function? Or am I misunderstanding something? Let me know.