Search in sources :

Example 11 with MessageText

use of io.vertigo.core.locale.MessageText in project vertigo by KleeGroup.

the class UiSelectedFacets method toSelectedFacetValues.

/**
 * Convert this Ui Selected Facets to a SelectedFacetValues.
 * @return ListFilter for these Facets
 */
public SelectedFacetValues toSelectedFacetValues() {
    final SelectedFacetValuesBuilder selectedFacetValuesBuilder = SelectedFacetValues.empty();
    // 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()) {
            final String label = entry.getValue();
            for (final FacetValue facet : facetDefinition.getFacetRanges()) {
                if (facet.getLabel().getDisplay().equals(label)) {
                    selectedFacetValuesBuilder.add(facetDefinition, facet);
                    break;
                }
            }
        } else {
            final String term = entry.getValue();
            final MessageText label = MessageText.of(term);
            final String query = facetDefinition.getDtField().getName() + ":\"" + term + "\"";
            final FacetValue facetValue = new FacetValue(term, ListFilter.of(query), label);
            selectedFacetValuesBuilder.add(facetDefinition, facetValue);
        }
    }
    return selectedFacetValuesBuilder.build();
}
Also used : FacetValue(io.vertigo.dynamo.collections.model.FacetValue) SelectedFacetValuesBuilder(io.vertigo.dynamo.collections.model.SelectedFacetValues.SelectedFacetValuesBuilder) MessageText(io.vertigo.core.locale.MessageText) FacetDefinition(io.vertigo.dynamo.collections.metamodel.FacetDefinition) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

MessageText (io.vertigo.core.locale.MessageText)11 FacetValue (io.vertigo.dynamo.collections.model.FacetValue)9 LinkedHashMap (java.util.LinkedHashMap)5 FacetDefinition (io.vertigo.dynamo.collections.metamodel.FacetDefinition)4 Bucket (org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket)4 DtList (io.vertigo.dynamo.domain.model.DtList)3 ListFilter (io.vertigo.dynamo.collections.ListFilter)2 Facet (io.vertigo.dynamo.collections.model.Facet)2 DtField (io.vertigo.dynamo.domain.metamodel.DtField)2 HashMap (java.util.HashMap)2 Aggregation (org.elasticsearch.search.aggregations.Aggregation)2 MultiBucketsAggregation (org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation)2 MessageKey (io.vertigo.core.locale.MessageKey)1 SelectedFacetValuesBuilder (io.vertigo.dynamo.collections.model.SelectedFacetValues.SelectedFacetValuesBuilder)1 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)1 DtObject (io.vertigo.dynamo.domain.model.DtObject)1 DslDefinition (io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition)1 VUserException (io.vertigo.lang.VUserException)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1