Search in sources :

Example 1 with SimpleConnector

use of org.opennms.features.topology.api.topo.SimpleConnector 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)

Example 2 with SimpleConnector

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

the class EnhancedLinkdTopologyProvider method connectVertices.

protected final LinkdEdge connectVertices(BridgeMacLink link, VertexRef sourceRef, VertexRef targetRef, String nameSpace) {
    SimpleConnector source = new SimpleConnector(sourceRef.getNamespace(), sourceRef.getId() + "-" + link.getId() + "-connector", sourceRef);
    SimpleConnector target = new SimpleConnector(targetRef.getNamespace(), targetRef.getId() + "-" + link.getId() + "-connector", targetRef);
    LinkdEdge edge = new LinkdEdge(nameSpace, String.valueOf(link.getId()), source, target);
    edge.setSourceNodeid(link.getNode().getId());
    if (link.getBridgePortIfIndex() != null)
        edge.setSourceEndPoint(String.valueOf(link.getBridgePortIfIndex()));
    edge.setTargetEndPoint(String.valueOf(link.getMacAddress()));
    addEdges(edge);
    return edge;
}
Also used : SimpleConnector(org.opennms.features.topology.api.topo.SimpleConnector)

Example 3 with SimpleConnector

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

the class EnhancedLinkdTopologyProvider method connectVertices.

protected final LinkdEdge connectVertices(LinkDetail<?> linkdetail, String nameSpace) {
    SimpleConnector source = new SimpleConnector(linkdetail.getSource().getNamespace(), linkdetail.getSource().getId() + "-" + linkdetail.getId() + "-connector", linkdetail.getSource());
    SimpleConnector target = new SimpleConnector(linkdetail.getTarget().getNamespace(), linkdetail.getTarget().getId() + "-" + linkdetail.getId() + "-connector", linkdetail.getTarget());
    LinkdEdge edge = new LinkdEdge(nameSpace, linkdetail.getId(), source, target);
    try {
        edge.setSourceNodeid(Integer.parseInt(linkdetail.getSource().getId()));
    } catch (NumberFormatException e) {
    }
    try {
        edge.setTargetNodeid(Integer.parseInt(linkdetail.getTarget().getId()));
    } catch (NumberFormatException e) {
    }
    if (linkdetail.getSourceIfIndex() != null)
        edge.setSourceEndPoint(String.valueOf(linkdetail.getSourceIfIndex()));
    if (linkdetail.getTargetIfIndex() != null)
        edge.setTargetEndPoint(String.valueOf(linkdetail.getTargetIfIndex()));
    addEdges(edge);
    return edge;
}
Also used : SimpleConnector(org.opennms.features.topology.api.topo.SimpleConnector)

Example 4 with SimpleConnector

use of org.opennms.features.topology.api.topo.SimpleConnector 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 5 with SimpleConnector

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

the class EnhancedLinkdTopologyProvider method connectVertices.

protected final LinkdEdge connectVertices(BridgePort targetport, VertexRef sourceRef, VertexRef targetRef, String nameSpace) {
    SimpleConnector source = new SimpleConnector(sourceRef.getNamespace(), sourceRef.getId() + "-" + targetRef.getId() + "-connector", sourceRef);
    SimpleConnector target = new SimpleConnector(targetRef.getNamespace(), targetRef.getId() + "-" + sourceRef.getId() + "-connector", targetRef);
    LinkdEdge edge = new LinkdEdge(nameSpace, targetRef.getId() + ":" + targetport.getBridgePort(), source, target);
    edge.setTargetNodeid(targetport.getNode().getId());
    if (targetport.getBridgePortIfIndex() != null)
        edge.setTargetEndPoint(String.valueOf(targetport.getBridgePortIfIndex()));
    addEdges(edge);
    return edge;
}
Also used : SimpleConnector(org.opennms.features.topology.api.topo.SimpleConnector)

Aggregations

SimpleConnector (org.opennms.features.topology.api.topo.SimpleConnector)8 AbstractEdge (org.opennms.features.topology.api.topo.AbstractEdge)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)2 Edge (org.opennms.features.topology.api.topo.Edge)2 SimpleLeafVertex (org.opennms.features.topology.api.topo.SimpleLeafVertex)2 Vertex (org.opennms.features.topology.api.topo.Vertex)2 VertexRef (org.opennms.features.topology.api.topo.VertexRef)2