Search in sources :

Example 1 with AbstractEdge

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

the class SimpleEdgeBuilder method edge.

public SimpleEdgeBuilder edge(String id, String srcNs, String srcId, String tgtNs, String tgtId) {
    VertexRef srcVertex = new DefaultVertexRef(srcNs, srcId);
    VertexRef tgtVertex = new DefaultVertexRef(tgtNs, tgtId);
    SimpleConnector source = new SimpleConnector(ns(), srcId + "-" + id + "-connector", srcVertex);
    SimpleConnector target = new SimpleConnector(ns(), tgtId + "-" + id + "-connector", tgtVertex);
    m_currentEdge = new AbstractEdge(ns(), id, source, target);
    source.setEdge(m_currentEdge);
    target.setEdge(m_currentEdge);
    m_edgeProvider.add(m_currentEdge);
    return this;
}
Also used : AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) SimpleConnector(org.opennms.features.topology.api.topo.SimpleConnector) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 2 with AbstractEdge

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

the class DefaultEdgeInfoPanelItemProvider method createComponent.

private Component createComponent(EdgeRef ref) {
    FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);
    formLayout.setMargin(false);
    if (ref instanceof AbstractEdge) {
        AbstractEdge edge = (AbstractEdge) ref;
        formLayout.addComponent(createLabel("Source", edge.getSource().getVertex().getLabel()));
        formLayout.addComponent(createLabel("Target", edge.getTarget().getVertex().getLabel()));
    }
    return formLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge)

Example 3 with AbstractEdge

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

the class HierarchyLayoutAlgorithmTest method verifyHierarchyLayoutFallBack.

// NMS-8703
@Test
public void verifyHierarchyLayoutFallBack() {
    // Vertices
    vertices.add(new TestVertex("root"));
    vertices.add(new TestVertex("v1"));
    vertices.add(new TestVertex("v2"));
    vertices.add(new TestVertex("v3"));
    // Edges
    edges.add(new AbstractEdge("test", "rootEdge", vertices.get(0), vertices.get(1)));
    edges.add(new AbstractEdge("test", "e1", vertices.get(1), vertices.get(2)));
    edges.add(new AbstractEdge("test", "e2", vertices.get(2), vertices.get(3)));
    // Circle
    edges.add(new AbstractEdge("test", "e3", vertices.get(3), vertices.get(1)));
    // Update the layouts and ensure no exception is thrown
    buildLayout();
}
Also used : AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) TestVertex(org.opennms.features.topology.app.internal.TestVertex) Test(org.junit.Test)

Example 4 with AbstractEdge

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

the class ApplicationTopologyProvider method load.

private void load() {
    resetContainer();
    for (OnmsApplication application : applicationDao.findAll()) {
        ApplicationVertex applicationVertex = new ApplicationVertex(application);
        addVertices(applicationVertex);
        for (OnmsMonitoredService eachMonitoredService : application.getMonitoredServices()) {
            final ApplicationVertex serviceVertex = new ApplicationVertex(eachMonitoredService);
            applicationVertex.addChildren(serviceVertex);
            addVertices(serviceVertex);
            // connect with application
            String id = String.format("connection:%s:%s", applicationVertex.getId(), serviceVertex.getId());
            Edge edge = new AbstractEdge(getNamespace(), id, applicationVertex, serviceVertex);
            addEdges(edge);
        }
    }
}
Also used : AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Edge(org.opennms.features.topology.api.topo.Edge) AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 5 with AbstractEdge

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

the class SimpleGraphBuilder method edge.

public SimpleGraphBuilder edge(String id, String srcId, String tgtId) {
    VertexRef srcVertex = m_graphProvider.getVertex(ns(), srcId);
    if (srcVertex == null) {
        srcVertex = new DefaultVertexRef(ns(), srcId);
    }
    VertexRef tgtVertex = m_graphProvider.getVertex(ns(), tgtId);
    if (tgtVertex == null) {
        tgtVertex = new DefaultVertexRef(ns(), tgtId);
    }
    SimpleConnector source = new SimpleConnector(ns(), srcId + "-" + id + "-connector", srcVertex);
    SimpleConnector target = new SimpleConnector(ns(), tgtId + "-" + id + "-connector", tgtVertex);
    m_currentEdge = new AbstractEdge(ns(), id, source, target);
    source.setEdge(m_currentEdge);
    target.setEdge(m_currentEdge);
    m_graphProvider.addEdges(m_currentEdge);
    return this;
}
Also used : AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) SimpleConnector(org.opennms.features.topology.api.topo.SimpleConnector) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Aggregations

AbstractEdge (org.opennms.features.topology.api.topo.AbstractEdge)12 Vertex (org.opennms.features.topology.api.topo.Vertex)5 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)4 Edge (org.opennms.features.topology.api.topo.Edge)4 SimpleConnector (org.opennms.features.topology.api.topo.SimpleConnector)4 Test (org.junit.Test)3 VertexRef (org.opennms.features.topology.api.topo.VertexRef)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2 SimpleLeafVertex (org.opennms.features.topology.api.topo.SimpleLeafVertex)2 FormLayout (com.vaadin.ui.FormLayout)1 UnweightedShortestPath (edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath)1 DirectedSparseGraph (edu.uci.ics.jung.graph.DirectedSparseGraph)1 IgnoreHopCriteria (org.opennms.features.topology.api.support.IgnoreHopCriteria)1 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)1 EdgeRef (org.opennms.features.topology.api.topo.EdgeRef)1 TestVertex (org.opennms.features.topology.app.internal.TestVertex)1 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)1