Search in sources :

Example 1 with SearchSuggestion

use of org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion in project opennms by OpenNMS.

the class GraphMLSearchProviderTest method canSearchAllSearchProviders.

@Test
public void canSearchAllSearchProviders() throws IOException, InvalidGraphException {
    final GraphMLMetaTopologyProvider metaTopologyProvider = new GraphMLMetaTopologyProvider(new GraphMLServiceAccessor());
    metaTopologyProvider.setTopologyLocation("target/test-classes/test-graph.xml");
    metaTopologyProvider.reload();
    Assert.assertNotNull(metaTopologyProvider.getDefaultGraphProvider());
    List<SearchProvider> searchProviders = metaTopologyProvider.getGraphProviders().stream().map(eachProvider -> new GraphMLSearchProvider(metaTopologyProvider.getRawTopologyProvider(eachProvider.getNamespace()))).collect(Collectors.toList());
    Assert.assertEquals(2, searchProviders.size());
    DefaultTopologyService defaultTopologyService = new DefaultTopologyService();
    defaultTopologyService.setServiceLocator(new SimpleServiceLocator(metaTopologyProvider));
    VEProviderGraphContainer graphContainer = new VEProviderGraphContainer();
    graphContainer.setTopologyService(defaultTopologyService);
    graphContainer.setMetaTopologyId(metaTopologyProvider.getId());
    graphContainer.setSelectedNamespace(metaTopologyProvider.getDefaultGraphProvider().getNamespace());
    OperationContext operationContext = EasyMock.niceMock(OperationContext.class);
    EasyMock.expect(operationContext.getGraphContainer()).andReturn(graphContainer).anyTimes();
    OnmsServiceManager onmsServiceManager = EasyMock.niceMock(OnmsServiceManager.class);
    EasyMock.expect(onmsServiceManager.getServices(SearchProvider.class, null, new Hashtable<>())).andReturn(searchProviders).anyTimes();
    EasyMock.replay(onmsServiceManager, operationContext);
    SearchBox searchBox = new SearchBox(onmsServiceManager, operationContext);
    List<SearchSuggestion> results = searchBox.getQueryResults("North");
    Assert.assertEquals(5, results.size());
}
Also used : IOException(java.io.IOException) Test(org.junit.Test) EasyMock(org.easymock.EasyMock) DefaultTopologyService(org.opennms.features.topology.app.internal.service.DefaultTopologyService) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) Collectors(java.util.stream.Collectors) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) List(java.util.List) OperationContext(org.opennms.features.topology.api.OperationContext) InvalidGraphException(org.opennms.features.graphml.model.InvalidGraphException) SearchSuggestion(org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion) VEProviderGraphContainer(org.opennms.features.topology.app.internal.VEProviderGraphContainer) Assert(org.junit.Assert) SimpleServiceLocator(org.opennms.features.topology.app.internal.service.SimpleServiceLocator) GraphMLGraph(org.opennms.features.graphml.model.GraphMLGraph) GraphMLServiceAccessor(org.opennms.features.topology.plugins.topo.graphml.internal.GraphMLServiceAccessor) Hashtable(java.util.Hashtable) SearchProvider(org.opennms.features.topology.api.topo.SearchProvider) OperationContext(org.opennms.features.topology.api.OperationContext) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) SearchSuggestion(org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion) DefaultTopologyService(org.opennms.features.topology.app.internal.service.DefaultTopologyService) VEProviderGraphContainer(org.opennms.features.topology.app.internal.VEProviderGraphContainer) Hashtable(java.util.Hashtable) SimpleServiceLocator(org.opennms.features.topology.app.internal.service.SimpleServiceLocator) SearchProvider(org.opennms.features.topology.api.topo.SearchProvider) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) GraphMLServiceAccessor(org.opennms.features.topology.plugins.topo.graphml.internal.GraphMLServiceAccessor) Test(org.junit.Test)

Example 2 with SearchSuggestion

use of org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion in project opennms by OpenNMS.

the class SearchBox method mapToSearchSuggestion.

private static SearchSuggestion mapToSearchSuggestion(SearchResult searchResult) {
    SearchSuggestion suggestion = new SearchSuggestion(searchResult.getNamespace(), searchResult.getId(), searchResult.getLabel());
    suggestion.setCollapsible(searchResult.isCollapsible());
    suggestion.setCollapsed(searchResult.isCollapsed());
    suggestion.setQuery(searchResult.getQuery());
    return suggestion;
}
Also used : SearchSuggestion(org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion)

Example 3 with SearchSuggestion

use of org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion in project opennms by OpenNMS.

the class SearchBox method updateTokenFieldList.

private void updateTokenFieldList(GraphContainer graphContainer) {
    final List<SearchSuggestion> suggestions = Lists.newArrayList();
    final Criteria[] criterium = graphContainer.getCriteria();
    for (Criteria criteria : criterium) {
        try {
            CollapsibleCriteria crit = (CollapsibleCriteria) criteria;
            SearchSuggestion suggestion = new SearchSuggestion(crit.getNamespace(), crit.getId(), crit.getLabel());
            suggestion.setCollapsible(true);
            suggestion.setCollapsed(crit.isCollapsed());
            suggestions.add(suggestion);
            continue;
        } catch (ClassCastException e) {
        }
        try {
            VertexHopCriteria crit = (VertexHopCriteria) criteria;
            SearchSuggestion suggestion = new SearchSuggestion(crit.getNamespace(), crit.getId(), crit.getLabel());
            suggestions.add(suggestion);
            continue;
        } catch (ClassCastException e) {
        }
    }
    getState().setFocused(suggestions);
}
Also used : SearchSuggestion(org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion) CollapsibleCriteria(org.opennms.features.topology.api.topo.CollapsibleCriteria) CollapsibleCriteria(org.opennms.features.topology.api.topo.CollapsibleCriteria) DefaultVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria) Criteria(org.opennms.features.topology.api.topo.Criteria) DefaultVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria)

Aggregations

SearchSuggestion (org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion)3 IOException (java.io.IOException)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 EasyMock (org.easymock.EasyMock)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 GraphMLGraph (org.opennms.features.graphml.model.GraphMLGraph)1 InvalidGraphException (org.opennms.features.graphml.model.InvalidGraphException)1 OperationContext (org.opennms.features.topology.api.OperationContext)1 DefaultVertexHopCriteria (org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria)1 VertexHopCriteria (org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria)1 CollapsibleCriteria (org.opennms.features.topology.api.topo.CollapsibleCriteria)1 Criteria (org.opennms.features.topology.api.topo.Criteria)1 SearchProvider (org.opennms.features.topology.api.topo.SearchProvider)1 VEProviderGraphContainer (org.opennms.features.topology.app.internal.VEProviderGraphContainer)1 DefaultTopologyService (org.opennms.features.topology.app.internal.service.DefaultTopologyService)1 SimpleServiceLocator (org.opennms.features.topology.app.internal.service.SimpleServiceLocator)1 SearchBox (org.opennms.features.topology.app.internal.ui.SearchBox)1