use of cz.metacentrum.perun.notif.StringTemplateLoader in project perun by CESNET.
the class PerunNotifTemplateManagerImpl method init.
@PostConstruct
public void init() throws Exception {
// Loads all templates to cache
List<PerunNotifTemplate> templates = perunNotifTemplateDao.getAllPerunNotifTemplates();
for (PerunNotifTemplate template : templates) {
// Cache template by id
allTemplatesById.put(template.getId(), template);
// Cache template by regexId
for (PerunNotifRegex regexId : template.getMatchingRegexs()) {
List<PerunNotifTemplate> templateList = null;
if (!allTemplatesByRegexId.containsKey(regexId.getId())) {
templateList = new ArrayList<PerunNotifTemplate>();
templateList.add(template);
allTemplatesByRegexId.put(regexId.getId(), templateList);
} else {
templateList = allTemplatesByRegexId.get(regexId.getId());
templateList.add(template);
}
}
}
//Initialization of freemarker
StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
for (PerunNotifTemplate template : templates) {
for (PerunNotifTemplateMessage pattern : template.getPerunNotifTemplateMessages()) {
insertPerunNotifTemplateMessageToLoader(stringTemplateLoader, pattern);
}
}
// create evaluation freemarker template
stringTemplateLoader.putTemplate(EVALUATION_TEMPLATE, "");
//All templates loaded to freemarker configuration
configuration = createFreemarkerConfiguration(stringTemplateLoader);
session = NotifUtils.getPerunSession(perun);
}
Aggregations