Search in sources :

Example 1 with Node

use of org.opennms.features.topology.netutils.internal.Node in project opennms by OpenNMS.

the class EventsAlarmsOperation method execute.

@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
    try {
        String label = "";
        int nodeID = -1;
        if (targets != null) {
            for (final VertexRef target : targets) {
                final String labelValue = getLabelValue(operationContext, target);
                final Integer nodeValue = getNodeIdValue(operationContext, target);
                if (nodeValue != null && nodeValue > 0) {
                    label = labelValue == null ? "" : labelValue;
                    nodeID = nodeValue;
                    break;
                }
            }
        }
        final Node node = new Node(nodeID, null, label);
        final String eventUrl;
        final String alarmUrl;
        if (node.getNodeID() >= 0) {
            eventUrl = getEventsURL() + "?filter=node%3D" + node.getNodeID();
            alarmUrl = getAlarmsURL() + "?sortby=id&acktype=unacklimit=20&filter=node%3D" + node.getNodeID();
        } else {
            eventUrl = getEventsURL();
            alarmUrl = getAlarmsURL();
        }
        final URL fullEventUrl = new URL(getFullUrl(eventUrl));
        final URL fullAlarmUrl = new URL(getFullUrl(alarmUrl));
        operationContext.getMainWindow().addWindow(new EventsAlarmsWindow(node, fullEventUrl, fullAlarmUrl));
    } catch (final Exception e) {
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        } else {
            throw new RuntimeException("Failed to create event/alarm window.", e);
        }
    }
}
Also used : EventsAlarmsWindow(org.opennms.features.topology.netutils.internal.EventsAlarmsWindow) Node(org.opennms.features.topology.netutils.internal.Node) VertexRef(org.opennms.features.topology.api.topo.VertexRef) URL(java.net.URL)

Example 2 with Node

use of org.opennms.features.topology.netutils.internal.Node in project opennms by OpenNMS.

the class ResourceGraphsOperation method execute.

@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
    try {
        String label = "";
        int nodeID = -1;
        if (targets != null) {
            for (final VertexRef target : targets) {
                final String labelValue = getLabelValue(operationContext, target);
                final Integer nodeValue = getNodeIdValue(operationContext, target);
                if (nodeValue != null && nodeValue > 0) {
                    label = labelValue == null ? "" : labelValue;
                    nodeID = nodeValue.intValue();
                    break;
                }
            }
        }
        final Node node = new Node(nodeID, null, label);
        final String url;
        if (node.getNodeID() >= 0) {
            url = getResourceGraphNodeURL() + "[" + node.getNodeID() + "]";
        } else {
            url = getResourceGraphListURL();
        }
        final URL fullUrl = new URL(getFullUrl(url));
        operationContext.getMainWindow().addWindow(new ResourceGraphsWindow(node, fullUrl));
    } catch (final Exception e) {
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        } else {
            throw new RuntimeException("Failed to create resource graph window.", e);
        }
    }
}
Also used : Node(org.opennms.features.topology.netutils.internal.Node) VertexRef(org.opennms.features.topology.api.topo.VertexRef) URL(java.net.URL) ResourceGraphsWindow(org.opennms.features.topology.netutils.internal.ResourceGraphsWindow)

Example 3 with Node

use of org.opennms.features.topology.netutils.internal.Node in project opennms by OpenNMS.

the class NodeInfoOperation method execute.

@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
    try {
        String label = "";
        int nodeID = -1;
        if (targets != null) {
            for (final VertexRef target : targets) {
                final String labelValue = getLabelValue(operationContext, target);
                final Integer nodeValue = getNodeIdValue(operationContext, target);
                if (nodeValue != null && nodeValue > 0) {
                    label = labelValue == null ? "" : labelValue;
                    nodeID = nodeValue.intValue();
                    break;
                }
            }
        }
        final Node node = new Node(nodeID, null, label);
        final String url;
        if (node.getNodeID() >= 0) {
            url = getNodePageURL() + node.getNodeID();
        } else {
            url = getNodeListURL();
        }
        final URL fullUrl = new URL(getFullUrl(url));
        operationContext.getMainWindow().addWindow(new NodeInfoWindow(node, fullUrl));
    } catch (final Exception e) {
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        } else {
            throw new RuntimeException("Failed to create node window.", e);
        }
    }
}
Also used : Node(org.opennms.features.topology.netutils.internal.Node) NodeInfoWindow(org.opennms.features.topology.netutils.internal.NodeInfoWindow) VertexRef(org.opennms.features.topology.api.topo.VertexRef) URL(java.net.URL)

Aggregations

URL (java.net.URL)3 VertexRef (org.opennms.features.topology.api.topo.VertexRef)3 Node (org.opennms.features.topology.netutils.internal.Node)3 EventsAlarmsWindow (org.opennms.features.topology.netutils.internal.EventsAlarmsWindow)1 NodeInfoWindow (org.opennms.features.topology.netutils.internal.NodeInfoWindow)1 ResourceGraphsWindow (org.opennms.features.topology.netutils.internal.ResourceGraphsWindow)1