Search in sources :

Example 6 with JpaAlert

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());
}
Also used : QJpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert) BooleanBuilder(com.querydsl.core.BooleanBuilder) JpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert) QJpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert) Predicate(com.querydsl.core.types.Predicate)

Example 7 with JpaAlert

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;
}
Also used : JpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert)

Example 8 with 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;
}
Also used : JpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert)

Example 9 with 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;
}
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)

Example 10 with JpaAlert

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();
}
Also used : KyloEntityAwareAlertCriteria(com.thinkbiganalytics.alerts.spi.defaults.KyloEntityAwareAlertCriteria) ArrayList(java.util.ArrayList) JpaAlertChangeEvent(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlertChangeEvent) Alert(com.thinkbiganalytics.alerts.api.Alert) JpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert) EntityAlert(com.thinkbiganalytics.alerts.api.EntityAlert)

Aggregations

JpaAlert (com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert)10 Alert (com.thinkbiganalytics.alerts.api.Alert)4 BooleanBuilder (com.querydsl.core.BooleanBuilder)3 Predicate (com.querydsl.core.types.Predicate)3 JpaAlertChangeEvent (com.thinkbiganalytics.metadata.jpa.alerts.JpaAlertChangeEvent)3 QJpaAlert (com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert)3 Principal (java.security.Principal)3 AlertNotfoundException (com.thinkbiganalytics.alerts.api.AlertNotfoundException)2 AlertChangeEvent (com.thinkbiganalytics.alerts.api.AlertChangeEvent)1 EntityAlert (com.thinkbiganalytics.alerts.api.EntityAlert)1 EntityIdentificationAlertContent (com.thinkbiganalytics.alerts.spi.EntityIdentificationAlertContent)1 KyloEntityAwareAlertCriteria (com.thinkbiganalytics.alerts.spi.defaults.KyloEntityAwareAlertCriteria)1 AlertId (com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert.AlertId)1 QJpaOpsManagerFeed (com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed)1 QJpaServiceLevelAgreementDescription (com.thinkbiganalytics.metadata.jpa.sla.QJpaServiceLevelAgreementDescription)1 ArrayList (java.util.ArrayList)1