JDK: 1.6.0_18
Jasper: DynamicJasper-3.0.16.jar
If Percentage column is added without other concatenated reports, the column behaves as expected. Introduction of other reports causes an unhandled ar.com.fdvs.dj.core.registration.EntitiesRegistrationException complaining of a duplicate variable being registered:
Caused by: ar.com.fdvs.dj.core.registration.EntitiesRegistrationException: Duplicate declaration of variable : variable-global_salesValueRaw_percentage
at ar.com.fdvs.dj.core.registration.AbstractEntityRegistrationManager.registerEntities(AbstractEntityRegistrationManager.java:94)
at ar.com.fdvs.dj.core.DynamicJasperHelper.registerPercentageColumnsVariables(DynamicJasperHelper.java:159)
at ar.com.fdvs.dj.core.DynamicJasperHelper.registerEntities(DynamicJasperHelper.java:101)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:513)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:279)
at officemate.screens.reports.jasper.JasperReportState.getJasperPrint(JasperReportState.java:102)
at officemate.screens.reports.jasper.JasperReportState$ReportLoader.doInBackground(JasperReportState.java:294)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: ar.com.fdvs.dj.core.registration.EntitiesRegistrationException: Duplicate declaration of variable : variable-global_salesValueRaw_percentage
at ar.com.fdvs.dj.core.registration.DJGroupVariableDefRegistrationManager.registerEntity(DJGroupVariableDefRegistrationManager.java:78)
at ar.com.fdvs.dj.core.registration.AbstractEntityRegistrationManager.registerEntities(AbstractEntityRegistrationManager.java:90)
... 13 more
Caused by: net.sf.jasperreports.engine.JRException: Duplicate declaration of variable : variable-global_salesValueRaw_percentage
at net.sf.jasperreports.engine.design.JRDesignDataset.addVariable(JRDesignDataset.java:805)
at net.sf.jasperreports.engine.design.JRDesignDataset.addVariable(JRDesignDataset.java:789)
at net.sf.jasperreports.engine.design.JasperDesign.addVariable(JasperDesign.java:960)
at ar.com.fdvs.dj.core.registration.DJGroupVariableDefRegistrationManager.registerEntity(DJGroupVariableDefRegistrationManager.java:76)
Sample of code is shown below. If the percentage column is not included at the same time as the sub reports the report will compile, otherwise the exception is thrown.
...
builder.addReportColumn(ItemSoldReport.Properties.SALES_VALUE_RAW, "Sales", "$0.00") ;
AbstractColumn percColumn = ColumnBuilder.getNew().setTitle("% of Sales")
.setPercentageColumn(builder.getPropertyColumn(ItemSoldReport.Properties.SALES_VALUE_RAW))
.setPattern("0.0%").build();
builder.getReportBuilder().addColumn(percColumn);
//Add a dynamic subreport.
addCategoryTotalsReport();
//Add a Jasper report
addSalesTotalReport();
...
//Report is built, and exception is thrown.
A suspect may be in the DynamicJasperHelper.registerPercentageColumnVariables(...):
/**
* Group should not be needed in the percentage column. There should be a variable for each group, using
* parent group as "rest group"
*/
if (column instanceof PercentageColumn) {
PercentageColumn percentageColumn = ((PercentageColumn) column);
for (Iterator iterator2 = dr.getColumnsGroups().iterator(); iterator2.hasNext();) {
DJGroup djGroup = (DJGroup) iterator2.next();
JRDesignGroup jrGroup = LayoutUtils.getJRDesignGroup(jd, layoutManager, djGroup);
DJGroupVariableDefRegistrationManager variablesRM = new DJGroupVariableDefRegistrationManager(jd,dr,layoutManager, jrGroup);
DJGroupVariableDef variable = new DJGroupVariableDef(percentageColumn.getGroupVariableName(djGroup), percentageColumn.getPercentageColumn(), DJCalculation.SUM);
Collection entities = new ArrayList();
entities.add(variable);
variablesRM.registerEntities(entities);//<-- Unhandled EntitiesRegistrationException
}
}