use of org.thingsboard.server.common.data.page.TimePageData in project thingsboard by thingsboard.
the class BaseAlarmService method findHighestAlarmSeverity.
@Override
public AlarmSeverity findHighestAlarmSeverity(EntityId entityId, AlarmSearchStatus alarmSearchStatus, AlarmStatus alarmStatus) {
TimePageLink nextPageLink = new TimePageLink(100);
boolean hasNext = true;
AlarmSeverity highestSeverity = null;
AlarmQuery query;
while (hasNext && AlarmSeverity.CRITICAL != highestSeverity) {
query = new AlarmQuery(entityId, nextPageLink, alarmSearchStatus, alarmStatus, false);
List<AlarmInfo> alarms;
try {
alarms = alarmDao.findAlarms(query).get();
} catch (ExecutionException | InterruptedException e) {
log.warn("Failed to find highest alarm severity. EntityId: [{}], AlarmSearchStatus: [{}], AlarmStatus: [{}]", entityId, alarmSearchStatus, alarmStatus);
throw new RuntimeException(e);
}
hasNext = alarms.size() == nextPageLink.getLimit();
if (hasNext) {
nextPageLink = new TimePageData<>(alarms, nextPageLink).getNextPageLink();
}
AlarmSeverity severity = detectHighestSeverity(alarms);
if (severity == null) {
continue;
}
if (severity == AlarmSeverity.CRITICAL || highestSeverity == null) {
highestSeverity = severity;
} else {
highestSeverity = highestSeverity.compareTo(severity) < 0 ? highestSeverity : severity;
}
}
return highestSeverity;
}
Aggregations