use of com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert in project kylo by Teradata.
the class KyloEntityAwareAlertCriteria method createEntityQuery.
public JPAQuery<JpaAlert> createEntityQuery() {
QJpaAlert alert = QJpaAlert.jpaAlert;
JPAQuery<JpaAlert> query = queryFactory.select(alert).from(alert).limit(getLimit());
List<Predicate> preds = filter(alert);
addEntityFilter(alert, preds);
if (entityCriteria == null || entityCriteria.isEmpty()) {
log.warn("Unable to apply Entity Query. No Entity Criteria was specified!");
preds.add(Expressions.stringTemplate("1").eq(Expressions.stringTemplate("2")));
}
return super.addWhere(query, preds, new BooleanBuilder());
}
use of com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert in project kylo by Teradata.
the class DefaultAlertManager method clearAlert.
protected JpaAlert clearAlert(JpaAlert.AlertId id) {
JpaAlert jpaAlert = this.metadataAccess.commit(() -> {
JpaAlert alert = repository.findOne(id);
alert.setCleared(true);
return alert;
}, MetadataAccess.SERVICE);
updateLastUpdatedTime();
return jpaAlert;
}
use of com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert in project kylo by Teradata.
the class DefaultAlertManager method unclearAlert.
protected JpaAlert unclearAlert(JpaAlert.AlertId id) {
JpaAlert jpaAlert = this.metadataAccess.commit(() -> {
JpaAlert alert = repository.findOne(id);
alert.setCleared(false);
return alert;
}, MetadataAccess.SERVICE);
updateLastUpdatedTime();
return jpaAlert;
}
use of com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert in project kylo by Teradata.
the class DefaultAlertManager method changeAlert.
protected <C extends Serializable> Alert changeAlert(JpaAlert.AlertId id, State state, String descr, C content) {
final Principal user = SecurityContextHolder.getContext().getAuthentication() != null ? SecurityContextHolder.getContext().getAuthentication() : null;
Alert changed = this.metadataAccess.commit(() -> {
JpaAlert alert = findAlert(id).orElseThrow(() -> new AlertNotfoundException(id));
JpaAlertChangeEvent event = new JpaAlertChangeEvent(state, user, descr, content);
alert.addEvent(event);
// need to save it
repository.save(alert);
return asValue(alert);
}, MetadataAccess.SERVICE);
updateLastUpdatedTime();
notifyReceivers(1);
return changed;
}
use of com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert in project kylo by Teradata.
the class KyloEntityAwareAlertManager method entityDeleted.
public Iterator<Alert> entityDeleted(AlertCriteria criteria, String message) {
log.info("Query for Entity Alerts data");
List<Alert> handledAlerts = this.metadataAccess.commit(() -> {
List<Alert> alerts = new ArrayList<>();
criteria.state(Alert.State.UNHANDLED);
KyloEntityAwareAlertCriteria critImpl = ensureAlertCriteriaType(criteria);
critImpl.createEntityQuery().fetch().stream().forEach(jpaAlert -> {
JpaAlertChangeEvent event = new JpaAlertChangeEvent(Alert.State.HANDLED, MetadataAccess.SERVICE, message, null);
jpaAlert.addEvent(event);
// hide it
jpaAlert.setCleared(true);
alerts.add(asValue(jpaAlert));
});
return alerts;
}, MetadataAccess.SERVICE);
return handledAlerts.iterator();
}
Aggregations