Search in sources :

Example 1 with EdgeStatusProvider

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

the class DefaultTopologyService method getGraph.

@Override
public Graph getGraph(String metaTopologyId, String namespace, Criteria[] criteria, int semanticZoomLevel) {
    Objects.requireNonNull(metaTopologyId);
    Objects.requireNonNull(namespace);
    Objects.requireNonNull(metaTopologyId);
    Objects.requireNonNull(criteria);
    if (semanticZoomLevel < 0) {
        LOG.warn("Semantic Zoom Level was {}. Only values >= 0 are allowed, forcing it to be 1", semanticZoomLevel);
        semanticZoomLevel = 0;
    }
    final GraphProvider graphProvider = getGraphProvider(metaTopologyId, namespace);
    // Determine visible vertices and edges
    final List<Vertex> displayVertices = new ArrayList<>();
    for (Vertex v : graphProvider.getVertices(criteria)) {
        int vzl = graphProvider.getSemanticZoomLevel(v);
        if (vzl == semanticZoomLevel || (vzl < semanticZoomLevel && !graphProvider.hasChildren(v))) {
            displayVertices.add(v);
        }
    }
    final Collection<Edge> displayEdges = graphProvider.getEdges(criteria);
    // Create graph object
    final DefaultGraph graph = new DefaultGraph(displayVertices, displayEdges);
    // Calculate status
    final StatusProvider vertexStatusProvider = serviceLocator != null ? findVertexStatusProvider(graphProvider) : null;
    final EdgeStatusProvider edgeStatusProvider = serviceLocator != null ? findEdgeStatusProvider(graphProvider) : null;
    if (vertexStatusProvider != null) {
        graph.setVertexStatus(vertexStatusProvider.getStatusForVertices(graphProvider, new ArrayList<>(displayVertices), criteria));
    }
    if (edgeStatusProvider != null) {
        graph.setEdgeStatus(edgeStatusProvider.getStatusForEdges(graphProvider, new ArrayList<>(graph.getDisplayEdges()), criteria));
    }
    return graph;
}
Also used : Vertex(org.opennms.features.topology.api.topo.Vertex) EdgeStatusProvider(org.opennms.features.topology.api.topo.EdgeStatusProvider) EdgeStatusProvider(org.opennms.features.topology.api.topo.EdgeStatusProvider) StatusProvider(org.opennms.features.topology.api.topo.StatusProvider) GraphProvider(org.opennms.features.topology.api.topo.GraphProvider) ArrayList(java.util.ArrayList) Edge(org.opennms.features.topology.api.topo.Edge)

Aggregations

ArrayList (java.util.ArrayList)1 Edge (org.opennms.features.topology.api.topo.Edge)1 EdgeStatusProvider (org.opennms.features.topology.api.topo.EdgeStatusProvider)1 GraphProvider (org.opennms.features.topology.api.topo.GraphProvider)1 StatusProvider (org.opennms.features.topology.api.topo.StatusProvider)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1