@Test public void testProviderFiltering() { Collection<String> providerAliases = new HashSet<String>(); providerAliases.add("1"); Collection<TagSuggestion> tagSuggestions = tagSuggestionManagement.findTagSuggestions( Types.NOTE, providerAliases, null, false, null, null, null); Assert.assertEquals(tagSuggestions.size(), 2); for (TagSuggestion tagSuggestion : tagSuggestions) { Assert.assertTrue(tagSuggestion.getAlias().startsWith("1_")); } providerAliases.add("2"); tagSuggestions = tagSuggestionManagement.findTagSuggestions(Types.NOTE, providerAliases, null, false, null, null, null); Assert.assertEquals(tagSuggestions.size(), 4); providerAliases.remove("1"); tagSuggestions = tagSuggestionManagement.findTagSuggestions(Types.NOTE, providerAliases, null, false, null, null, null); Assert.assertEquals(tagSuggestions.size(), 2); for (TagSuggestion tagSuggestion : tagSuggestions) { Assert.assertTrue(tagSuggestion.getAlias().startsWith("2_")); } }
public Collection<TagSuggestion> findTagSuggestions(TagStoreType type, Collection<String> tagSuggestionProviderAliases, Collection<String> tagSuggestionAliases, boolean assignedTagsOnly, Map<String, Object> filters, QueryParametersParameterNameProvider nameProvider, Locale locale) { if (tagSuggestionProviderAliases == null) { tagSuggestionProviderAliases = Collections.emptyList(); } if (tagSuggestionAliases != null && tagSuggestionAliases.isEmpty()) { tagSuggestionAliases = null; } Collection<TagSuggestion> suggestions = new ArrayList<TagSuggestion>(); for (TagSuggestionProvider provider : tagSuggestionProviders) { if (skipProvider(type, tagSuggestionProviderAliases, provider)) { continue; } Collection<String> filteredTagSuggestionAliases = this.filterTagSuggestionAliases( tagSuggestionAliases, provider, assignedTagsOnly); if (filteredTagSuggestionAliases == null || filteredTagSuggestionAliases.size() > 0) { Collection<TagSuggestion> tagSuggestions = provider.findTagSuggestions( filteredTagSuggestionAliases, assignedTagsOnly, filters, nameProvider, locale); if (tagSuggestions != null) { suggestions.addAll(tagSuggestions); } } } return suggestions; }
TagSuggestionManagement { public Collection<TagSuggestion> findTagSuggestions(TagStoreType type, Collection<String> tagSuggestionProviderAliases, Collection<String> tagSuggestionAliases, boolean assignedTagsOnly, Map<String, Object> filters, QueryParametersParameterNameProvider nameProvider, Locale locale) { if (tagSuggestionProviderAliases == null) { tagSuggestionProviderAliases = Collections.emptyList(); } if (tagSuggestionAliases != null && tagSuggestionAliases.isEmpty()) { tagSuggestionAliases = null; } Collection<TagSuggestion> suggestions = new ArrayList<TagSuggestion>(); for (TagSuggestionProvider provider : tagSuggestionProviders) { if (skipProvider(type, tagSuggestionProviderAliases, provider)) { continue; } Collection<String> filteredTagSuggestionAliases = this.filterTagSuggestionAliases( tagSuggestionAliases, provider, assignedTagsOnly); if (filteredTagSuggestionAliases == null || filteredTagSuggestionAliases.size() > 0) { Collection<TagSuggestion> tagSuggestions = provider.findTagSuggestions( filteredTagSuggestionAliases, assignedTagsOnly, filters, nameProvider, locale); if (tagSuggestions != null) { suggestions.addAll(tagSuggestions); } } } return suggestions; } }
TagSuggestionManagement { public Collection<TagSuggestion> findTagSuggestions(TagStoreType type, Collection<String> tagSuggestionProviderAliases, Collection<String> tagSuggestionAliases, boolean assignedTagsOnly, Map<String, Object> filters, QueryParametersParameterNameProvider nameProvider, Locale locale) { if (tagSuggestionProviderAliases == null) { tagSuggestionProviderAliases = Collections.emptyList(); } if (tagSuggestionAliases != null && tagSuggestionAliases.isEmpty()) { tagSuggestionAliases = null; } Collection<TagSuggestion> suggestions = new ArrayList<TagSuggestion>(); for (TagSuggestionProvider provider : tagSuggestionProviders) { if (skipProvider(type, tagSuggestionProviderAliases, provider)) { continue; } Collection<String> filteredTagSuggestionAliases = this.filterTagSuggestionAliases( tagSuggestionAliases, provider, assignedTagsOnly); if (filteredTagSuggestionAliases == null || filteredTagSuggestionAliases.size() > 0) { Collection<TagSuggestion> tagSuggestions = provider.findTagSuggestions( filteredTagSuggestionAliases, assignedTagsOnly, filters, nameProvider, locale); if (tagSuggestions != null) { suggestions.addAll(tagSuggestions); } } } return suggestions; }  }
TagSuggestionManagement { public Collection<TagSuggestion> findTagSuggestions(TagStoreType type, Collection<String> tagSuggestionProviderAliases, Collection<String> tagSuggestionAliases, boolean assignedTagsOnly, Map<String, Object> filters, QueryParametersParameterNameProvider nameProvider, Locale locale) { if (tagSuggestionProviderAliases == null) { tagSuggestionProviderAliases = Collections.emptyList(); } if (tagSuggestionAliases != null && tagSuggestionAliases.isEmpty()) { tagSuggestionAliases = null; } Collection<TagSuggestion> suggestions = new ArrayList<TagSuggestion>(); for (TagSuggestionProvider provider : tagSuggestionProviders) { if (skipProvider(type, tagSuggestionProviderAliases, provider)) { continue; } Collection<String> filteredTagSuggestionAliases = this.filterTagSuggestionAliases( tagSuggestionAliases, provider, assignedTagsOnly); if (filteredTagSuggestionAliases == null || filteredTagSuggestionAliases.size() > 0) { Collection<TagSuggestion> tagSuggestions = provider.findTagSuggestions( filteredTagSuggestionAliases, assignedTagsOnly, filters, nameProvider, locale); if (tagSuggestions != null) { suggestions.addAll(tagSuggestions); } } } return suggestions; }  synchronized void addTagSuggestionProvider(TagSuggestionProvider provider); Collection<TagSuggestion> findTagSuggestions(TagStoreType type,
            Collection<String> tagSuggestionProviderAliases,
            Collection<String> tagSuggestionAliases, boolean assignedTagsOnly,
            Map<String, Object> filters, QueryParametersParameterNameProvider nameProvider,
            Locale locale); List<TagSuggestionConfiguration> getTagSuggestionConfigurations(TagStoreType type,
            boolean assignedOnly); @PostConstruct void init(); synchronized void removeTagSuggestionProvider(TagSuggestionProvider provider); }
TagSuggestionManagement { public Collection<TagSuggestion> findTagSuggestions(TagStoreType type, Collection<String> tagSuggestionProviderAliases, Collection<String> tagSuggestionAliases, boolean assignedTagsOnly, Map<String, Object> filters, QueryParametersParameterNameProvider nameProvider, Locale locale) { if (tagSuggestionProviderAliases == null) { tagSuggestionProviderAliases = Collections.emptyList(); } if (tagSuggestionAliases != null && tagSuggestionAliases.isEmpty()) { tagSuggestionAliases = null; } Collection<TagSuggestion> suggestions = new ArrayList<TagSuggestion>(); for (TagSuggestionProvider provider : tagSuggestionProviders) { if (skipProvider(type, tagSuggestionProviderAliases, provider)) { continue; } Collection<String> filteredTagSuggestionAliases = this.filterTagSuggestionAliases( tagSuggestionAliases, provider, assignedTagsOnly); if (filteredTagSuggestionAliases == null || filteredTagSuggestionAliases.size() > 0) { Collection<TagSuggestion> tagSuggestions = provider.findTagSuggestions( filteredTagSuggestionAliases, assignedTagsOnly, filters, nameProvider, locale); if (tagSuggestions != null) { suggestions.addAll(tagSuggestions); } } } return suggestions; }  synchronized void addTagSuggestionProvider(TagSuggestionProvider provider); Collection<TagSuggestion> findTagSuggestions(TagStoreType type,
            Collection<String> tagSuggestionProviderAliases,
            Collection<String> tagSuggestionAliases, boolean assignedTagsOnly,
            Map<String, Object> filters, QueryParametersParameterNameProvider nameProvider,
            Locale locale); List<TagSuggestionConfiguration> getTagSuggestionConfigurations(TagStoreType type,
            boolean assignedOnly); @PostConstruct void init(); synchronized void removeTagSuggestionProvider(TagSuggestionProvider provider); final static String PARAMETER_TAG_STORE_ALIASES; }