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);
}
}
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);
}
}
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);
}
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();
}
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;
}
Aggregations