use of com.bakdata.conquery.apiv1.FilterSearchItem in project conquery by bakdata.
the class ConceptsProcessor method autocompleteTextFilter.
/**
* Autocompletion for search terms. For values of {@link AbstractSelectFilter<?>}.
* Is used by the serach cache to load missing items
*/
private static List<FEValue> autocompleteTextFilter(AbstractSelectFilter<?> filter, String text) {
if (Strings.isNullOrEmpty(text)) {
// If no text provided, we just list them
// Filter might not have a source search (since none might be defined).
// TODO unify these code paths, they are quite the mess, maybe also create source search for key-value also
final Stream<FEValue> fromSearch = filter.getSourceSearch() == null ? Stream.empty() : filter.getSourceSearch().listItems().stream().map(item -> new FEValue(item.getLabel(), item.getValue(), item.getTemplateValues(), item.getOptionValue()));
final Stream<FEValue> fromLabels = filter.getLabels().entrySet().stream().map(entry -> new FEValue(entry.getValue(), entry.getKey()));
return Stream.concat(fromLabels, fromSearch).sorted().collect(Collectors.toList());
}
List<FEValue> result = new LinkedList<>();
QuickSearch<FilterSearchItem> search = filter.getSourceSearch();
if (search != null) {
result = createSourceSearchResult(filter.getSourceSearch(), Collections.singletonList(text), OptionalInt.empty(), FilterSearch.FilterSearchType.CONTAINS::score);
}
String value = filter.getValueFor(text);
if (value != null) {
result.add(new FEValue(text, value));
}
return result;
}
Aggregations