Search in sources :

Example 1 with RefComparator

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

the class IpLikeHopCriteria method getVertices.

@Override
public Set<VertexRef> getVertices() {
    CriteriaBuilder bldr = new CriteriaBuilder(OnmsIpInterface.class);
    bldr.iplike("ipAddress", m_ipQuery);
    List<OnmsIpInterface> ips = ipInterfaceProvider.findMatching(bldr.toCriteria());
    Set<VertexRef> vertices = new TreeSet<VertexRef>(new RefComparator());
    for (OnmsIpInterface ip : ips) {
        OnmsNode node = ip.getNode();
        vertices.add(new DefaultVertexRef("nodes", String.valueOf(node.getId()), node.getLabel()));
    }
    return vertices;
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) 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 2 with RefComparator

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

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

the class NCSSearchProvider method getVertexRefsForEdges.

public static Set<VertexRef> getVertexRefsForEdges(NCSEdgeProvider provider, Criteria criteria) {
    Set<VertexRef> vertexRefs = new TreeSet<VertexRef>(new RefComparator());
    List<Edge> edges = provider.getEdges(criteria);
    for (Edge ncsEdge : edges) {
        vertexRefs.add(ncsEdge.getSource().getVertex());
        vertexRefs.add(ncsEdge.getTarget().getVertex());
    }
    return vertexRefs;
}
Also used : TreeSet(java.util.TreeSet) VertexRef(org.opennms.features.topology.api.topo.VertexRef) Edge(org.opennms.features.topology.api.topo.Edge) RefComparator(org.opennms.features.topology.api.topo.RefComparator)

Example 4 with RefComparator

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

the class AlarmHopCriteria method createVertices.

private Set<VertexRef> createVertices(List<OnmsAlarm> alarms) {
    Set<VertexRef> vertices = new TreeSet<VertexRef>(new RefComparator());
    for (OnmsAlarm alarm : alarms) {
        OnmsNode node = alarm.getNode();
        if (node == null) {
            continue;
        }
        vertices.add(new DefaultVertexRef("nodes", String.valueOf(node.getId()), node.getLabel()));
    }
    return vertices;
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) TreeSet(java.util.TreeSet) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) 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 5 with RefComparator

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

the class DefaultGraph method updateLayout.

private void updateLayout(Collection<Vertex> displayVertices, Collection<Edge> displayEdges) {
    m_displayVertices.clear();
    m_displayVertices.addAll(displayVertices);
    m_displayEdges.clear();
    m_displayEdges.addAll(displayEdges);
    for (Iterator<Edge> itr = m_displayEdges.iterator(); itr.hasNext(); ) {
        Edge edge = itr.next();
        if (new RefComparator().compare(edge.getSource().getVertex(), edge.getTarget().getVertex()) == 0) {
            LOG.debug("Discarding edge whose source and target are the same: {}", edge);
            itr.remove();
        } else if (m_displayVertices.contains(edge.getSource().getVertex())) {
            if (m_displayVertices.contains(edge.getTarget().getVertex())) {
            // This edge is OK, it is attached to two vertices that are in the graph
            } else {
                LOG.debug("Discarding edge that is not attached to 2 vertices in the graph: {}", edge);
                itr.remove();
            }
        } else {
            LOG.debug("Discarding edge that is not attached to 2 vertices in the graph: {}", edge);
            itr.remove();
        }
    }
    LOG.debug("Created a graph with {} vertices and {} edges", m_displayVertices.size(), m_displayEdges.size());
}
Also used : Edge(org.opennms.features.topology.api.topo.Edge) RefComparator(org.opennms.features.topology.api.topo.RefComparator)

Aggregations

RefComparator (org.opennms.features.topology.api.topo.RefComparator)7 VertexRef (org.opennms.features.topology.api.topo.VertexRef)6 TreeSet (java.util.TreeSet)5 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)5 OnmsNode (org.opennms.netmgt.model.OnmsNode)4 Edge (org.opennms.features.topology.api.topo.Edge)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)1 CollapsibleCriteria (org.opennms.features.topology.api.topo.CollapsibleCriteria)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)1 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1