use of org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria in project opennms by OpenNMS.
the class AbstractAnalysisOperation method focusOnVertices.
private void focusOnVertices(VertexRef target, Set<GraphVertex> graphVerticesToFocus, GraphContainer container) {
// add to focus
removeHopCriteria(container);
graphVerticesToFocus.forEach(graphVertex -> container.addCriteria(new DefaultVertexHopCriteria(createTopologyVertex(graphVertex))));
// add the context vertex because it is missing in the root cause result
container.addCriteria(new DefaultVertexHopCriteria(target));
container.setSemanticZoomLevel(0);
// Remove the current selection before redrawing the layout in order
// to avoid centering on the current vertex
container.getSelectionManager().setSelectedVertexRefs(Collections.emptyList());
container.getSelectionManager().setSelectedEdgeRefs(Collections.emptyList());
container.redoLayout();
}
use of org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria in project opennms by OpenNMS.
the class VertexHopGraphProviderTest method testGraphProvider.
@Test
public void testGraphProvider() {
DefaultVertexHopCriteria criteria = new DefaultVertexHopCriteria(new DefaultVertexRef("nodes", "g0"));
m_provider.getVertices(criteria);
assertEquals(0, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "g0")));
assertEquals(1, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "g1")));
assertEquals(1, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "g2")));
assertEquals(2, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "v1")));
assertEquals(2, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "v2")));
assertEquals(2, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "v3")));
assertEquals(2, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "v4")));
// Make sure that the hop provider isn't showing nodes with parent/child relationships like the
// older grouping providers did
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "g0")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "g1")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "g2")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "v1")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "v2")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "v3")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "v4")));
criteria = new DefaultVertexHopCriteria(new DefaultVertexRef("nodes", "v1"));
m_provider.getVertices(criteria);
assertEquals(2, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "g0")));
assertEquals(1, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "g1")));
assertEquals(3, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "g2")));
assertEquals(0, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "v1")));
assertEquals(2, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "v2")));
assertEquals(4, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "v3")));
assertEquals(4, m_provider.getSemanticZoomLevel(new DefaultVertexRef("nodes", "v4")));
// Make sure that the hop provider isn't showing nodes with parent/child relationships like the
// older grouping providers did
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "g0")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "g1")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "g2")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "v1")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "v2")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "v3")));
assertNull(m_provider.getParent(new DefaultVertexRef("nodes", "v4")));
}
use of org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria in project opennms by OpenNMS.
the class SimpleSearchProvider method removeVertexHopCriteria.
@Override
public void removeVertexHopCriteria(SearchResult searchResult, GraphContainer container) {
LOG.debug("SimpleSearchProvider->removeVertexHopCriteria: called with search result: '{}'", searchResult);
final DefaultVertexHopCriteria criterion = new DefaultVertexHopCriteria(new DefaultVertexRef(searchResult.getNamespace(), searchResult.getId(), searchResult.getLabel()));
container.removeCriteria(criterion);
LOG.debug("SimpleSearchProvider->removeVertexHopCriteria: current criteria {}.", Arrays.toString(container.getCriteria()));
}
use of org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria in project opennms by OpenNMS.
the class AddFocusVerticesOperation method execute.
@Override
public void execute(List<VertexRef> targets, final OperationContext operationContext) {
if (targets == null || targets.isEmpty()) {
return;
}
final GraphContainer graphContainer = operationContext.getGraphContainer();
for (VertexRef target : targets) {
graphContainer.addCriteria(new DefaultVertexHopCriteria(target));
}
graphContainer.redoLayout();
}
use of org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria in project opennms by OpenNMS.
the class SearchBox method removeIfSpecialURLCase.
private void removeIfSpecialURLCase(SearchResult searchResult, GraphContainer graphContainer) {
DefaultVertexRef vertexRef = new DefaultVertexRef(searchResult.getNamespace(), searchResult.getId(), searchResult.getLabel());
DefaultVertexHopCriteria criteria = new DefaultVertexHopCriteria(vertexRef);
graphContainer.removeCriteria(criteria);
}
Aggregations