use of org.opennms.features.topology.api.topo.VertexRef 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);
List<Integer> nodeIds = nodes.stream().map(n -> n.getId()).collect(Collectors.toList());
GraphProvider graphProvider = graphContainer.getTopologyServiceClient().getGraphProviderBy(graphContainer.getTopologyServiceClient().getNamespace());
return graphProvider.getVertices(new IgnoreHopCriteria()).stream().filter(v -> v.getNodeID() != null).filter(v -> nodeIds.contains(v.getNodeID())).collect(Collectors.toSet());
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class IpLikeHopCriteria method getVertices.
@Override
public Set<VertexRef> getVertices() {
CriteriaBuilder bldr = new CriteriaBuilder(OnmsIpInterface.class);
bldr.iplike("ipAddr", 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.VertexRef in project opennms by OpenNMS.
the class LayoutManager method isPersistedLayoutEqualToCurrentLayout.
public boolean isPersistedLayoutEqualToCurrentLayout(Graph graph) {
LayoutEntity layoutEntity = loadLayout(graph);
if (layoutEntity != null) {
// If we have a layout persisted, we verify if it is equal.
final Map<VertexRef, Point> persistedLocations = layoutEntity.getVertexPositions().stream().collect(Collectors.toMap((Function<VertexPositionEntity, VertexRef>) vertexPositionEntity -> {
VertexRefEntity vertexRefEntity = vertexPositionEntity.getVertexRef();
return new DefaultVertexRef(vertexRefEntity.getNamespace(), vertexRefEntity.getId());
}, vertexPositionEntity -> {
PointEntity position = vertexPositionEntity.getPosition();
return new Point(position.getX(), position.getY());
}));
// The locations may contain elements currently not visible, we filter them
final Map<VertexRef, Point> manualLocations = new HashMap<>();
graph.getLayout().getLocations().forEach((key, value) -> {
if (persistedLocations.containsKey(key)) {
// layoutEntity stores int coordinates, but manualLocations are stored as double.
// Convert to int to make it comparable.
manualLocations.put(key, new Point((int) value.getX(), (int) value.getY()));
}
});
final boolean layoutIsEqual = manualLocations.equals(persistedLocations);
return layoutIsEqual;
}
// We don't have anything persisted, so they are not equal
return false;
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class BreadcrumbComponent method createButton.
private static Button createButton(GraphContainer container, Breadcrumb breadcrumb) {
final Button button = new Button();
final String layerName = getLayerName(container, breadcrumb.getTargetNamespace());
if (breadcrumb.getSourceVertices().isEmpty()) {
button.setCaption(layerName);
} else {
String sourceLayerName = getLayerName(container, breadcrumb.getSourceVertices().get(0).getNamespace());
if (breadcrumb.getSourceVertices().size() > 2) {
button.setCaption("Multiple " + layerName);
button.setDescription(String.format("Multiple vertices from %s", sourceLayerName));
} else {
button.setCaption(breadcrumb.getSourceVertices().stream().map(VertexRef::getLabel).collect(Collectors.joining(", ")));
button.setDescription(String.format("%s from %s", button.getCaption(), sourceLayerName));
}
}
button.addStyleName(BaseTheme.BUTTON_LINK);
button.addClickListener((event) -> breadcrumb.clicked(container));
return button;
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class OSGiVerticesUpdateManagerTest method createVertexRefsWithIds.
private List<VertexRef> createVertexRefsWithIds(int... vertIds) {
List<VertexRef> vertices = new ArrayList<>();
for (int i = 0; i < vertIds.length; i++) {
VertexRef vRef = new DefaultVertexRef("nodes", "" + vertIds[i], "");
vertices.add(vRef);
}
return vertices;
}
Aggregations