@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; }
@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; } }
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; } }