}
protected static DynamicJasperDesign generateJasperDesign(DynamicReport dr) throws CoreException {
DynamicJasperDesign jd = null;
try {
if (dr.getTemplateFileName() != null) {
log.info("loading template file: "+dr.getTemplateFileName());
log.info("Attemping to find the file directly in the file system...");
File file = new File(dr.getTemplateFileName());
if (file.exists()){
JasperDesign jdesign = JRXmlLoader.load(file);
jd = DJJRDesignHelper.downCast(jdesign,dr);
} else {
log.info("Not found: Attemping to find the file in the classpath...");
URL url = DynamicJasperHelper.class.getClassLoader().getResource(dr.getTemplateFileName());
JasperDesign jdesign = JRXmlLoader.load(url.openStream());
jd = DJJRDesignHelper.downCast(jdesign,dr);
}
DJJRDesignHelper.populateReportOptionsFromDesign(jd,dr);
} else {
//Create new JasperDesign from the scratch
jd = DJJRDesignHelper.getNewDesign(dr);
}
jd.setScriptletClass(DJDefaultScriptlet.class.getName()); //XXX this is new, for testing
registerParameters(jd,dr);
} catch (JRException e) {
throw new CoreException(e.getMessage(),e);
} catch (IOException e) {
throw new CoreException(e.getMessage(),e);