Search in sources :

Example 6 with Domain

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

the class DomainDynamicRegistry method populateDataDtField.

/**
 * Ajoute une liste de champs d'un certain type à la dtDefinition
 *
 * @param fields List
 */
private static void populateDataDtField(final DefinitionSpace definitionSpace, final DtDefinitionBuilder dtDefinitionBuilder, final List<DslDefinition> fields) {
    for (final DslDefinition field : fields) {
        final Domain domain = definitionSpace.resolve(field.getDefinitionLinkName("domain"), Domain.class);
        // --
        Assertion.checkArgument(field.getPropertyNames().contains(KspProperty.LABEL), "Label est une propriété obligatoire");
        final String label = (String) field.getPropertyValue(KspProperty.LABEL);
        // --
        final boolean notNull = (Boolean) field.getPropertyValue(KspProperty.NOT_NULL);
        Assertion.checkArgument(field.getPropertyNames().contains(KspProperty.NOT_NULL), "Not null est une propriété obligatoire.");
        // --
        final Boolean tmpPersistent = (Boolean) field.getPropertyValue(KspProperty.PERSISTENT);
        // Si PERSISTENT est non renseigné on suppose que le champ est à priori persistant .
        final boolean persistent = tmpPersistent == null || tmpPersistent;
        // --
        final String fieldName = field.getName();
        // -----
        dtDefinitionBuilder.addDataField(fieldName, label, domain, notNull, persistent);
    }
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 7 with Domain

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

the class DomainDynamicRegistry method populateComputedDtField.

/**
 * Ajoute une liste de champs d'un certain type à la dtDefinition
 *
 * @param fields List
 */
private static void populateComputedDtField(final DefinitionSpace definitionSpace, final DtDefinitionBuilder dtDefinitionBuilder, final List<DslDefinition> fields) {
    for (final DslDefinition field : fields) {
        final Domain domain = definitionSpace.resolve(field.getDefinitionLinkName("domain"), Domain.class);
        // --
        Assertion.checkArgument(field.getPropertyNames().contains(KspProperty.LABEL), "Label est une propriété obligatoire");
        final String label = (String) field.getPropertyValue(KspProperty.LABEL);
        // ---
        final String expression = (String) field.getPropertyValue(KspProperty.EXPRESSION);
        final ComputedExpression computedExpression = new ComputedExpression(expression);
        // --
        final String fieldName = field.getName();
        dtDefinitionBuilder.addComputedField(fieldName, label, domain, computedExpression);
    }
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) ComputedExpression(io.vertigo.dynamo.domain.metamodel.ComputedExpression) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 8 with Domain

use of io.vertigo.dynamo.domain.metamodel.Domain 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 9 with Domain

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

the class TaskDynamicRegistry method createTaskDefinition.

private static TaskDefinition createTaskDefinition(final DslDefinition xtaskDefinition) {
    final String taskDefinitionName = xtaskDefinition.getName();
    final String request = (String) xtaskDefinition.getPropertyValue(KspProperty.REQUEST);
    Assertion.checkNotNull(taskDefinitionName);
    final Class<? extends TaskEngine> taskEngineClass = getTaskEngineClass(xtaskDefinition);
    final String dataSpace = (String) xtaskDefinition.getPropertyValue(KspProperty.DATA_SPACE);
    final TaskDefinitionBuilder taskDefinitionBuilder = TaskDefinition.builder(taskDefinitionName).withEngine(taskEngineClass).withDataSpace(dataSpace).withRequest(request).withPackageName(xtaskDefinition.getPackageName());
    for (final DslDefinition xtaskAttribute : xtaskDefinition.getChildDefinitions(TaskGrammar.TASK_ATTRIBUTE)) {
        final String attributeName = xtaskAttribute.getName();
        Assertion.checkNotNull(attributeName);
        final String domainName = xtaskAttribute.getDefinitionLinkName("domain");
        final Domain domain = Home.getApp().getDefinitionSpace().resolve(domainName, Domain.class);
        // -----
        final boolean required = (Boolean) xtaskAttribute.getPropertyValue(KspProperty.NOT_NULL);
        if (isInValue((String) xtaskAttribute.getPropertyValue(KspProperty.IN_OUT))) {
            if (required) {
                taskDefinitionBuilder.addInRequired(attributeName, domain);
            } else {
                taskDefinitionBuilder.addInOptional(attributeName, domain);
            }
        } else {
            if (required) {
                taskDefinitionBuilder.withOutRequired(attributeName, domain);
            } else {
                taskDefinitionBuilder.withOutOptional(attributeName, domain);
            }
        }
    }
    return taskDefinitionBuilder.build();
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) TaskDefinitionBuilder(io.vertigo.dynamo.task.metamodel.TaskDefinitionBuilder) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 10 with Domain

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

the class VegaUiObject method getInputValue.

/**
 * {@inheritDoc}
 */
@Override
public String getInputValue(final String fieldName) {
    Assertion.checkArgNotEmpty(fieldName);
    Assertion.checkArgument(Character.isLowerCase(fieldName.charAt(0)) && !fieldName.contains("_"), "Le nom du champs doit-être en camelCase ({0}).", fieldName);
    // -----
    if (hasFormatError(fieldName)) {
        return inputBuffer.get(fieldName);
    }
    final Object value = doGetTypedValue(fieldName);
    final Domain domain = getDtField(fieldName).getDomain();
    if (domain.getScope().isPrimitive() && !domain.isMultiple()) {
        return domain.valueToString(value);
    }
    // only non multiple primitives are supported (from user input)
    return null;
}
Also used : DtObject(io.vertigo.dynamo.domain.model.DtObject) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Aggregations

Domain (io.vertigo.dynamo.domain.metamodel.Domain)26 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)8 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)7 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)7 Task (io.vertigo.dynamo.task.model.Task)7 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)7 Test (org.junit.Test)6 DslDefinition (io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition)5 ArrayList (java.util.ArrayList)4 AutoCloseableApp (io.vertigo.app.AutoCloseableApp)3 AppConfig (io.vertigo.app.config.AppConfig)3 DtList (io.vertigo.dynamo.domain.model.DtList)3 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)3 FormatterDefault (io.vertigo.dynamox.domain.formatter.FormatterDefault)3 Assertion (io.vertigo.lang.Assertion)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Home (io.vertigo.app.Home)2 VTransactionManager (io.vertigo.commons.transaction.VTransactionManager)2 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)2