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