dataset.setDatasetRun(datasetRun);
JRDesignDataset jrDataset = new JRDesignDataset(false);
// jrDataset.setName("sub1");
for (int i = rows.length-1; i >= 0; i--) {
DJCrosstabRow crosstabRow = rows[i];
JRDesignField field = new JRDesignField();
field.setName(crosstabRow.getProperty().getProperty());
field.setValueClassName(crosstabRow.getProperty().getValueClassName());
try {
jrDataset.addField(field);
} catch (JRException e) {
log.error(e.getMessage(),e);
}
}
for (int i = cols.length-1; i >= 0; i--) {
DJCrosstabColumn crosstabColumn = cols[i];
JRDesignField field = new JRDesignField();
field.setName(crosstabColumn.getProperty().getProperty());
field.setValueClassName(crosstabColumn.getProperty().getValueClassName());
try {
jrDataset.addField(field);
} catch (JRException e) {
log.error(e.getMessage(),e);
}
}
JRDesignField field = new JRDesignField();
field.setName(djcrosstab.getMeasure(0).getProperty().getProperty());
field.setValueClassName(djcrosstab.getMeasure(0).getProperty().getValueClassName());
try {
jrDataset.addField(field);
} catch (JRException e) {
log.error(e.getMessage(),e);
}
jrcross.setDataset(dataset);
Random rd = new Random();
String dsName = "crosstabDataSource_" + rd.nextLong();
while (design.getDatasetMap().containsKey(dsName)){
dsName = "crosstabDataSource_" + rd.nextLong();
}
datasetRun.setDatasetName(dsName);
jrDataset.setName(dsName);
log.debug("Crosstab dataset name = " + dsName);
try {
if ( design.getDatasetMap().containsKey(jrDataset.getName())==false)
design.addDataset(jrDataset);
} catch (JRException e) {
//Will never happen
log.error(e.getMessage(),e);
}