use of io.vertigo.dynamo.collections.model.FacetedQuery in project vertigo by KleeGroup.
the class FacetManagerTest method testFacetListByRange.
/**
* Test le facettage par range d'une liste.
*/
@Test
public void testFacetListByRange() {
final DtList<SmartCar> cars = smartCarDataBase.getAllCars();
final FacetedQuery facetedQuery = new FacetedQuery(carFacetQueryDefinition, SelectedFacetValues.empty().build());
final FacetedQueryResult<SmartCar, DtList<SmartCar>> result = collectionsManager.facetList(cars, facetedQuery);
testFacetResultByRange(result);
}
use of io.vertigo.dynamo.collections.model.FacetedQuery 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.FacetedQuery 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.FacetedQuery 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