Search in sources :

Example 1 with DefinitionSpace

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);
}
Also used : ListFilter(io.vertigo.dynamo.collections.ListFilter) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) Test(org.junit.Test)

Example 2 with DefinitionSpace

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();
}
Also used : CarDataBase(io.vertigo.dynamo.search_2_4.data.domain.CarDataBase) Car(io.vertigo.dynamo.search_2_4.data.domain.Car) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) SqlConnection(io.vertigo.database.sql.connection.SqlConnection)

Example 3 with DefinitionSpace

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);
}
Also used : SmartCarDataBase(io.vertigo.dynamo.collections.data.domain.SmartCarDataBase) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) FacetedQueryDefinition(io.vertigo.dynamo.collections.metamodel.FacetedQueryDefinition)

Example 4 with DefinitionSpace

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);
}
Also used : Arrays(java.util.Arrays) ListFilter(io.vertigo.dynamo.collections.ListFilter) DtField(io.vertigo.dynamo.domain.metamodel.DtField) HashMap(java.util.HashMap) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) ArrayList(java.util.ArrayList) FacetDefinition(io.vertigo.dynamo.collections.metamodel.FacetDefinition) Map(java.util.Map) Assertion(io.vertigo.lang.Assertion) KspProperty(io.vertigo.dynamo.plugins.environment.KspProperty) DslEntity(io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntity) DslGrammar(io.vertigo.dynamo.plugins.environment.dsl.entity.DslGrammar) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) Domain(io.vertigo.dynamo.domain.metamodel.Domain) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) FacetedQueryDefinition(io.vertigo.dynamo.collections.metamodel.FacetedQueryDefinition) ClassUtil(io.vertigo.util.ClassUtil) Collectors(java.util.stream.Collectors) Definition(io.vertigo.core.definition.Definition) MessageText(io.vertigo.core.locale.MessageText) List(java.util.List) ListFilterBuilder(io.vertigo.dynamo.collections.metamodel.ListFilterBuilder) DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) DefinitionSupplier(io.vertigo.core.definition.DefinitionSupplier) FacetOrder(io.vertigo.dynamo.collections.metamodel.FacetDefinition.FacetOrder) FacetValue(io.vertigo.dynamo.collections.model.FacetValue) DynamicRegistry(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DynamicRegistry) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) FacetDefinition(io.vertigo.dynamo.collections.metamodel.FacetDefinition) Domain(io.vertigo.dynamo.domain.metamodel.Domain) FacetedQueryDefinition(io.vertigo.dynamo.collections.metamodel.FacetedQueryDefinition)

Example 5 with DefinitionSpace

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");
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) DefinitionReference(io.vertigo.core.definition.DefinitionReference) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.jupiter.api.Test)

Aggregations

DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)29 Test (org.junit.Test)18 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)9 Domain (io.vertigo.dynamo.domain.metamodel.Domain)6 FacetedQueryDefinition (io.vertigo.dynamo.collections.metamodel.FacetedQueryDefinition)4 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)4 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)4 FormatterDefault (io.vertigo.dynamox.domain.formatter.FormatterDefault)4 ListFilter (io.vertigo.dynamo.collections.ListFilter)3 FacetDefinition (io.vertigo.dynamo.collections.metamodel.FacetDefinition)3 FormatterDefinition (io.vertigo.dynamo.domain.metamodel.FormatterDefinition)3 Task (io.vertigo.dynamo.task.model.Task)3 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)2 SqlConnection (io.vertigo.database.sql.connection.SqlConnection)2 DslDefinition (io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition)2 Item (io.vertigo.dynamo.search.data.domain.Item)2 ItemDataBase (io.vertigo.dynamo.search.data.domain.ItemDataBase)2 Car (io.vertigo.dynamo.search_2_4.data.domain.Car)2 CarDataBase (io.vertigo.dynamo.search_2_4.data.domain.CarDataBase)2 TaskResult (io.vertigo.dynamo.task.model.TaskResult)2