String paramName = parameter.getName();
if(parameter.getValueClassName().equals("net.sf.jasperreports.engine.JRDataSource")&& paramName.equals(datasetName)){//&& parameter.getName().equals(dataset.getLabel()
//set dataset query value
dataset.loadData();
IDataStore dstore = dataset.getDataStore();
JRSpagoBIDataStoreDataSource dataSource = new JRSpagoBIDataStoreDataSource( dstore );
getEnv().put(paramName, dataSource);
logger.debug("set parameter"+ paramName+" value");
}
}
}
}
logger.debug("Compiling template file ...");
Monitor monitorCompileTemplate =MonitorFactory.start("JasperReportRunner.compileTemplate");
JasperReport report = JasperCompileManager.compileReport(jasperDesign);
monitorCompileTemplate.stop();
logger.debug("Template file compiled succesfully");
adaptReportParams(report);
setupLocale();
Monitor monitorSubReport = MonitorFactory.start("JasperReportRunner.compileSubReport");
File[] compiledSubreports = compileSubreports();
monitorSubReport.stop();
ClassLoader previous = Thread.currentThread().getContextClassLoader();
ClassLoader current = URLClassLoader.newInstance(new URL[]{getCacheDir(prefixDirTemplate).toURL()}, previous);
Thread.currentThread().setContextClassLoader(current);
logger.debug("Filling report ...");
Monitor monitorFillingReport =MonitorFactory.start("JasperReportRunner.FillingReport");
JasperPrint jasperPrint = null;
if( getDataSet() != null) {
logger.debug("... using dataset [" + getDataSet().getName() + "]");
getDataSet().setParamsMap(getEnv());
getDataSet().loadData();
for(int i = 0; i < getDataSet().getDataStore().getMetaData().getFieldCount(); i++) {
logger.debug("Dataset column [" + (i+1) + "] name is equal to [" + getDataSet().getDataStore().getMetaData().getFieldName(i) + "]");
}
JRSpagoBIDataStoreDataSource dataSource = new JRSpagoBIDataStoreDataSource( getDataSet().getDataStore() );
jasperPrint = JasperFillManager.fillReport(report, getEnv(), dataSource);
} else {
logger.debug("... using datasource [" + getDataSource().getLabel() + "]");
connection = getConnection();
jasperPrint = JasperFillManager.fillReport(report, getEnv(), connection);