Search in sources :

Example 6 with PerunNotifTemplate

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

Example 7 with PerunNotifTemplate

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;
}
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

PerunNotifTemplate (cz.metacentrum.perun.notif.entities.PerunNotifTemplate)7 PerunNotifReceiver (cz.metacentrum.perun.notif.entities.PerunNotifReceiver)3 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)2 PerunNotifRegex (cz.metacentrum.perun.notif.entities.PerunNotifRegex)2 PerunNotifTemplateMessage (cz.metacentrum.perun.notif.entities.PerunNotifTemplateMessage)2 PerunBean (cz.metacentrum.perun.core.api.PerunBean)1 GroupNotExistsException (cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException)1 PerunNotifEmailMessageToSendDto (cz.metacentrum.perun.notif.dto.PerunNotifEmailMessageToSendDto)1 PerunNotifMessageDto (cz.metacentrum.perun.notif.dto.PerunNotifMessageDto)1 PoolMessage (cz.metacentrum.perun.notif.dto.PoolMessage)1 PerunNotifPoolMessage (cz.metacentrum.perun.notif.entities.PerunNotifPoolMessage)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DateTime (org.joda.time.DateTime)1 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)1