use of io.vertigo.dynamo.collections.model.SelectedFacetValues in project vertigo by KleeGroup.
the class FacetManagerTest method addFacetQuery.
private static FacetedQuery addFacetQuery(final String facetName, final String facetValueLabel, final FacetedQueryResult<SmartCar, ?> result) {
// pb d'initialisation, et assert.notNull ne suffit pas
FacetValue facetFilter = null;
final Facet yearFacet = getFacetByName(result, facetName);
for (final Entry<FacetValue, Long> entry : yearFacet.getFacetValues().entrySet()) {
if (entry.getKey().getLabel().getDisplay().toLowerCase(Locale.FRENCH).contains(facetValueLabel)) {
facetFilter = entry.getKey();
break;
}
}
if (facetFilter == null) {
throw new IllegalArgumentException("Pas de FacetValue contenant " + facetValueLabel + " dans la facette " + facetName);
}
final FacetedQuery previousQuery = result.getFacetedQuery().get();
final SelectedFacetValues queryFilters = SelectedFacetValues.of(previousQuery.getSelectedFacetValues()).add(yearFacet.getDefinition(), facetFilter).build();
return new FacetedQuery(previousQuery.getDefinition(), queryFilters);
}
use of io.vertigo.dynamo.collections.model.SelectedFacetValues in project vertigo by KleeGroup.
the class AbstractSearchManagerTest method createFacetQuery.
private static FacetedQuery createFacetQuery(final String facetName, final String facetValueLabel, final FacetedQueryResult<Car, ?> result) {
// pb d'initialisation, et assert.notNull ne suffit pas
FacetValue facetValue = null;
final Facet facet = getFacetByName(result, facetName);
for (final Entry<FacetValue, Long> entry : facet.getFacetValues().entrySet()) {
if (entry.getKey().getLabel().getDisplay().toLowerCase(Locale.FRENCH).contains(facetValueLabel)) {
facetValue = entry.getKey();
break;
}
}
if (facetValue == null) {
throw new IllegalArgumentException("Pas de FacetValue contenant " + facetValueLabel + " dans la facette " + facetName);
}
final FacetedQuery previousQuery = result.getFacetedQuery().get();
final SelectedFacetValues queryFilters = SelectedFacetValues.of(previousQuery.getSelectedFacetValues()).add(facet.getDefinition(), facetValue).build();
return new FacetedQuery(previousQuery.getDefinition(), queryFilters);
}
use of io.vertigo.dynamo.collections.model.SelectedFacetValues in project vertigo by KleeGroup.
the class AbstractSearchManagerTest method createFacetQuery.
private static FacetedQuery createFacetQuery(final String facetName, final String facetValueLabel, final FacetedQueryResult<Item, ?> result) {
// pb d'initialisation, et assert.notNull ne suffit pas
FacetValue facetValue = null;
final Facet facet = getFacetByName(result, facetName);
for (final Entry<FacetValue, Long> entry : facet.getFacetValues().entrySet()) {
if (entry.getKey().getLabel().getDisplay().toLowerCase(Locale.FRENCH).contains(facetValueLabel)) {
facetValue = entry.getKey();
break;
}
}
if (facetValue == null) {
throw new IllegalArgumentException("Pas de FacetValue contenant " + facetValueLabel + " dans la facette " + facetName);
}
final FacetedQuery previousQuery = result.getFacetedQuery().get();
final SelectedFacetValues queryFilters = SelectedFacetValues.of(previousQuery.getSelectedFacetValues()).add(facet.getDefinition(), facetValue).build();
return new FacetedQuery(previousQuery.getDefinition(), queryFilters);
}
use of io.vertigo.dynamo.collections.model.SelectedFacetValues in project vertigo by KleeGroup.
the class CollectionsManagerImpl method filter.
// =========================================================================
// =======================Filtrage==========================================
// =========================================================================
private <D extends DtObject> Predicate<D> filter(final FacetedQuery facetedQuery) {
final SelectedFacetValues selectedFacetValues = facetedQuery.getSelectedFacetValues();
Predicate<D> predicate = list -> true;
for (final FacetDefinition facetDefinition : facetedQuery.getDefinition().getFacetDefinitions()) {
if (!selectedFacetValues.getFacetValues(facetDefinition).isEmpty()) {
Predicate<D> predicateValue = list -> false;
for (final FacetValue facetValue : selectedFacetValues.getFacetValues(facetDefinition)) {
predicateValue = predicateValue.or(this.filter(facetValue.getListFilter()));
}
predicate = predicate.and(predicateValue);
}
}
return predicate;
}
Aggregations