use of io.vertigo.dynamo.collections.model.FacetedQuery in project vertigo by KleeGroup.
the class FacetManagerTest method testFacetListByTerm.
/**
* Test le facettage par term d'une liste.
*/
@Test
public void testFacetListByTerm() {
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);
testFacetResultByTerm(result);
}
use of io.vertigo.dynamo.collections.model.FacetedQuery in project vertigo by KleeGroup.
the class FacetManagerTest method testFilterFacetListByRange.
/**
* Test le facettage par range d'une liste.
* Et le filtrage par une facette.
*/
@Test
public void testFilterFacetListByRange() {
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);
// on applique une facette
final FacetedQuery query = addFacetQuery("FCT_YEAR_CAR", "avant", result);
final FacetedQueryResult<SmartCar, DtList<SmartCar>> resultFiltered = collectionsManager.facetList(result.getSource(), query);
Assert.assertEquals(smartCarDataBase.getCarsBefore(2000), resultFiltered.getCount());
}
use of io.vertigo.dynamo.collections.model.FacetedQuery 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.FacetedQuery in project vertigo by KleeGroup.
the class FacetManagerTest method testFilterFacetListByTerm.
/**
* Test le facettage par term d'une liste.
* Et le filtrage par une facette.
*/
@Test
public void testFilterFacetListByTerm() {
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);
// on applique une facette
final FacetedQuery query = addFacetQuery("FCT_MANUFACTURER_CAR", "peugeot", result);
final FacetedQueryResult<SmartCar, DtList<SmartCar>> resultFiltered = collectionsManager.facetList(result.getSource(), query);
Assert.assertEquals(smartCarDataBase.getCarsByManufacturer("peugeot").size(), (int) resultFiltered.getCount());
}
use of io.vertigo.dynamo.collections.model.FacetedQuery in project vertigo by KleeGroup.
the class SearchTestWebServices method testFacetedQueryResult.
@POST("/facetedResult")
public FacetedQueryResult<Contact, DtList<Contact>> testFacetedQueryResult(final SelectedFacetValues selectedFacetValues) {
final DtList<Contact> allContacts = asDtList(contactDao.getList(), Contact.class);
final FacetedQueryDefinition facetedQueryDefinition = Home.getApp().getDefinitionSpace().resolve("QRY_CONTACT_FACET", FacetedQueryDefinition.class);
final FacetedQuery facetedQuery = new FacetedQuery(facetedQueryDefinition, selectedFacetValues);
return collectionsManager.facetList(allContacts, facetedQuery);
}
Aggregations