Search in sources :

Example 1 with HistoryOperation

use of org.opennms.features.topology.api.HistoryOperation in project opennms by OpenNMS.

the class SavedHistory method apply.

public void apply(GraphContainer graphContainer, Collection<HistoryOperation> operations, ServiceLocator serviceLocator) {
    LOG.debug("Applying " + toString());
    graphContainer.clearCriteria();
    // Apply the history for each registered HistoryOperation
    for (HistoryOperation operation : operations) {
        try {
            operation.applyHistory(graphContainer, m_settings);
        } catch (Throwable e) {
            LOG.warn("Failed to perform applyHistory() operation", e);
        }
    }
    // Browse through all available search providers that have a "history" functionality
    List<SearchProvider> searchProviders = serviceLocator.findServices(SearchProvider.class, null);
    for (SearchProvider searchProvider : searchProviders) {
        if (searchProvider instanceof HistoryAwareSearchProvider) {
            // Add resulting Criteria to the graph container
            for (SearchResult searchQuery : m_searchQueries) {
                if (searchProvider.getSearchProviderNamespace().equals(searchQuery.getNamespace()) || searchProvider.contributesTo(searchQuery.getNamespace())) {
                    Criteria searchCriteria = ((HistoryAwareSearchProvider) searchProvider).buildCriteriaFromQuery(searchQuery, graphContainer);
                    graphContainer.addCriteria(searchCriteria);
                }
            }
        }
    }
    // Set Vertices in Focus after all other operations are applied, otherwise the topology provider may have changed
    // which results in a graphContainer.clearCriteria()
    applyVerticesInFocus(m_focusVertices, graphContainer);
    applySavedLocations(m_locations, graphContainer.getGraph().getLayout());
    graphContainer.setSemanticZoomLevel(getSemanticZoomLevel());
    // Apply the selected vertices
    graphContainer.getSelectionManager().setSelectedVertexRefs(m_selectedVertices);
    graphContainer.getMapViewManager().setBoundingBox(getBoundingBox());
}
Also used : HistoryOperation(org.opennms.features.topology.api.HistoryOperation) SearchProvider(org.opennms.features.topology.api.topo.SearchProvider) SearchResult(org.opennms.features.topology.api.topo.SearchResult) CollapsibleCriteria(org.opennms.features.topology.api.topo.CollapsibleCriteria) SearchCriteria(org.opennms.features.topology.api.topo.SearchCriteria) Criteria(org.opennms.features.topology.api.topo.Criteria)

Aggregations

HistoryOperation (org.opennms.features.topology.api.HistoryOperation)1 CollapsibleCriteria (org.opennms.features.topology.api.topo.CollapsibleCriteria)1 Criteria (org.opennms.features.topology.api.topo.Criteria)1 SearchCriteria (org.opennms.features.topology.api.topo.SearchCriteria)1 SearchProvider (org.opennms.features.topology.api.topo.SearchProvider)1 SearchResult (org.opennms.features.topology.api.topo.SearchResult)1