Search in sources :

Example 1 with NodeInfo

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

the class NodeMapComponent method createMapNode.

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;
}
Also used : NodeInfo(org.opennms.features.geolocation.api.NodeInfo) MapNode(org.opennms.features.vaadin.nodemaps.internal.gwt.client.MapNode)

Example 2 with NodeInfo

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

the class DefaultGeolocationService method convert.

private GeolocationInfo convert(OnmsNode node) {
    GeolocationInfo geolocationInfo = new GeolocationInfo();
    // Coordinates
    OnmsGeolocation onmsGeolocation = geoLocation(node);
    if (onmsGeolocation != null) {
        geolocationInfo.setAddressInfo(toAddressInfo(onmsGeolocation));
        if (onmsGeolocation.getLongitude() != null && onmsGeolocation.getLatitude() != null) {
            geolocationInfo.setCoordinates(new Coordinates(onmsGeolocation.getLongitude(), onmsGeolocation.getLatitude()));
        }
    }
    // NodeInfo
    NodeInfo nodeInfo = new NodeInfo();
    nodeInfo.setNodeId(node.getId());
    nodeInfo.setNodeLabel(node.getLabel());
    nodeInfo.setNodeLabel(node.getLabel());
    nodeInfo.setForeignSource(node.getForeignSource());
    nodeInfo.setForeignId(node.getForeignId());
    nodeInfo.setLocation(node.getLocation().getLocationName());
    if (node.getAssetRecord() != null) {
        nodeInfo.setDescription(node.getAssetRecord().getDescription());
        nodeInfo.setMaintcontract(node.getAssetRecord().getMaintcontract());
    }
    if (node.getPrimaryInterface() != null) {
        nodeInfo.setIpAddress(InetAddressUtils.str(node.getPrimaryInterface().getIpAddress()));
    }
    nodeInfo.setCategories(node.getCategories().stream().map(OnmsCategory::getName).collect(Collectors.toList()));
    geolocationInfo.setNodeInfo(nodeInfo);
    return geolocationInfo;
}
Also used : OnmsCategory(org.opennms.netmgt.model.OnmsCategory) NodeInfo(org.opennms.features.geolocation.api.NodeInfo) Coordinates(org.opennms.features.geolocation.api.Coordinates) GeolocationInfo(org.opennms.features.geolocation.api.GeolocationInfo) OnmsGeolocation(org.opennms.netmgt.model.OnmsGeolocation)

Aggregations

NodeInfo (org.opennms.features.geolocation.api.NodeInfo)2 Coordinates (org.opennms.features.geolocation.api.Coordinates)1 GeolocationInfo (org.opennms.features.geolocation.api.GeolocationInfo)1 MapNode (org.opennms.features.vaadin.nodemaps.internal.gwt.client.MapNode)1 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)1 OnmsGeolocation (org.opennms.netmgt.model.OnmsGeolocation)1