protected void updateGeolocation(GeolocationResolver geolocationResolver, OnmsNode node) { Objects.requireNonNull(geolocationResolver); Objects.requireNonNull(node); // Only resolve long/lat if not already set and an address is set final OnmsGeolocation geolocation = node.getAssetRecord().getGeolocation(); if (geolocation != null && geolocation.getLatitude() == null && geolocation.getLatitude() == null && !Strings.isNullOrEmpty(geolocation.asAddressString())) { final Coordinates coordinates = geolocationResolver.resolve(geolocation.asAddressString()); if (coordinates != null) { geolocation.setLongitude(coordinates.getLongitude()); geolocation.setLatitude(coordinates.getLatitude()); nodeDao.saveOrUpdate(node); } else { LOG.warn("Could not resolve address string '{}' for node with id {}", geolocation.asAddressString(), node.getId()); } } }
@Override public Coordinates resolve(String addressString) { try { org.opennms.features.geocoder.Coordinates coordinates = geocoderService.getCoordinates(addressString); if (coordinates != null) { return new Coordinates(coordinates.getLongitude(), coordinates.getLatitude()); } else { LOG.warn("Couldn't resolve address '{}'", addressString); } } catch (GeocoderException e) { LOG.warn("Couldn't resolve address '{}'", addressString, e); } return null; }
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; } }
@Override public Coordinates resolve(String addressString) { try { org.opennms.features.geocoder.Coordinates coordinates = geocoderService.getCoordinates(addressString); if (coordinates != null) { return new Coordinates(coordinates.getLongitude(), coordinates.getLatitude()); } else { LOG.warn("Couldn't resolve address '{}'", addressString); } } catch (GeocoderException e) { LOG.warn("Couldn't resolve address '{}'", addressString, e); } return null; }
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; } }
geolocationInfo.setAddressInfo(toAddressInfo(onmsGeolocation)); if (onmsGeolocation.getLongitude() != null && onmsGeolocation.getLatitude() != null) { geolocationInfo.setCoordinates(new Coordinates(onmsGeolocation.getLongitude(), onmsGeolocation.getLatitude()));
geolocationInfo.setAddressInfo(toAddressInfo(onmsGeolocation)); if (onmsGeolocation.getLongitude() != null && onmsGeolocation.getLatitude() != null) { geolocationInfo.setCoordinates(new Coordinates(onmsGeolocation.getLongitude(), onmsGeolocation.getLatitude()));