Search in sources :

Example 1 with EntityAwareAlertSummary

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

the class AlertsModel method groupAlertSummaries.

public Collection<AlertSummaryGrouped> groupAlertSummaries(List<AlertSummary> alertSummaries) {
    Map<String, AlertSummaryGrouped> group = new HashMap<>();
    alertSummaries.forEach(alertSummary -> {
        String key = alertSummary.getType() + ":" + alertSummary.getSubtype();
        String displayName = alertTypeDisplayName(alertSummary);
        if (alertSummary instanceof EntityAwareAlertSummary) {
            EntityAwareAlertSummary entityAwareAlertSummary = (EntityAwareAlertSummary) alertSummary;
            key = entityAwareAlertSummary.getGroupByKey();
            group.computeIfAbsent(key, key1 -> new AlertSummaryGrouped.Builder().typeString(alertSummary.getType()).typeDisplayName(displayName).subType(entityAwareAlertSummary.getSubtype()).feedId(entityAwareAlertSummary.getFeedId() != null ? entityAwareAlertSummary.getFeedId().toString() : null).feedName(entityAwareAlertSummary.getFeedName()).slaId(entityAwareAlertSummary.getSlaId() != null ? entityAwareAlertSummary.getSlaId().toString() : null).slaName(entityAwareAlertSummary.getSlaName()).build()).add(toModel(alertSummary.getLevel()), alertSummary.getCount(), alertSummary.getLastAlertTimestamp());
        } else {
            group.computeIfAbsent(key, key1 -> new AlertSummaryGrouped.Builder().typeString(alertSummary.getType()).typeDisplayName(displayName).subType(alertSummary.getSubtype()).build()).add(toModel(alertSummary.getLevel()), alertSummary.getCount(), alertSummary.getLastAlertTimestamp());
        }
    });
    return group.values();
}
Also used : EntityAwareAlertSummary(com.thinkbiganalytics.metadata.api.alerts.EntityAwareAlertSummary) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) Proxy(java.lang.reflect.Proxy) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) SourceAlert(com.thinkbiganalytics.alerts.api.SourceAlert) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) EntityAwareAlertSummary(com.thinkbiganalytics.metadata.api.alerts.EntityAwareAlertSummary) AlertSummary(com.thinkbiganalytics.alerts.api.AlertSummary) ObjectMapperSerializer(com.thinkbiganalytics.json.ObjectMapperSerializer) EntityAlert(com.thinkbiganalytics.alerts.api.EntityAlert) Component(org.springframework.stereotype.Component) List(java.util.List) AlertConstants(com.thinkbiganalytics.alerts.AlertConstants) Map(java.util.Map) Alert(com.thinkbiganalytics.alerts.rest.model.Alert) AlertSummaryGrouped(com.thinkbiganalytics.alerts.rest.model.AlertSummaryGrouped) HashMap(java.util.HashMap) AlertSummaryGrouped(com.thinkbiganalytics.alerts.rest.model.AlertSummaryGrouped)

Aggregations

AlertConstants (com.thinkbiganalytics.alerts.AlertConstants)1 AlertSummary (com.thinkbiganalytics.alerts.api.AlertSummary)1 EntityAlert (com.thinkbiganalytics.alerts.api.EntityAlert)1 SourceAlert (com.thinkbiganalytics.alerts.api.SourceAlert)1 Alert (com.thinkbiganalytics.alerts.rest.model.Alert)1 AlertSummaryGrouped (com.thinkbiganalytics.alerts.rest.model.AlertSummaryGrouped)1 ObjectMapperSerializer (com.thinkbiganalytics.json.ObjectMapperSerializer)1 EntityAwareAlertSummary (com.thinkbiganalytics.metadata.api.alerts.EntityAwareAlertSummary)1 Proxy (java.lang.reflect.Proxy)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Component (org.springframework.stereotype.Component)1