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 Status status = calculateStatus(query, nodeIds); // Appliing the calculated status to each location for(GeolocationInfo info : locations) { OnmsSeverity severity = status.getSeverity(info.getNodeInfo().getNodeId()); // After the status was calculated, it is not guaranteed that status.size() == locations.size() // 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())); } } }
private static MapNode createMapNode(GeolocationInfo geolocationInfo) { final MapNode node = new MapNode(); // Coordinates if (geolocationInfo.getCoordinates() != null) { node.setLatitude(geolocationInfo.getCoordinates().getLatitude()); node.setLongitude(geolocationInfo.getCoordinates().getLongitude()); } // Node Info final NodeInfo nodeInfo = geolocationInfo.getNodeInfo(); node.setNodeId(String.valueOf(nodeInfo.getNodeId())); node.setNodeLabel(nodeInfo.getNodeLabel()); node.setForeignSource(nodeInfo.getForeignSource()); node.setForeignId(nodeInfo.getForeignId()); node.setIpAddress(nodeInfo.getIpAddress()); node.setDescription(nodeInfo.getDescription()); node.setMaintcontract(nodeInfo.getMaintcontract()); node.setCategories(new ArrayList<>(nodeInfo.getCategories())); // Severity node.setSeverityLabel(geolocationInfo.getSeverityInfo().getLabel()); node.setSeverity(String.valueOf(geolocationInfo.getSeverityInfo().getId())); // Count node.setUnackedCount(geolocationInfo.getAlarmUnackedCount()); return node; } }
.build()); final List<Marker> markers = locations.stream() .filter(locationInfo -> locationInfo.getCoordinates() != null) .map(locationInfo -> { final Vertex vertex = vertices.stream() .filter(v -> v.getNodeID() != null && locationInfo.getNodeInfo().getNodeId() == v.getNodeID()) .findFirst() .get(); return new Marker( locationInfo.getCoordinates(), createTooltip(vertex, locationInfo.getAddressInfo()), container.getSelectionManager().isVertexRefSelected(vertex)); }).collect(Collectors.toList());
private GeolocationInfo convert(OnmsNode node) { GeolocationInfo geolocationInfo = new GeolocationInfo(); geolocationInfo.setAddressInfo(toAddressInfo(onmsGeolocation)); if (onmsGeolocation.getLongitude() != null && onmsGeolocation.getLatitude() != null) { geolocationInfo.setCoordinates(new Coordinates(onmsGeolocation.getLongitude(), onmsGeolocation.getLatitude())); .map(OnmsCategory::getName) .collect(Collectors.toList())); geolocationInfo.setNodeInfo(nodeInfo); return geolocationInfo;
public void refresh() { List<GeolocationInfo> locations = geolocationService.getLocations(new GeolocationQueryBuilder() .withIncludeAcknowledgedAlarms(false) .withStatusCalculationStrategy(StatusCalculationStrategy.Alarms) .withSeverity(GeolocationSeverity.Normal) .build()); // apply acl filter if enabled if (m_aclsEnabled) { Map<Integer, String> nodes = m_nodeDao.getAllLabelsById(); locations = locations.stream() .filter(l -> nodes.containsKey(l.getNodeInfo().getNodeId())) .collect(Collectors.toList()); } // Convert m_activeNodes = locations.stream() .map(NodeMapComponent::createMapNode) .collect(Collectors.toMap(l -> Integer.valueOf(l.getNodeId()), Function.identity())); showNodes(m_activeNodes); }
@Override public List<GeolocationInfo> getLocations(GeolocationQuery query) { if (query == null) { return new ArrayList<>(); } final List<OnmsNode> nodes = getNodes(query); final List<GeolocationInfo> nodesWithCoordinates = nodes.stream() .filter(n -> geoLocation(n) != null && geoLocation(n).getLongitude() != null && geoLocation(n).getLatitude() != null) // Avoid including -inf values, just in case. See NMS-9338 .filter(n -> geoLocation(n).getLatitude() != Double.NEGATIVE_INFINITY && geoLocation(n).getLongitude() != Double.NEGATIVE_INFINITY) .map(this::convert) .collect(Collectors.toList()); if (query.getStatusCalculationStrategy() != null) { applyStatus(query, nodesWithCoordinates); } if (query.getSeverity() != null) { OnmsSeverity severity = OnmsSeverity.get(query.getSeverity().getId()); return nodesWithCoordinates.stream() .filter(n -> severity.getId() <= n.getSeverityInfo().getId()) .collect(Collectors.toList()); } return nodesWithCoordinates; }
private static MapNode createMapNode(GeolocationInfo geolocationInfo) { final MapNode node = new MapNode(); // Coordinates if (geolocationInfo.getCoordinates() != null) { node.setLatitude(geolocationInfo.getCoordinates().getLatitude()); node.setLongitude(geolocationInfo.getCoordinates().getLongitude()); } // Node Info final NodeInfo nodeInfo = geolocationInfo.getNodeInfo(); node.setNodeId(String.valueOf(nodeInfo.getNodeId())); node.setNodeLabel(nodeInfo.getNodeLabel()); node.setForeignSource(nodeInfo.getForeignSource()); node.setForeignId(nodeInfo.getForeignId()); node.setIpAddress(nodeInfo.getIpAddress()); node.setDescription(nodeInfo.getDescription()); node.setMaintcontract(nodeInfo.getMaintcontract()); node.setCategories(new ArrayList<>(nodeInfo.getCategories())); // Severity node.setSeverityLabel(geolocationInfo.getSeverityInfo().getLabel()); node.setSeverity(String.valueOf(geolocationInfo.getSeverityInfo().getId())); // Count node.setUnackedCount(geolocationInfo.getAlarmUnackedCount()); return node; } }
.build()); final List<Marker> markers = locations.stream() .filter(locationInfo -> locationInfo.getCoordinates() != null) .map(locationInfo -> { final Vertex vertex = vertices.stream() .filter(v -> v.getNodeID() != null && locationInfo.getNodeInfo().getNodeId() == v.getNodeID()) .findFirst() .get(); return new Marker( locationInfo.getCoordinates(), createTooltip(vertex, locationInfo.getAddressInfo()), container.getSelectionManager().isVertexRefSelected(vertex)); }).collect(Collectors.toList());
private GeolocationInfo convert(OnmsNode node) { GeolocationInfo geolocationInfo = new GeolocationInfo(); geolocationInfo.setAddressInfo(toAddressInfo(onmsGeolocation)); if (onmsGeolocation.getLongitude() != null && onmsGeolocation.getLatitude() != null) { geolocationInfo.setCoordinates(new Coordinates(onmsGeolocation.getLongitude(), onmsGeolocation.getLatitude())); .map(OnmsCategory::getName) .collect(Collectors.toList())); geolocationInfo.setNodeInfo(nodeInfo); return geolocationInfo;
public void refresh() { List<GeolocationInfo> locations = geolocationService.getLocations(new GeolocationQueryBuilder() .withIncludeAcknowledgedAlarms(false) .withStatusCalculationStrategy(StatusCalculationStrategy.Alarms) .withSeverity(GeolocationSeverity.Normal) .build()); // apply acl filter if enabled if (m_aclsEnabled) { Map<Integer, String> nodes = m_nodeDao.getAllLabelsById(); locations = locations.stream() .filter(l -> nodes.containsKey(l.getNodeInfo().getNodeId())) .collect(Collectors.toList()); } // Convert m_activeNodes = locations.stream() .map(NodeMapComponent::createMapNode) .collect(Collectors.toMap(l -> Integer.valueOf(l.getNodeId()), Function.identity())); showNodes(m_activeNodes); }
@Override public List<GeolocationInfo> getLocations(GeolocationQuery query) { if (query == null) { return new ArrayList<>(); } final List<OnmsNode> nodes = getNodes(query); final List<GeolocationInfo> nodesWithCoordinates = nodes.stream() .filter(n -> geoLocation(n) != null && geoLocation(n).getLongitude() != null && geoLocation(n).getLatitude() != null) // Avoid including -inf values, just in case. See NMS-9338 .filter(n -> geoLocation(n).getLatitude() != Double.NEGATIVE_INFINITY && geoLocation(n).getLongitude() != Double.NEGATIVE_INFINITY) .map(this::convert) .collect(Collectors.toList()); if (query.getStatusCalculationStrategy() != null) { applyStatus(query, nodesWithCoordinates); } if (query.getSeverity() != null) { OnmsSeverity severity = OnmsSeverity.get(query.getSeverity().getId()); return nodesWithCoordinates.stream() .filter(n -> severity.getId() <= n.getSeverityInfo().getId()) .collect(Collectors.toList()); } return nodesWithCoordinates; }
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 Status status = calculateStatus(query, nodeIds); // Appliing the calculated status to each location for(GeolocationInfo info : locations) { OnmsSeverity severity = status.getSeverity(info.getNodeInfo().getNodeId()); // After the status was calculated, it is not guaranteed that status.size() == locations.size() // 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())); } } }