Search in sources :

Example 11 with VertexRef

use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.

the class CategoryHopCriteria method getVertices.

@Override
public Set<VertexRef> getVertices() {
    OnmsCategory category = categoryProvider.findCategoryByName(m_categoryName);
    if (category == null) {
        return Collections.emptySet();
    } else {
        List<OnmsNode> nodes = categoryProvider.findNodesForCategory(category);
        Set<VertexRef> retval = new TreeSet<VertexRef>(new RefComparator());
        for (OnmsNode node : nodes) {
            retval.add(new DefaultVertexRef("nodes", String.valueOf(node.getId())));
        }
        return retval;
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) TreeSet(java.util.TreeSet) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) RefComparator(org.opennms.features.topology.api.topo.RefComparator)

Example 12 with VertexRef

use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.

the class BreadcrumbPathCalculator method findPath.

static PathTree findPath(TopologyServiceClient topologyServiceClient, Collection<VertexRef> vertices) {
    Objects.requireNonNull(topologyServiceClient);
    Objects.requireNonNull(vertices);
    final Map<VertexRef, EdgeRef> incomingEdgeMap = getIncomingEdgeMap(topologyServiceClient);
    final PathTree pathTree = new PathTree();
    for (VertexRef eachVertex : vertices) {
        List<VertexRef> path = findPath(incomingEdgeMap, eachVertex);
        pathTree.addPath(path);
    }
    return pathTree;
}
Also used : EdgeRef(org.opennms.features.topology.api.topo.EdgeRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 13 with VertexRef

use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.

the class RemoveFocusOtherVerticesOperation method enabled.

@Override
public boolean enabled(List<VertexRef> targets, OperationContext operationContext) {
    if (targets == null || targets.isEmpty()) {
        return false;
    }
    final GraphContainer graphContainer = operationContext.getGraphContainer();
    final WrappedVertexHopCriteria wrappedVertexHopCriteria = VertexHopGraphProvider.getWrappedVertexHopCriteria(graphContainer);
    if (wrappedVertexHopCriteria.isEmpty()) {
        return false;
    }
    // Are the selected vertices in focus?
    for (VertexRef target : targets) {
        if (!wrappedVertexHopCriteria.contains(target)) {
            return false;
        }
    }
    // Are there any other vertices in focus?
    for (VertexRef vertex : wrappedVertexHopCriteria.getVertices()) {
        if (!targets.contains(vertex)) {
            return true;
        }
    }
    return false;
}
Also used : GraphContainer(org.opennms.features.topology.api.GraphContainer) WrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.WrappedVertexHopCriteria) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 14 with VertexRef

use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.

the class TopologyContextMenu method addNavigateToItems.

// adds menu items for the "navigate to" operation
private static void addNavigateToItems(MenuBuilder menuBuilder, List<VertexRef> targets, OperationContext operationContext) {
    if (!targets.isEmpty()) {
        menuBuilder.createPath("Navigate To");
        final GraphContainer graphContainer = operationContext.getGraphContainer();
        // Find the vertices in other graphs that this vertex links to
        final Collection<VertexRef> oppositeVertices = graphContainer.getTopologyServiceClient().getOppositeVertices(targets.get(0));
        // Find all namespaces
        final Set<String> targetNamespaces = oppositeVertices.stream().map(v -> v.getNamespace()).collect(Collectors.toSet());
        // Find provider for namespaces and add menu entry
        for (String eachTargetNamespace : targetNamespaces) {
            // Find the graph provider for the target namespace
            final GraphProvider targetGraphProvider = graphContainer.getTopologyServiceClient().getGraphProviders().stream().filter(g -> g.getNamespace().equals(eachTargetNamespace)).findFirst().orElse(null);
            if (targetGraphProvider == null) {
                LOG.warn("No graph provider found for namespace '{}'.", eachTargetNamespace);
                continue;
            }
            NavigationMenuItem item = new NavigationMenuItem(targetGraphProvider, targets.get(0));
            menuBuilder.addMenuItem(item, "Navigate To");
        }
    }
}
Also used : GraphContainer(org.opennms.features.topology.api.GraphContainer) GraphContainer(org.opennms.features.topology.api.GraphContainer) Logger(org.slf4j.Logger) ContextMenu(org.vaadin.peter.contextmenu.ContextMenu) MenuBar(com.vaadin.ui.MenuBar) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) UI(com.vaadin.ui.UI) Set(java.util.Set) ContextMenuState(org.vaadin.peter.contextmenu.client.ContextMenuState) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) DefaultOperationContext(org.opennms.features.topology.app.internal.DefaultOperationContext) OperationContext(org.opennms.features.topology.api.OperationContext) VertexRef(org.opennms.features.topology.api.topo.VertexRef) Collections(java.util.Collections) GraphProvider(org.opennms.features.topology.api.topo.GraphProvider) GraphProvider(org.opennms.features.topology.api.topo.GraphProvider) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 15 with VertexRef

use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.

the class NodeMapQueryLink method execute.

@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
    final Collection<VertexRef> availableNodes = m_geoAssetProvider.getNodesWithCoordinates();
    final StringBuilder sb = new StringBuilder();
    sb.append(VaadinServlet.getCurrent().getServletContext().getContextPath());
    sb.append("/node-maps#search/nodeId%20in%20");
    final List<String> nodeIds = new ArrayList<String>();
    for (final VertexRef ref : targets) {
        if (availableNodes.contains(ref)) {
            nodeIds.add(ref.getId());
        }
    }
    final Iterator<String> i = nodeIds.iterator();
    while (i.hasNext()) {
        sb.append(i.next());
        if (i.hasNext()) {
            sb.append(",");
        }
    }
    final String redirectUrl = sb.toString();
    LOG.info("redirecting to: " + redirectUrl);
    final UI ui = operationContext.getMainWindow();
    ui.getPage().getJavaScript().execute("window.location = '" + redirectUrl + "';");
}
Also used : UI(com.vaadin.ui.UI) ArrayList(java.util.ArrayList) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Aggregations

VertexRef (org.opennms.features.topology.api.topo.VertexRef)94 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)30 Vertex (org.opennms.features.topology.api.topo.Vertex)29 Point (org.opennms.features.topology.api.Point)23 Edge (org.opennms.features.topology.api.topo.Edge)22 EdgeRef (org.opennms.features.topology.api.topo.EdgeRef)18 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)17 List (java.util.List)13 Criteria (org.opennms.features.topology.api.topo.Criteria)13 SparseGraph (edu.uci.ics.jung.graph.SparseGraph)12 Collectors (java.util.stream.Collectors)12 Layout (org.opennms.features.topology.api.Layout)12 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)10 GraphContainer (org.opennms.features.topology.api.GraphContainer)10 Collection (java.util.Collection)9 Map (java.util.Map)9 Set (java.util.Set)8 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)8