use of cz.metacentrum.perun.notif.entities.PerunNotifObject in project perun by CESNET.
the class PerunNotifRegexDaoImpl method getPerunNotifRegexForTemplateId.
@Override
public Set<PerunNotifRegex> getPerunNotifRegexForTemplateId(int id) throws InternalErrorException {
logger.debug("Loading regexes for template with id: {}", id);
List<PerunNotifRegex> regexes = this.getJdbcTemplate().query("SELECT * from pn_regex regex JOIN pn_template_regex bind ON regex.id=bind.regex_id WHERE bind.template_id = ?", new Object[] { id }, PerunNotifRegex.PERUN_NOTIF_REGEX);
if (regexes != null) {
for (PerunNotifRegex regex : regexes) {
List<PerunNotifObject> objects = this.getJdbcTemplate().query("SELECT * from pn_object object JOIN pn_regex_object bind ON object.id = bind.object_id WHERE bind.regex_id = ?", new Object[] { regex.getId() }, PerunNotifObject.PERUN_NOTIF_OBJECT);
regex.addObjects(objects);
}
}
logger.debug("Regexes loaded with object for template id: {}, result: {}", Arrays.asList(id, regexes));
return new HashSet<PerunNotifRegex>(regexes);
}
use of cz.metacentrum.perun.notif.entities.PerunNotifObject in project perun by CESNET.
the class PerunNotifObjectDaoImpl method getPerunNotifObjectById.
@Override
public PerunNotifObject getPerunNotifObjectById(int id) throws InternalErrorException {
logger.debug("Getting PerunNotifObject from db by id: {}", id);
try {
PerunNotifObject object = this.getJdbcTemplate().queryForObject("SELECT * FROM pn_object object where object.id = ?", new Object[] { id }, PerunNotifObject.PERUN_NOTIF_OBJECT);
logger.debug("PerunNotifObject retrieved from db: {}", object);
return object;
} catch (EmptyResultDataAccessException ex) {
logger.debug("PerunNotifObject with id: {} not found.", id);
return null;
}
}
use of cz.metacentrum.perun.notif.entities.PerunNotifObject in project perun by CESNET.
the class PerunNotifRegexDaoImpl method getAll.
@Override
public List<PerunNotifRegex> getAll() {
logger.debug("Getting all PerunNotifRegexes from db.");
List<PerunNotifRegex> result = this.getJdbcTemplate().query("SELECT * from pn_regex ", PerunNotifRegex.PERUN_NOTIF_REGEX);
logger.debug("Regexes loaded from db: {}, loading objects.", result);
for (PerunNotifRegex regex : result) {
List<PerunNotifObject> objects = this.getJdbcTemplate().query("SELECT * from pn_object object JOIN pn_regex_object bind ON object.id = bind.object_id WHERE bind.regex_id = ?", new Object[] { regex.getId() }, PerunNotifObject.PERUN_NOTIF_OBJECT);
regex.addObjects(objects);
}
logger.debug("Objects loaded, resulting regexes: {}", result);
return result;
}
use of cz.metacentrum.perun.notif.entities.PerunNotifObject in project perun by CESNET.
the class PerunNotifRegexDaoImpl method getPerunNotifRegexById.
@Override
public PerunNotifRegex getPerunNotifRegexById(int id) throws InternalErrorException {
logger.debug("Loading regex from db by id: {}", id);
PerunNotifRegex regex = null;
try {
regex = this.getJdbcTemplate().queryForObject("SELECT * from pn_regex where id = ?", new Object[] { id }, PerunNotifRegex.PERUN_NOTIF_REGEX);
} catch (EmptyResultDataAccessException ex) {
logger.debug("Regex with id: {}, not found.", id);
return null;
}
logger.debug("Regex with id: {}, loaded from db. Loading objects.", id);
List<PerunNotifObject> objects = this.getJdbcTemplate().query("SELECT * from pn_object object JOIN pn_regex_object bind ON object.id = bind.object_id WHERE bind.regex_id = ?", new Object[] { regex.getId() }, PerunNotifObject.PERUN_NOTIF_OBJECT);
regex.addObjects(objects);
logger.debug("Objects loaded result: {}", regex);
return regex;
}
use of cz.metacentrum.perun.notif.entities.PerunNotifObject in project perun by CESNET.
the class PerunNotifObjectManagerImpl method removePerunNotifObjectById.
@Override
public void removePerunNotifObjectById(int id) throws InternalErrorException {
PerunNotifObject objectToRemove = getPerunNotifObjectById(id);
if (objectToRemove == null) {
throw new NotExistsException("Object does not exists in db.");
}
perunNotifObjectDao.removePerunNotifObjectById(id);
perunNotifRegexManager.removePerunNotifObjectFromCache(objectToRemove);
}
Aggregations