use of io.vertigo.dynamo.collections.model.SelectedFacetValues.SelectedFacetValuesBuilder 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();
}
use of io.vertigo.dynamo.collections.model.SelectedFacetValues.SelectedFacetValuesBuilder in project vertigo by KleeGroup.
the class SelectedFacetValuesDeserializer method deserialize.
@Override
public SelectedFacetValues deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) {
final SelectedFacetValuesBuilder selectedFacetValuesBuilder = SelectedFacetValues.empty();
final JsonObject jsonObject = json.getAsJsonObject();
for (final Entry<String, JsonElement> entry : jsonObject.entrySet()) {
final FacetDefinition facetDefinition = Home.getApp().getDefinitionSpace().resolve(entry.getKey(), FacetDefinition.class);
if (facetDefinition.isRangeFacet()) {
appendRangeFacetValues(entry.getValue(), facetDefinition, selectedFacetValuesBuilder);
} else {
appendTermFacetValues(entry.getValue(), facetDefinition, selectedFacetValuesBuilder);
}
}
return selectedFacetValuesBuilder.build();
}
Aggregations