Search in sources :

Example 1 with BirtTemplateParameter

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;
}
Also used : AxelorException(com.axelor.exception.AxelorException) BirtException(org.eclipse.birt.core.exception.BirtException) ReportSettings(com.axelor.apps.report.engine.ReportSettings) BirtTemplateParameter(com.axelor.apps.base.db.BirtTemplateParameter)

Aggregations

BirtTemplateParameter (com.axelor.apps.base.db.BirtTemplateParameter)1 ReportSettings (com.axelor.apps.report.engine.ReportSettings)1 AxelorException (com.axelor.exception.AxelorException)1 BirtException (org.eclipse.birt.core.exception.BirtException)1