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);
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.VertexRef in project opennms by OpenNMS.
the class BreadcrumbPathCalculator method findPath.
static PathTree findPath(TopologyServiceClient topologyServiceClient, Collection<VertexRef> vertices) {
Objects.requireNonNull(topologyServiceClient);
Objects.requireNonNull(vertices);
final Map<VertexRef, EdgeRef> incomingEdgeMap = getIncomingEdgeMap(topologyServiceClient);
final PathTree pathTree = new PathTree();
for (VertexRef eachVertex : vertices) {
List<VertexRef> path = findPath(incomingEdgeMap, eachVertex);
pathTree.addPath(path);
}
return pathTree;
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class RemoveFocusOtherVerticesOperation method enabled.
@Override
public boolean enabled(List<VertexRef> targets, OperationContext operationContext) {
if (targets == null || targets.isEmpty()) {
return false;
}
final GraphContainer graphContainer = operationContext.getGraphContainer();
final WrappedVertexHopCriteria wrappedVertexHopCriteria = VertexHopGraphProvider.getWrappedVertexHopCriteria(graphContainer);
if (wrappedVertexHopCriteria.isEmpty()) {
return false;
}
// Are the selected vertices in focus?
for (VertexRef target : targets) {
if (!wrappedVertexHopCriteria.contains(target)) {
return false;
}
}
// Are there any other vertices in focus?
for (VertexRef vertex : wrappedVertexHopCriteria.getVertices()) {
if (!targets.contains(vertex)) {
return true;
}
}
return false;
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class TopologyContextMenu method addNavigateToItems.
// adds menu items for the "navigate to" operation
private static void addNavigateToItems(MenuBuilder menuBuilder, List<VertexRef> targets, OperationContext operationContext) {
if (!targets.isEmpty()) {
menuBuilder.createPath("Navigate To");
final GraphContainer graphContainer = operationContext.getGraphContainer();
// Find the vertices in other graphs that this vertex links to
final Collection<VertexRef> oppositeVertices = graphContainer.getTopologyServiceClient().getOppositeVertices(targets.get(0));
// Find all namespaces
final Set<String> targetNamespaces = oppositeVertices.stream().map(v -> v.getNamespace()).collect(Collectors.toSet());
// Find provider for namespaces and add menu entry
for (String eachTargetNamespace : targetNamespaces) {
// Find the graph provider for the target namespace
final GraphProvider targetGraphProvider = graphContainer.getTopologyServiceClient().getGraphProviders().stream().filter(g -> g.getNamespace().equals(eachTargetNamespace)).findFirst().orElse(null);
if (targetGraphProvider == null) {
LOG.warn("No graph provider found for namespace '{}'.", eachTargetNamespace);
continue;
}
NavigationMenuItem item = new NavigationMenuItem(targetGraphProvider, targets.get(0));
menuBuilder.addMenuItem(item, "Navigate To");
}
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class NodeMapQueryLink method execute.
@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
final Collection<VertexRef> availableNodes = m_geoAssetProvider.getNodesWithCoordinates();
final StringBuilder sb = new StringBuilder();
sb.append(VaadinServlet.getCurrent().getServletContext().getContextPath());
sb.append("/node-maps#search/nodeId%20in%20");
final List<String> nodeIds = new ArrayList<String>();
for (final VertexRef ref : targets) {
if (availableNodes.contains(ref)) {
nodeIds.add(ref.getId());
}
}
final Iterator<String> i = nodeIds.iterator();
while (i.hasNext()) {
sb.append(i.next());
if (i.hasNext()) {
sb.append(",");
}
}
final String redirectUrl = sb.toString();
LOG.info("redirecting to: " + redirectUrl);
final UI ui = operationContext.getMainWindow();
ui.getPage().getJavaScript().execute("window.location = '" + redirectUrl + "';");
}
Aggregations