use of com.axelor.apps.base.db.BirtTemplate in project axelor-open-suite by axelor.
the class MessageServiceBaseImpl method printMessage.
@SuppressWarnings("unchecked")
@Override
public String printMessage(Message message) throws AxelorException {
Company company = message.getCompany();
if (company == null) {
return null;
}
PrintingSettings printSettings = company.getPrintingSettings();
if (printSettings == null || printSettings.getDefaultMailBirtTemplate() == null) {
return null;
}
BirtTemplate birtTemplate = printSettings.getDefaultMailBirtTemplate();
logger.debug("Default BirtTemplate : {}", birtTemplate);
Templates templates = new StringTemplates('$', '$');
Map<String, Object> templatesContext = Maps.newHashMap();
try {
Class<? extends Model> className = (Class<? extends Model>) Class.forName(message.getClass().getName());
templatesContext.put("Message", JPA.find(className, message.getId()));
} catch (ClassNotFoundException e) {
TraceBackService.trace(e);
}
String fileName = "Message " + message.getSubject() + "-" + appBaseService.getTodayDate(company).format(DateTimeFormatter.BASIC_ISO_DATE);
return Beans.get(TemplateMessageServiceBaseImpl.class).generateBirtTemplateLink(templates, templatesContext, fileName, birtTemplate.getTemplateLink(), birtTemplate.getFormat(), birtTemplate.getBirtTemplateParameterList());
}
use of com.axelor.apps.base.db.BirtTemplate in project axelor-open-suite by axelor.
the class PrintTemplateServiceImpl method getMetaFiles.
public Set<MetaFile> getMetaFiles(TemplateMaker maker, PrintTemplate printTemplate) throws AxelorException, IOException {
Set<MetaFile> metaFiles = new HashSet<>();
if (printTemplate.getBirtTemplateSet() == null) {
return metaFiles;
}
for (BirtTemplate birtTemplate : printTemplate.getBirtTemplateSet()) {
metaFiles.add(templateMessageService.createMetaFileUsingBirtTemplate(maker, birtTemplate, null, null));
}
LOG.debug("MetaFile to attach: {}", metaFiles);
return metaFiles;
}
use of com.axelor.apps.base.db.BirtTemplate in project axelor-open-suite by axelor.
the class TemplateMessageServiceBaseImpl method getMetaFiles.
@Override
public Set<MetaFile> getMetaFiles(Template template, Templates templates, Map<String, Object> templatesContext) throws AxelorException, IOException {
Set<MetaFile> metaFiles = super.getMetaFiles(template, templates, templatesContext);
Set<BirtTemplate> birtTemplates = template.getBirtTemplateSet();
if (CollectionUtils.isEmpty(birtTemplates)) {
return metaFiles;
}
for (BirtTemplate birtTemplate : birtTemplates) {
metaFiles.add(createMetaFileUsingBirtTemplate(null, birtTemplate, templates, templatesContext));
}
logger.debug("Metafile to attach: {}", metaFiles);
return metaFiles;
}
Aggregations