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;
}
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;
}
}
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;
}
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;
}
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());
}
Aggregations