Search in sources :

Example 1 with PerunNotifTemplateMessage

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;
}
Also used : PerunNotifTemplate(cz.metacentrum.perun.notif.entities.PerunNotifTemplate) PerunNotifTemplateMessage(cz.metacentrum.perun.notif.entities.PerunNotifTemplateMessage) PerunNotifReceiver(cz.metacentrum.perun.notif.entities.PerunNotifReceiver) PerunNotifRegex(cz.metacentrum.perun.notif.entities.PerunNotifRegex)

Example 2 with PerunNotifTemplateMessage

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;
}
Also used : PerunNotifTemplate(cz.metacentrum.perun.notif.entities.PerunNotifTemplate) PerunNotifTemplateMessage(cz.metacentrum.perun.notif.entities.PerunNotifTemplateMessage) PerunNotifReceiver(cz.metacentrum.perun.notif.entities.PerunNotifReceiver) PerunNotifRegex(cz.metacentrum.perun.notif.entities.PerunNotifRegex) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException)

Aggregations

PerunNotifReceiver (cz.metacentrum.perun.notif.entities.PerunNotifReceiver)2 PerunNotifRegex (cz.metacentrum.perun.notif.entities.PerunNotifRegex)2 PerunNotifTemplate (cz.metacentrum.perun.notif.entities.PerunNotifTemplate)2 PerunNotifTemplateMessage (cz.metacentrum.perun.notif.entities.PerunNotifTemplateMessage)2 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)1