Search in sources :

Example 1 with AlertChangeEvent

use of com.thinkbiganalytics.alerts.api.AlertChangeEvent in project kylo by Teradata.

the class DefaultAlertManager method updateAlertChangeEntry.

protected <C extends Serializable> Alert updateAlertChangeEntry(JpaAlert.AlertId id, 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));
        List<AlertChangeEvent> events = alert.getEvents();
        if (events != null && !events.isEmpty()) {
            JpaAlertChangeEvent event = (JpaAlertChangeEvent) events.get(0);
            event.setDescription(descr);
            event.setContent(content);
            event.setChangeTime(DateTime.now());
        }
        return asValue(alert);
    }, MetadataAccess.SERVICE);
    updateLastUpdatedTime();
    notifyReceivers(1);
    return changed;
}
Also used : AlertNotfoundException(com.thinkbiganalytics.alerts.api.AlertNotfoundException) JpaAlertChangeEvent(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlertChangeEvent) Alert(com.thinkbiganalytics.alerts.api.Alert) JpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert) JpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert) Principal(java.security.Principal) AlertChangeEvent(com.thinkbiganalytics.alerts.api.AlertChangeEvent) JpaAlertChangeEvent(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlertChangeEvent)

Aggregations

Alert (com.thinkbiganalytics.alerts.api.Alert)1 AlertChangeEvent (com.thinkbiganalytics.alerts.api.AlertChangeEvent)1 AlertNotfoundException (com.thinkbiganalytics.alerts.api.AlertNotfoundException)1 JpaAlert (com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert)1 JpaAlertChangeEvent (com.thinkbiganalytics.metadata.jpa.alerts.JpaAlertChangeEvent)1 Principal (java.security.Principal)1