use of io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionBody in project vertigo by KleeGroup.
the class DslInnerDefinitionRule method handle.
@Override
protected DslDefinitionEntry handle(final List<Object> parsing) {
// Dans le cas des sous définition :: field [PRD_XXX]
final String definitionName = (String) parsing.get(2);
final DslDefinitionBody definitionBody = (DslDefinitionBody) parsing.get(4);
final DslDefinitionBuilder dslDefinitionBuilder = DslDefinition.builder(definitionName, entity);
populateDefinition(definitionBody, dslDefinitionBuilder);
// ---
return new DslDefinitionEntry(entityName, dslDefinitionBuilder.build());
}
use of io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionBody in project vertigo by KleeGroup.
the class DslDefinitionBodyRule method handle.
@Override
protected DslDefinitionBody handle(final List<Object> parsing) {
final List<PegChoice> many = (List<PegChoice>) parsing.get(2);
final List<DslDefinitionEntry> fieldDefinitionEntries = new ArrayList<>();
final List<DslPropertyEntry> fieldPropertyEntries = new ArrayList<>();
for (final PegChoice item : many) {
switch(item.getChoiceIndex()) {
case 0:
// Soit on est en présence d'une propriété standard
final DslPropertyEntry propertyEntry = (DslPropertyEntry) item.getValue();
fieldPropertyEntries.add(propertyEntry);
break;
case 1:
final DslDefinitionEntry xDefinitionEntry = (DslDefinitionEntry) item.getValue();
fieldDefinitionEntries.add(xDefinitionEntry);
break;
case 2:
final PegChoice subTuple = (PegChoice) item.getValue();
fieldDefinitionEntries.add((DslDefinitionEntry) subTuple.getValue());
break;
case 3:
break;
default:
throw new IllegalArgumentException("Type of rule not supported");
}
}
return new DslDefinitionBody(fieldDefinitionEntries, fieldPropertyEntries);
}
use of io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionBody in project vertigo by KleeGroup.
the class DslDefinitionBodyRuleTest 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 List<DslEntity> entities = dslDefinitionRepository.getGrammar().getEntities();
final DslEntity entity = find(entities, "Domain");
final DslDefinitionBody definitionBody = new DslDefinitionBodyRule(entity).parse("{ dataType : String , formatter : FMT_DEFAULT, constraint : [ CK_CODE_POSTAL ] } ", 0).getValue();
Assert.assertNotNull(definitionBody);
}
use of io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionBody in project vertigo by KleeGroup.
the class DslDefinitionBodyRuleTest method test1.
@Test
public void test1() throws PegNoMatchFoundException {
final List<DslEntity> entities = dslDefinitionRepository.getGrammar().getEntities();
final DslEntity entity = find(entities, "Formatter");
final DslDefinitionBody definitionBody = new DslDefinitionBodyRule(entity).parse("{ args : \"UPPER\" }", 0).getValue();
Assert.assertEquals(1, definitionBody.getPropertyEntries().size());
}
Aggregations