Search in sources :

Example 1 with SeverityInfo

use of org.opennms.features.geolocation.api.SeverityInfo in project opennms by OpenNMS.

the class DefaultGeolocationService method applyStatus.

private void applyStatus(GeolocationQuery query, List<GeolocationInfo> locations) {
    final Set<Integer> nodeIds = locations.stream().map(l -> l.getNodeInfo().getNodeId()).collect(Collectors.toSet());
    if (!nodeIds.isEmpty()) {
        final StatusCalculator calculator = getStatusCalculator(query.getStatusCalculationStrategy());
        final Status status = calculator.calculateStatus(query, nodeIds);
        // Appliing the calculated status to each location
        for (GeolocationInfo info : locations) {
            OnmsSeverity severity = status.getSeverity(info.getNodeInfo().getNodeId());
            // Therefore for all locations with no status must be set to "NORMAL" in the result
            if (severity == null) {
                severity = OnmsSeverity.NORMAL;
            }
            info.setSeverityInfo(new SeverityInfo(severity.getId(), severity.getLabel()));
            info.setAlarmUnackedCount(status.getUnacknowledgedAlarmCount(info.getNodeInfo().getNodeId()));
        }
    }
}
Also used : AddressInfo(org.opennms.features.geolocation.api.AddressInfo) OutageStatusCalculator(org.opennms.features.geolocation.services.status.OutageStatusCalculator) Status(org.opennms.features.geolocation.services.status.Status) LoggerFactory(org.slf4j.LoggerFactory) ArrayList(java.util.ArrayList) Coordinates(org.opennms.features.geolocation.api.Coordinates) StatusCalculator(org.opennms.features.geolocation.services.status.StatusCalculator) GeolocationInfo(org.opennms.features.geolocation.api.GeolocationInfo) GenericPersistenceAccessor(org.opennms.netmgt.dao.api.GenericPersistenceAccessor) OnmsNode(org.opennms.netmgt.model.OnmsNode) Logger(org.slf4j.Logger) InetAddressUtils(org.opennms.core.utils.InetAddressUtils) Set(java.util.Set) SeverityInfo(org.opennms.features.geolocation.api.SeverityInfo) Collectors(java.util.stream.Collectors) Restrictions(org.opennms.core.criteria.restrictions.Restrictions) Objects(java.util.Objects) OnmsGeolocation(org.opennms.netmgt.model.OnmsGeolocation) List(java.util.List) GeolocationQuery(org.opennms.features.geolocation.api.GeolocationQuery) NodeInfo(org.opennms.features.geolocation.api.NodeInfo) StatusCalculationStrategy(org.opennms.features.geolocation.api.StatusCalculationStrategy) AlarmStatusCalculator(org.opennms.features.geolocation.services.status.AlarmStatusCalculator) CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) GeolocationResolver(org.opennms.features.geolocation.api.GeolocationResolver) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) GeolocationService(org.opennms.features.geolocation.api.GeolocationService) Status(org.opennms.features.geolocation.services.status.Status) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) SeverityInfo(org.opennms.features.geolocation.api.SeverityInfo) OutageStatusCalculator(org.opennms.features.geolocation.services.status.OutageStatusCalculator) StatusCalculator(org.opennms.features.geolocation.services.status.StatusCalculator) AlarmStatusCalculator(org.opennms.features.geolocation.services.status.AlarmStatusCalculator) GeolocationInfo(org.opennms.features.geolocation.api.GeolocationInfo)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)1 Restrictions (org.opennms.core.criteria.restrictions.Restrictions)1 InetAddressUtils (org.opennms.core.utils.InetAddressUtils)1 AddressInfo (org.opennms.features.geolocation.api.AddressInfo)1 Coordinates (org.opennms.features.geolocation.api.Coordinates)1 GeolocationInfo (org.opennms.features.geolocation.api.GeolocationInfo)1 GeolocationQuery (org.opennms.features.geolocation.api.GeolocationQuery)1 GeolocationResolver (org.opennms.features.geolocation.api.GeolocationResolver)1 GeolocationService (org.opennms.features.geolocation.api.GeolocationService)1 NodeInfo (org.opennms.features.geolocation.api.NodeInfo)1 SeverityInfo (org.opennms.features.geolocation.api.SeverityInfo)1 StatusCalculationStrategy (org.opennms.features.geolocation.api.StatusCalculationStrategy)1 AlarmStatusCalculator (org.opennms.features.geolocation.services.status.AlarmStatusCalculator)1 OutageStatusCalculator (org.opennms.features.geolocation.services.status.OutageStatusCalculator)1 Status (org.opennms.features.geolocation.services.status.Status)1