Search in sources :

Example 16 with ListFilter

use of io.vertigo.dynamo.collections.ListFilter in project vertigo by KleeGroup.

the class UiSelectedFacets method toListFilters.

/**
 * Convert this Selected Facets to a list of ListFilter.
 * @return ListFilter for these Facets
 */
public List<ListFilter> toListFilters() {
    final List<ListFilter> listFilters = new ArrayList<>(size());
    // facet selection list.
    for (final Map.Entry<String, String> entry : entrySet()) {
        final FacetDefinition facetDefinition = Home.getApp().getDefinitionSpace().resolve(entry.getKey(), FacetDefinition.class);
        if (facetDefinition.isRangeFacet()) {
            for (final FacetValue facet : facetDefinition.getFacetRanges()) {
                if (facet.getCode().equals(entry.getValue())) {
                    listFilters.add(facet.getListFilter());
                    break;
                }
            }
        } else {
            final ListFilter filter = ListFilter.of(facetDefinition.getDtField().getName() + ":\"" + entry.getValue() + "\"");
            listFilters.add(filter);
        }
    }
    return listFilters;
}
Also used : ListFilter(io.vertigo.dynamo.collections.ListFilter) FacetValue(io.vertigo.dynamo.collections.model.FacetValue) ArrayList(java.util.ArrayList) FacetDefinition(io.vertigo.dynamo.collections.metamodel.FacetDefinition) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ListFilter (io.vertigo.dynamo.collections.ListFilter)16 FacetValue (io.vertigo.dynamo.collections.model.FacetValue)3 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)2 MessageText (io.vertigo.core.locale.MessageText)2 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)2 HashMap (java.util.HashMap)2 QueryNodeException (org.apache.lucene.queryparser.flexible.core.QueryNodeException)2 StandardQueryParser (org.apache.lucene.queryparser.flexible.standard.StandardQueryParser)2 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 Builder (org.apache.lucene.search.BooleanQuery.Builder)2 Test (org.junit.Test)2 FacetDefinition (io.vertigo.dynamo.collections.metamodel.FacetDefinition)1 DtField (io.vertigo.dynamo.domain.metamodel.DtField)1 DtList (io.vertigo.dynamo.domain.model.DtList)1 DtObject (io.vertigo.dynamo.domain.model.DtObject)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1