use of com.thinkbiganalytics.alerts.rest.model.AlertSummaryGrouped 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();
}
use of com.thinkbiganalytics.alerts.rest.model.AlertSummaryGrouped in project kylo by Teradata.
the class AlertsCache method fetchUnhandledAlerts.
protected List<AlertSummaryGrouped> fetchUnhandledAlerts() {
List<AlertSummary> alerts = new ArrayList<>();
AlertCriteria criteria = alertProvider.criteria();
new AlertCriteriaInput.Builder().state(Alert.State.UNHANDLED).asServiceAccount(true).onlyIfChangesDetected(true).applyToCriteria(criteria);
Iterator<? extends AlertSummary> itr = alertProvider.getAlertsSummary(criteria);
if (itr.hasNext()) {
itr.forEachRemaining(alerts::add);
List<AlertSummaryGrouped> latestAlerts = new ArrayList<>(alertsModel.groupAlertSummaries(alerts));
return latestAlerts;
} else {
return Collections.emptyList();
}
}
Aggregations