use of cz.metacentrum.perun.notif.entities.PerunNotifTemplate in project perun by CESNET.
the class PerunNotifTemplateDaoImpl method saveTemplateRegexRelation.
@Override
public void saveTemplateRegexRelation(int templateId, Integer regexId) throws InternalErrorException {
if (perunNotifRegexDao.isRegexRelation(templateId, regexId)) {
//Relation exists
return;
} else {
perunNotifRegexDao.saveTemplateRegexRelation(templateId, regexId);
PerunNotifTemplate template = getPerunNotifTemplateById(templateId);
template.addPerunNotifRegex(perunNotifRegexDao.getPerunNotifRegexById(regexId));
}
}
use of cz.metacentrum.perun.notif.entities.PerunNotifTemplate in project perun by CESNET.
the class PerunNotifTemplateDaoImpl method getPerunNotifTemplateById.
@Override
public PerunNotifTemplate getPerunNotifTemplateById(int id) throws InternalErrorException {
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