Search in sources :

Example 1 with DtStereotype

use of io.vertigo.dynamo.domain.metamodel.DtStereotype in project vertigo by KleeGroup.

the class AnnotationLoader method load.

private static void load(final Class<DtObject> clazz, final DslDefinitionRepository dslDefinitionRepository) {
    Assertion.checkNotNull(dslDefinitionRepository);
    // -----
    final String simpleName = clazz.getSimpleName();
    final String packageName = clazz.getPackage().getName();
    final String dtDefinitionName = DT_DEFINITION_PREFIX + SEPARATOR + StringUtil.camelToConstCase(simpleName);
    String fragmentOf = null;
    if (Fragment.class.isAssignableFrom(clazz)) {
        // Fragments
        for (final Annotation annotation : clazz.getAnnotations()) {
            if (annotation instanceof io.vertigo.dynamo.domain.stereotype.Fragment) {
                fragmentOf = ((io.vertigo.dynamo.domain.stereotype.Fragment) annotation).fragmentOf();
                break;
            }
        }
        parseFragment(clazz, fragmentOf, dtDefinitionName, packageName, dslDefinitionRepository);
    } else {
        final DtStereotype stereotype = parseStereotype(clazz);
        parseDtDefinition(clazz, stereotype, dtDefinitionName, packageName, dslDefinitionRepository);
    }
}
Also used : Fragment(io.vertigo.dynamo.domain.model.Fragment) Annotation(java.lang.annotation.Annotation) DtStereotype(io.vertigo.dynamo.domain.metamodel.DtStereotype)

Example 2 with DtStereotype

use of io.vertigo.dynamo.domain.metamodel.DtStereotype in project vertigo by KleeGroup.

the class DomainDynamicRegistry method createDtDefinition.

/**
 * @param xdtDefinition Définition de DT
 */
private DtDefinition createDtDefinition(final DefinitionSpace definitionSpace, final DslDefinition xdtDefinition) {
    // Déclaration de la définition
    final String sortFieldName = (String) xdtDefinition.getPropertyValue(KspProperty.SORT_FIELD);
    final String displayFieldName = (String) xdtDefinition.getPropertyValue(KspProperty.DISPLAY_FIELD);
    // -----
    final String tmpStereotype = (String) xdtDefinition.getPropertyValue(KspProperty.STEREOTYPE);
    // Si Stereotype est non renseigné on suppose que la définition est DtStereotype.Data.
    final DtStereotype stereotype = tmpStereotype != null ? DtStereotype.valueOf(tmpStereotype) : null;
    // -----
    final String dataSpace = (String) xdtDefinition.getPropertyValue(KspProperty.DATA_SPACE);
    // -----
    final String fragmentOf = (String) xdtDefinition.getPropertyValue(KspProperty.FRAGMENT_OF);
    // -----
    // -----
    final String dtDefinitionName = xdtDefinition.getName();
    final DtDefinitionBuilder dtDefinitionBuilder = DtDefinition.builder(dtDefinitionName).withPackageName(xdtDefinition.getPackageName()).withDataSpace(dataSpace).withSortField(sortFieldName).withDisplayField(displayFieldName);
    if (stereotype != null) {
        dtDefinitionBuilder.withStereoType(stereotype);
    }
    if (!StringUtil.isEmpty(fragmentOf)) {
        dtDefinitionBuilder.withFragment(definitionSpace.resolve(fragmentOf, DtDefinition.class));
    }
    // On enregistre les Builder pour pouvoir les mettre à jour sur les associations.
    Assertion.checkArgument(!dtDefinitionBuilders.containsKey(dtDefinitionName), "Definition '{0}' already registered", dtDefinitionName);
    dtDefinitionBuilders.put(dtDefinitionName, dtDefinitionBuilder);
    // Déclaration de la clé primaire
    final List<DslDefinition> keys = xdtDefinition.getChildDefinitions(DomainGrammar.ID);
    populateIdDtField(definitionSpace, dtDefinitionBuilder, keys);
    // Déclaration des champs du DT
    final List<DslDefinition> fields = xdtDefinition.getChildDefinitions(DomainGrammar.FIELD);
    populateDataDtField(definitionSpace, dtDefinitionBuilder, fields);
    // Déclaration des champs calculés
    final List<DslDefinition> computedFields = xdtDefinition.getChildDefinitions(DomainGrammar.COMPUTED);
    populateComputedDtField(definitionSpace, dtDefinitionBuilder, computedFields);
    return dtDefinitionBuilder.build();
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) DtDefinitionBuilder(io.vertigo.dynamo.domain.metamodel.DtDefinitionBuilder) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtStereotype(io.vertigo.dynamo.domain.metamodel.DtStereotype)

Aggregations

DtStereotype (io.vertigo.dynamo.domain.metamodel.DtStereotype)2 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)1 DtDefinitionBuilder (io.vertigo.dynamo.domain.metamodel.DtDefinitionBuilder)1 Fragment (io.vertigo.dynamo.domain.model.Fragment)1 DslDefinition (io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition)1 Annotation (java.lang.annotation.Annotation)1