Search in sources :

Example 1 with EventsAlarmsWindow

use of org.opennms.features.topology.netutils.internal.EventsAlarmsWindow 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)

Aggregations

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