use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class SearchManagerMultiIndexTest method testClean.
/**
* Test de création nettoyage de l'index.
* La création s'effectue dans une seule transaction.
*/
@Test
public void testClean() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final SearchIndexDefinition carIndexDefinition = definitionSpace.resolve(IDX_CAR, SearchIndexDefinition.class);
final SearchIndexDefinition carDynIndexDefinition = definitionSpace.resolve(IDX_DYNA_CAR, SearchIndexDefinition.class);
final ListFilter removeQuery = ListFilter.of("*:*");
searchManager.removeAll(carIndexDefinition, removeQuery);
searchManager.removeAll(carDynIndexDefinition, removeQuery);
waitIndexation();
final long sizeCar = query("*:*", carIndexDefinition);
Assert.assertEquals(0, sizeCar);
final long sizeCarDyn = query("*:*", carDynIndexDefinition);
Assert.assertEquals(0, sizeCarDyn);
}
use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class SearchManagerStoreTest method doSetUp.
@Override
protected void doSetUp() throws Exception {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
carIndexDefinition = definitionSpace.resolve(IDX_CAR, SearchIndexDefinition.class);
// A chaque test on recrée la table famille
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final SqlConnection connection = dataBaseManager.getConnectionProvider(SqlDataBaseManager.MAIN_CONNECTION_PROVIDER_NAME).obtainConnection();
execCallableStatement(connection, "create table car(ID BIGINT, MAKE varchar(50), MODEL varchar(255), DESCRIPTION varchar(512), YEAR INT, KILO INT, PRICE INT, CONSOMMATION NUMERIC(8,2), MOTOR_TYPE varchar(50), OPTIONAL_NUMBER BIGINT, OPTIONAL_STRING varchar(50) );");
execCallableStatement(connection, "create sequence SEQ_CAR start with 10001 increment by 1");
}
// On supprime tout
remove("*:*");
final CarDataBase carDataBase = new CarDataBase();
carDataBase.loadDatas();
initialDbCarSize = carDataBase.size();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
for (final Car car : carDataBase.getAllCars()) {
car.setId(null);
storeManager.getDataStore().create(car);
}
transaction.commit();
}
waitIndexation();
}
use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class FacetManagerTest method doSetUp.
/**
*{@inheritDoc}
*/
@Override
protected void doSetUp() {
// On construit la BDD des voitures
smartCarDataBase = new SmartCarDataBase();
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
carFacetQueryDefinition = definitionSpace.resolve("QRY_CAR_FACET", FacetedQueryDefinition.class);
}
use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class SearchDynamicRegistry method createFacetedQueryDefinition.
private static FacetedQueryDefinition createFacetedQueryDefinition(final DefinitionSpace definitionSpace, final DslDefinition xdefinition) {
final String definitionName = xdefinition.getName();
final DtDefinition keyConceptDtDefinition = definitionSpace.resolve(xdefinition.getDefinitionLinkName("keyConcept"), DtDefinition.class);
final List<String> dynamicFacetDefinitionNames = xdefinition.getDefinitionLinkNames("facets");
final List<FacetDefinition> facetDefinitions = dynamicFacetDefinitionNames.stream().map(dynamicDefinitionName -> definitionSpace.resolve(dynamicDefinitionName, FacetDefinition.class)).collect(Collectors.toList());
final String listFilterBuilderQuery = (String) xdefinition.getPropertyValue(SearchGrammar.LIST_FILTER_BUILDER_QUERY);
final Class<? extends ListFilterBuilder> listFilterBuilderClass = getListFilterBuilderClass(xdefinition);
final String criteriaDomainName = xdefinition.getDefinitionLinkName("domainCriteria");
final Domain criteriaDomain = definitionSpace.resolve(criteriaDomainName, Domain.class);
return new FacetedQueryDefinition(definitionName, keyConceptDtDefinition, facetDefinitions, criteriaDomain, listFilterBuilderClass, listFilterBuilderQuery);
}
use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class DefinitionSpaceTest method testRegister.
@Test
public void testRegister() throws IOException, ClassNotFoundException {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
assertEquals(1L, definitionSpace.getAllTypes().size(), "definitionSpace must contain one element ");
assertEquals(1L, definitionSpace.getAll(SampleDefinition.class).size(), "definitionSpace[SampleDefinition.class] must contain one element ");
final SampleDefinition sampleDefinition = definitionSpace.resolve("SAMPLE_THE_DEFINITION", SampleDefinition.class);
assertNotNull(sampleDefinition);
assertEquals("THE_DEFINITION", DefinitionUtil.getLocalName(sampleDefinition.getName(), SampleDefinition.class), "localName must be THE_DEFINITION");
assertEquals(sampleDefinition.getName(), DefinitionUtil.getPrefix(SampleDefinition.class) + "_" + DefinitionUtil.getLocalName(sampleDefinition.getName(), SampleDefinition.class), "localName must be THE_DEFINITION");
final DefinitionReference<SampleDefinition> sampleDefinitionRef = new DefinitionReference<>(sampleDefinition);
byte[] serialized;
try (final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(bos)) {
oos.writeObject(sampleDefinitionRef);
oos.flush();
serialized = bos.toByteArray();
}
// ---
DefinitionReference definitionReference;
try (final ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
final ObjectInputStream ios = new ObjectInputStream(bis)) {
definitionReference = DefinitionReference.class.cast(ios.readObject());
}
assertNotSame(sampleDefinitionRef, definitionReference, "DefinitionReferences must be not strictly equals");
assertSame(sampleDefinition, definitionReference.get(), "Definitions must be strictly equals");
}
Aggregations