Search in sources :

Example 11 with DslDefinition

use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.

the class DslDefinitionRuleTest method test1.

@Test
public void test1() throws PegNoMatchFoundException {
    final DslDefinition dslDefinition = new DslDynamicDefinitionRule("create", dslDefinitionRepository.getGrammar()).parse("create Formatter FMT_TEST { args : \"UPPER\" }", 0).getValue();
    Assert.assertNotNull(dslDefinition);
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) DslDynamicDefinitionRule(io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDynamicDefinitionRule) Test(org.junit.Test)

Example 12 with DslDefinition

use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.

the class DslDefinitionRuleTest method test2.

// Exemple de test sur la déclaration d'un Domain
// create Domain DO_CODE_POSTAL (
// dataType : String;
// formatter : FMT_DEFAULT;
// constraint : {CK_CODE_POSTAL}
// )
@Test
public void test2() throws PegNoMatchFoundException {
    final DslDefinition dslDefinition = new DslDynamicDefinitionRule("create", dslDefinitionRepository.getGrammar()).parse("create Domain DO_CODE_POSTAL { dataType : String ,  formatter:FMT_DEFAULT, constraint : [ CK_CODE_POSTAL ]   } ", 0).getValue();
    Assert.assertNotNull(dslDefinition);
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) DslDynamicDefinitionRule(io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDynamicDefinitionRule) Test(org.junit.Test)

Example 13 with DslDefinition

use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.

the class EnvironmentManagerTest method badTypeTest.

@Test
public void badTypeTest() {
    Assertions.assertThrows(ClassCastException.class, () -> {
        final DslDefinition address1Definition = DslDefinition.builder("MOCK_MAIN_ADDRESS", PersonGrammar.ADDRESS_ENTITY).withPackageName("io.vertigo.test.model").addPropertyValue(STREET, "1, rue du louvre").addPropertyValue(POSTAL_CODE, 75008).addPropertyValue(CITY, "Paris").build();
        dslDefinitionRepository.addDefinition(address1Definition);
    });
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) Test(org.junit.jupiter.api.Test)

Example 14 with DslDefinition

use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.

the class EnvironmentManagerTest method simpleTest.

@Test
public void simpleTest() {
    final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
    final DslDefinition address1Definition = DslDefinition.builder("MOCK_MAIN_ADDRESS", PersonGrammar.ADDRESS_ENTITY).withPackageName("io.vertigo.test.model").addPropertyValue(STREET, "1, rue du louvre").addPropertyValue(POSTAL_CODE, "75008").addPropertyValue(CITY, "Paris").build();
    dslDefinitionRepository.addDefinition(address1Definition);
    final DslDefinition address2Definition = DslDefinition.builder("MOCK_SECOND_ADDRESS", PersonGrammar.ADDRESS_ENTITY).withPackageName("io.vertigo.test.model").addPropertyValue(STREET, "105, rue martin").addPropertyValue(POSTAL_CODE, "75008").addPropertyValue(CITY, "Paris CEDEX").build();
    dslDefinitionRepository.addDefinition(address2Definition);
    final DslDefinition personDefinition = DslDefinition.builder("MOCK_MISTER_BEAN", PersonGrammar.PERSON_ENTITY).withPackageName("io.vertigo.test.model").addPropertyValue(NAME, "105, rue martin").addPropertyValue(FIRST_NAME, "75008").addPropertyValue(AGE, 42).addPropertyValue(HEIGHT, 175.0d).addPropertyValue(MALE, Boolean.TRUE).addDefinitionLink(MAIN_ADDRESS, "MOCK_MAIN_ADDRESS").addDefinitionLink(PersonGrammar.SECOND_ADDRESS, "MOCK_SECOND_ADDRESS").build();
    dslDefinitionRepository.addDefinition(personDefinition);
    dslDefinitionRepository.solve(definitionSpace);
    assertNotNull(personDefinition);
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) Test(org.junit.jupiter.api.Test)

Example 15 with DslDefinition

use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.

the class DynamoDefinitionProvider method parse.

/**
 * @param definitionResourceConfigs List of resources (must be in a type managed by this loader)
 */
private List<DefinitionSupplier> parse(final DefinitionSpace definitionSpace) {
    // Création du repositoy des instances le la grammaire (=> model)
    final DynamicRegistry dynamoDynamicRegistry = new DynamoDynamicRegistry();
    final DslDefinitionRepository dslDefinitionRepository = new DslDefinitionRepository(dynamoDynamicRegistry);
    // --Enregistrement des types primitifs
    for (final DslDefinition dslDefinition : dynamoDynamicRegistry.getGrammar().getRootDefinitions()) {
        dslDefinitionRepository.addDefinition(dslDefinition);
    }
    for (final DefinitionResourceConfig definitionResourceConfig : definitionResourceConfigs) {
        final Loader loaderPlugin = loadersByType.get(definitionResourceConfig.getType());
        Assertion.checkNotNull(loaderPlugin, "This resource {0} can not be parse by these loaders : {1}", definitionResourceConfig, loadersByType.keySet());
        loaderPlugin.load(definitionResourceConfig.getPath(), dslDefinitionRepository);
    }
    return dslDefinitionRepository.solve(definitionSpace);
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) DynamoDynamicRegistry(io.vertigo.dynamo.plugins.environment.registries.DynamoDynamicRegistry) DefinitionResourceConfig(io.vertigo.app.config.DefinitionResourceConfig) DynamoDynamicRegistry(io.vertigo.dynamo.plugins.environment.registries.DynamoDynamicRegistry) DynamicRegistry(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DynamicRegistry) AnnotationLoader(io.vertigo.dynamo.plugins.environment.loaders.java.AnnotationLoader) Loader(io.vertigo.dynamo.plugins.environment.loaders.Loader) EAXmiLoader(io.vertigo.dynamo.plugins.environment.loaders.eaxmi.core.EAXmiLoader) OOMLoader(io.vertigo.dynamo.plugins.environment.loaders.poweramc.core.OOMLoader) KprLoader(io.vertigo.dynamo.plugins.environment.loaders.kpr.KprLoader) DslDefinitionRepository(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinitionRepository)

Aggregations

DslDefinition (io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition)20 Domain (io.vertigo.dynamo.domain.metamodel.Domain)6 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)5 DtField (io.vertigo.dynamo.domain.metamodel.DtField)4 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)3 MessageText (io.vertigo.core.locale.MessageText)3 FacetDefinition (io.vertigo.dynamo.collections.metamodel.FacetDefinition)3 FacetValue (io.vertigo.dynamo.collections.model.FacetValue)3 DynamicRegistry (io.vertigo.dynamo.plugins.environment.dsl.dynamic.DynamicRegistry)3 DslEntity (io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntity)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Definition (io.vertigo.core.definition.Definition)2 DefinitionSupplier (io.vertigo.core.definition.DefinitionSupplier)2 ListFilter (io.vertigo.dynamo.collections.ListFilter)2 FacetOrder (io.vertigo.dynamo.collections.metamodel.FacetDefinition.FacetOrder)2 FacetedQueryDefinition (io.vertigo.dynamo.collections.metamodel.FacetedQueryDefinition)2 ListFilterBuilder (io.vertigo.dynamo.collections.metamodel.ListFilterBuilder)2 DtDefinitionBuilder (io.vertigo.dynamo.domain.metamodel.DtDefinitionBuilder)2 KspProperty (io.vertigo.dynamo.plugins.environment.KspProperty)2