use of com.axelor.apps.base.db.BirtTemplateParameter in project axelor-open-suite by axelor.
the class TemplateMessageServiceBaseImpl method generateTemplate.
private ReportSettings generateTemplate(TemplateMaker maker, Templates templates, Map<String, Object> templatesContext, String fileName, String modelPath, String format, List<BirtTemplateParameter> birtTemplateParameterList) throws AxelorException {
if (modelPath == null || modelPath.isEmpty()) {
return null;
}
ReportSettings reportSettings = ReportFactory.createReport(modelPath, fileName).addFormat(format);
for (BirtTemplateParameter birtTemplateParameter : birtTemplateParameterList) {
try {
String parseValue = null;
if (maker != null) {
maker.setTemplate(birtTemplateParameter.getValue());
parseValue = maker.make();
} else {
parseValue = templates.fromText(birtTemplateParameter.getValue()).make(templatesContext).render();
}
reportSettings.addParam(birtTemplateParameter.getName(), convertValue(birtTemplateParameter.getType(), parseValue));
} catch (BirtException e) {
throw new AxelorException(e.getCause(), TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.TEMPLATE_MESSAGE_BASE_2));
}
}
reportSettings.generate();
return reportSettings;
}
Aggregations