Search in sources :

Example 1 with VertexHopCriteria

use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.

the class TopologyUI method getFocusVertices.

private int getFocusVertices(GraphContainer graphContainer) {
    int count = 0;
    Criteria[] crits = graphContainer.getCriteria();
    for (Criteria criteria : crits) {
        try {
            VertexHopCriteria catCrit = (VertexHopCriteria) criteria;
            count += catCrit.getVertices().size();
        } catch (ClassCastException e) {
        }
    }
    return count;
}
Also used : VertexHopGraphProvider.getWrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.getWrappedVertexHopCriteria) CategoryHopCriteria(org.opennms.features.topology.app.internal.support.CategoryHopCriteria) Criteria(org.opennms.features.topology.api.topo.Criteria) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria) VertexHopGraphProvider.getWrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.getWrappedVertexHopCriteria) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria)

Example 2 with VertexHopCriteria

use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.

the class RemoveFocusOtherVerticesOperation method execute.

@Override
public void execute(List<VertexRef> targets, final OperationContext operationContext) {
    final GraphContainer graphContainer = operationContext.getGraphContainer();
    final Set<VertexHopCriteria> criteriaForGraphContainer = Criteria.getCriteriaForGraphContainer(graphContainer, VertexHopCriteria.class);
    boolean didRemoveCriteria = false;
    for (VertexHopCriteria eachCriteria : criteriaForGraphContainer) {
        boolean shouldRemove = true;
        for (VertexRef vertex : eachCriteria.getVertices()) {
            if (targets.contains(vertex)) {
                // The criteria references at least one of our targets, so
                // we shouldn't remove it
                shouldRemove = false;
                break;
            }
        }
        if (shouldRemove) {
            graphContainer.removeCriteria(eachCriteria);
            didRemoveCriteria = true;
        }
    }
    if (didRemoveCriteria) {
        // Only update the layout if any changes were made
        graphContainer.redoLayout();
    }
}
Also used : GraphContainer(org.opennms.features.topology.api.GraphContainer) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria) WrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.WrappedVertexHopCriteria) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 3 with VertexHopCriteria

use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.

the class RemoveFocusVerticesOperation method execute.

@Override
public void execute(List<VertexRef> targets, final OperationContext operationContext) {
    if (targets == null || targets.isEmpty()) {
        return;
    }
    final GraphContainer graphContainer = operationContext.getGraphContainer();
    final Set<VertexHopCriteria> criteriaForGraphContainer = Criteria.getCriteriaForGraphContainer(graphContainer, VertexHopCriteria.class);
    for (VertexHopCriteria eachCriteria : criteriaForGraphContainer) {
        for (VertexRef eachTarget : targets) {
            if (eachCriteria.getVertices().contains(eachTarget)) {
                graphContainer.removeCriteria(eachCriteria);
            }
        }
    }
    graphContainer.redoLayout();
}
Also used : GraphContainer(org.opennms.features.topology.api.GraphContainer) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria) WrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.WrappedVertexHopCriteria) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 4 with VertexHopCriteria

use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.

the class EnhancedLinkdTopologyProvider method addVertexHopCriteria.

@Override
public void addVertexHopCriteria(SearchResult searchResult, GraphContainer container) {
    LOG.debug("SearchProvider->addVertexHopCriteria: called with search result: '{}'", searchResult);
    VertexHopCriteria criterion = LinkdHopCriteriaFactory.createCriteria(searchResult.getId(), searchResult.getLabel());
    container.addCriteria(criterion);
    LOG.debug("SearchProvider->addVertexHop: adding hop criteria {}.", criterion);
    logCriteriaInContainer(container);
}
Also used : VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria)

Example 5 with VertexHopCriteria

use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.

the class EnhancedLinkdTopologyProvider method getVertexRefsBy.

@Override
public Set<VertexRef> getVertexRefsBy(SearchResult searchResult, GraphContainer container) {
    LOG.debug("SearchProvider->getVertexRefsBy: called with search result: '{}'", searchResult);
    org.opennms.features.topology.api.topo.Criteria criterion = findCriterion(searchResult.getId(), container);
    Set<VertexRef> vertices = ((VertexHopCriteria) criterion).getVertices();
    LOG.debug("SearchProvider->getVertexRefsBy: found '{}' vertices.", vertices.size());
    return vertices;
}
Also used : Criteria(org.opennms.features.topology.api.topo.Criteria) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Aggregations

VertexHopCriteria (org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria)8 Criteria (org.opennms.features.topology.api.topo.Criteria)5 VertexRef (org.opennms.features.topology.api.topo.VertexRef)3 GraphContainer (org.opennms.features.topology.api.GraphContainer)2 DefaultVertexHopCriteria (org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria)2 WrappedVertexHopCriteria (org.opennms.features.topology.api.support.VertexHopGraphProvider.WrappedVertexHopCriteria)2 CollapsibleCriteria (org.opennms.features.topology.api.topo.CollapsibleCriteria)2 VertexHopGraphProvider.getWrappedVertexHopCriteria (org.opennms.features.topology.api.support.VertexHopGraphProvider.getWrappedVertexHopCriteria)1 SearchSuggestion (org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion)1 CategoryHopCriteria (org.opennms.features.topology.app.internal.support.CategoryHopCriteria)1