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());
}
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;
}
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);
}
Aggregations