use of cz.metacentrum.perun.notif.entities.PerunNotifTemplateMessage in project perun by CESNET.
the class PerunNotifTemplateDaoImpl method getAllPerunNotifTemplates.
public List<PerunNotifTemplate> getAllPerunNotifTemplates() {
List<PerunNotifTemplate> result = this.getJdbcTemplate().query("SELECT * from pn_template", PerunNotifTemplate.PERUN_NOTIF_TEMPLATE);
for (PerunNotifTemplate template : result) {
// Gets all template ids which are connected to given regexIds
Set<PerunNotifRegex> perunNotifRegexs = perunNotifRegexDao.getPerunNotifRegexForTemplateId(template.getId());
template.setMatchingRegexs(perunNotifRegexs);
List<PerunNotifReceiver> perunNotifReceiver = this.getJdbcTemplate().query("SELECT * from pn_receiver where template_id = ?", new Object[] { template.getId() }, PerunNotifReceiver.PERUN_NOTIF_RECEIVER);
template.setReceivers(perunNotifReceiver);
List<PerunNotifTemplateMessage> perunNotifTemplateMessages = this.getJdbcTemplate().query("SELECT * from pn_template_message where template_id = ?", new Object[] { template.getId() }, PerunNotifTemplateMessage.PERUN_NOTIF_TEMPLATE_MESSAGE_ROW_MAPPER);
template.setPerunNotifTemplateMessages(perunNotifTemplateMessages);
}
return result;
}
use of cz.metacentrum.perun.notif.entities.PerunNotifTemplateMessage in project perun by CESNET.
the class PerunNotifTemplateDaoImpl method getPerunNotifTemplateById.
@Override
public PerunNotifTemplate getPerunNotifTemplateById(int id) {
PerunNotifTemplate template = null;
try {
template = this.getJdbcTemplate().queryForObject("SELECT * from pn_template where id = ?", new Object[] { id }, PerunNotifTemplate.PERUN_NOTIF_TEMPLATE);
} catch (EmptyResultDataAccessException ex) {
// This exception is thrown when object is not found
return null;
}
Set<PerunNotifRegex> regexes = perunNotifRegexDao.getPerunNotifRegexForTemplateId(template.getId());
template.setMatchingRegexs(regexes);
List<PerunNotifReceiver> perunNotifReceiver = this.getJdbcTemplate().query("SELECT * from pn_receiver where template_id = ?", new Object[] { template.getId() }, PerunNotifReceiver.PERUN_NOTIF_RECEIVER);
template.setReceivers(perunNotifReceiver);
List<PerunNotifTemplateMessage> perunNotifTemplateMessages = this.getJdbcTemplate().query("SELECT * from pn_template_message where template_id = ?", new Object[] { template.getId() }, PerunNotifTemplateMessage.PERUN_NOTIF_TEMPLATE_MESSAGE_ROW_MAPPER);
template.setPerunNotifTemplateMessages(perunNotifTemplateMessages);
return template;
}
Aggregations