Search in sources :

Example 16 with DslDefinition

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

the class AnnotationLoader method parseAssociationDefinition.

private static void parseAssociationDefinition(final DslDefinitionRepository dynamicModelRepository, final Annotation annotation, final String packageName) {
    if (annotation instanceof io.vertigo.dynamo.domain.stereotype.Association) {
        final io.vertigo.dynamo.domain.stereotype.Association association = (io.vertigo.dynamo.domain.stereotype.Association) annotation;
        // ============================================================
        // Attention pamc inverse dans oom les déclarations des objets !!
        final DslDefinition associationDefinition = DslDefinition.builder(association.name(), DomainGrammar.ASSOCIATION_ENTITY).withPackageName(packageName).addPropertyValue(MULTIPLICITY_A, association.primaryMultiplicity()).addPropertyValue(MULTIPLICITY_B, association.foreignMultiplicity()).addPropertyValue(NAVIGABILITY_A, association.primaryIsNavigable()).addPropertyValue(NAVIGABILITY_B, association.foreignIsNavigable()).addPropertyValue(ROLE_A, association.primaryRole()).addPropertyValue(LABEL_A, association.primaryLabel()).addPropertyValue(ROLE_B, association.foreignRole()).addPropertyValue(LABEL_B, association.foreignRole()).addDefinitionLink("dtDefinitionA", association.primaryDtDefinitionName()).addDefinitionLink("dtDefinitionB", association.foreignDtDefinitionName()).addPropertyValue(FK_FIELD_NAME, association.fkFieldName()).build();
        if (!dynamicModelRepository.containsDefinitionName(associationDefinition.getName())) {
            // Les associations peuvent être déclarées sur les deux noeuds de l'association.
            dynamicModelRepository.addDefinition(associationDefinition);
        }
    } else if (annotation instanceof io.vertigo.dynamo.domain.stereotype.AssociationNN) {
        final io.vertigo.dynamo.domain.stereotype.AssociationNN association = (io.vertigo.dynamo.domain.stereotype.AssociationNN) annotation;
        // ============================================================
        // Attention pamc inverse dans oom les déclarations des objets !!
        final DslDefinition associationDefinition = DslDefinition.builder(association.name(), DomainGrammar.ASSOCIATION_NN_ENTITY).withPackageName(packageName).addPropertyValue(TABLE_NAME, association.tableName()).addPropertyValue(NAVIGABILITY_A, association.navigabilityA()).addPropertyValue(NAVIGABILITY_B, association.navigabilityB()).addPropertyValue(ROLE_A, association.roleA()).addPropertyValue(LABEL_A, association.labelA()).addPropertyValue(ROLE_B, association.roleB()).addPropertyValue(LABEL_B, association.labelB()).addDefinitionLink("dtDefinitionA", association.dtDefinitionA()).addDefinitionLink("dtDefinitionB", association.dtDefinitionB()).build();
        if (!dynamicModelRepository.containsDefinitionName(associationDefinition.getName())) {
            // Les associations peuvent être déclarées sur les deux noeuds de l'association.
            dynamicModelRepository.addDefinition(associationDefinition);
        }
    }
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition)

Example 17 with DslDefinition

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

the class AnnotationLoader method parseAnnotation.

/*
	 * Centralisation du parsing des annotations liées à un champ.
	 */
private static void parseAnnotation(final String fieldName, final DslDefinitionBuilder dtDefinition, final io.vertigo.dynamo.domain.stereotype.Field field) {
    // Si on trouve un domaine on est dans un objet dynamo.
    final FieldType type = FieldType.valueOf(field.type());
    final DslDefinition dtField = DslDefinition.builder(fieldName, DomainGrammar.DT_FIELD_ENTITY).addDefinitionLink("domain", field.domain()).addPropertyValue(LABEL, field.label()).addPropertyValue(NOT_NULL, field.required()).addPropertyValue(PERSISTENT, field.persistent()).build();
    switch(type) {
        case ID:
            dtDefinition.addChildDefinition(DomainGrammar.ID, dtField);
            break;
        case DATA:
            dtDefinition.addChildDefinition("field", dtField);
            break;
        case COMPUTED:
            // Valeurs renseignées automatiquement parce que l'on est dans le cas d'un champ calculé
            dtDefinition.addChildDefinition("computed", dtField);
            break;
        case FOREIGN_KEY:
            // on ne fait rien puisque le champ est défini par une association.
            break;
        default:
            throw new IllegalArgumentException("case " + type + " not implemented");
    }
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) FieldType(io.vertigo.dynamo.domain.metamodel.DtField.FieldType)

Example 18 with DslDefinition

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

the class AbstractXmlLoader method toDynamicDefinition.

private static DslDefinition toDynamicDefinition(final XmlClass clazz) {
    final DslEntity dtDefinitionEntity = DomainGrammar.DT_DEFINITION_ENTITY;
    final DslDefinitionBuilder dtDefinitionBuilder = DslDefinition.builder(getDtDefinitionName(clazz.getCode()), dtDefinitionEntity).withPackageName(clazz.getPackageName()).addPropertyValue(KspProperty.STEREOTYPE, clazz.getStereotype());
    for (final XmlAttribute attribute : clazz.getKeyAttributes()) {
        final DslDefinition dtField = toDynamicDefinition(attribute);
        dtDefinitionBuilder.addChildDefinition(DomainGrammar.ID, dtField);
    }
    for (final XmlAttribute tagAttribute : clazz.getFieldAttributes()) {
        final DslDefinition dtField = toDynamicDefinition(tagAttribute);
        dtDefinitionBuilder.addChildDefinition(DomainGrammar.FIELD, dtField);
    }
    return dtDefinitionBuilder.build();
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) DslEntity(io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntity) DslDefinitionBuilder(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinitionBuilder)

Example 19 with DslDefinition

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

the class SearchDynamicRegistry method createFacetDefinition.

private static FacetDefinition createFacetDefinition(final DefinitionSpace definitionSpace, final DslDefinition xdefinition) {
    final String definitionName = xdefinition.getName();
    final DtDefinition indexDtDefinition = definitionSpace.resolve(xdefinition.getDefinitionLinkName("dtDefinition"), DtDefinition.class);
    final String dtFieldName = (String) xdefinition.getPropertyValue(SearchGrammar.FIELD_NAME);
    final DtField dtField = indexDtDefinition.getField(dtFieldName);
    final String label = (String) xdefinition.getPropertyValue(KspProperty.LABEL);
    // Déclaration des ranges
    final List<DslDefinition> rangeDefinitions = xdefinition.getChildDefinitions("range");
    final MessageText labelMsg = MessageText.of(label);
    final FacetDefinition facetDefinition;
    if (rangeDefinitions.isEmpty()) {
        facetDefinition = FacetDefinition.createFacetDefinitionByTerm(definitionName, dtField, labelMsg, isMultiSelectable(xdefinition, false), getFacetOrder(xdefinition, FacetOrder.count));
    } else {
        final List<FacetValue> facetValues = rangeDefinitions.stream().map(SearchDynamicRegistry::createFacetValue).collect(Collectors.toList());
        facetDefinition = FacetDefinition.createFacetDefinitionByRange(definitionName, dtField, labelMsg, facetValues, isMultiSelectable(xdefinition, false), getFacetOrder(xdefinition, FacetOrder.definition));
    }
    return facetDefinition;
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) FacetValue(io.vertigo.dynamo.collections.model.FacetValue) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) MessageText(io.vertigo.core.locale.MessageText) FacetDefinition(io.vertigo.dynamo.collections.metamodel.FacetDefinition) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 20 with DslDefinition

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

the class DslKspRule method handle.

@Override
protected Dummy handle(final List<Object> parsing) {
    final String packageName = (String) parsing.get(1);
    final List<PegChoice> declarationChoices = (List<PegChoice>) parsing.get(3);
    for (final PegChoice declarationChoice : declarationChoices) {
        // - à des gestion de droits.
        switch(declarationChoice.getChoiceIndex()) {
            case 0:
                // On positionne le Package
                final DslDefinition oldDynamicDefinition = (DslDefinition) declarationChoice.getValue();
                final DslDefinition newDynamicDefinition = DslDefinition.builder(oldDynamicDefinition.getName(), oldDynamicDefinition.getEntity()).withPackageName(packageName).merge(oldDynamicDefinition).build();
                handleDefinitionRule(newDynamicDefinition);
                break;
            case 1:
                handleTemplateRule((DslDefinition) declarationChoice.getValue());
                break;
            default:
                throw new IllegalArgumentException("case " + declarationChoice.getChoiceIndex() + " not implemented");
        }
    }
    return Dummy.INSTANCE;
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) List(java.util.List) PegChoice(io.vertigo.commons.peg.PegChoice)

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