Search in sources :

Example 6 with CompositeEntity

use of org.whole.lang.models.model.CompositeEntity in project whole by wholeplatform.

the class CompositeEntityTablePart method getModelSpecificChildren.

protected List<IEntity> getModelSpecificChildren() {
    CompositeEntity entity = getModelEntity();
    List<IEntity> list = new ArrayList<IEntity>(5);
    list.add(entity.getModifiers());
    list.add(entity.getName());
    list.add(entity.getTypes());
    list.add(entity.getComponentModifiers());
    list.add(entity.getComponentType());
    return list;
}
Also used : IEntity(org.whole.lang.model.IEntity) CompositeEntity(org.whole.lang.models.model.CompositeEntity) ArrayList(java.util.ArrayList)

Example 7 with CompositeEntity

use of org.whole.lang.models.model.CompositeEntity in project whole by wholeplatform.

the class ControlQueriesTest method testChoose1.

@Test
public void testChoose1() {
    Model model = new ModelsModel().create();
    ModelDeclarations decls = model.getDeclarations();
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("choose1");
    assertFalse(BehaviorUtils.compileAndLazyEvaluate(query, model).hasNext());
    int i = 0;
    while (!Matcher.match(ModelsEntityDescriptorEnum.SimpleEntity, decls.wGet(i))) i++;
    SimpleEntity simpleEntity = (SimpleEntity) decls.wGet(i);
    int j = 0;
    for (IEntity name : BehaviorUtils.compileAndLazyEvaluate(query, simpleEntity)) {
        assertEquals(((Feature) simpleEntity.getFeatures().wGet(j++)).getName().wStringValue(), name.wStringValue());
    }
    assertEquals(simpleEntity.getFeatures().wSize(), j);
    while (!Matcher.match(ModelsEntityDescriptorEnum.CompositeEntity, decls.wGet(i))) i++;
    CompositeEntity compositeEntity = (CompositeEntity) decls.wGet(i);
    IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, compositeEntity);
    assertTrue(iterator.hasNext());
    assertEquals(compositeEntity.getComponentType().wStringValue(), iterator.next().wStringValue());
    assertFalse(iterator.hasNext());
    while (!Matcher.match(ModelsEntityDescriptorEnum.EnumEntity, decls.wGet(i))) i++;
    EnumEntity enumEntity = (EnumEntity) decls.wGet(i);
    iterator = BehaviorUtils.compileAndLazyEvaluate(query, enumEntity);
    assertTrue(iterator.hasNext());
    assertTrue(iterator.next() instanceof EnumValues);
    assertFalse(iterator.hasNext());
}
Also used : EnumEntity(org.whole.lang.models.model.EnumEntity) IEntity(org.whole.lang.model.IEntity) SimpleEntity(org.whole.lang.models.model.SimpleEntity) ITemplateManager(org.whole.lang.templates.ITemplateManager) Feature(org.whole.lang.models.model.Feature) EnumValues(org.whole.lang.models.model.EnumValues) ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) PathExpression(org.whole.lang.queries.model.PathExpression) XmlModel(org.whole.lang.models.codebase.XmlModel) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) CompositeEntity(org.whole.lang.models.model.CompositeEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Test(org.junit.Test)

Aggregations

CompositeEntity (org.whole.lang.models.model.CompositeEntity)7 IEntity (org.whole.lang.model.IEntity)6 SimpleEntity (org.whole.lang.models.model.SimpleEntity)6 Test (org.junit.Test)5 ModelsModel (org.whole.lang.models.codebase.ModelsModel)5 XmlModel (org.whole.lang.models.codebase.XmlModel)5 DataEntity (org.whole.lang.models.model.DataEntity)5 EnumEntity (org.whole.lang.models.model.EnumEntity)5 Model (org.whole.lang.models.model.Model)5 ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)5 PathExpression (org.whole.lang.queries.model.PathExpression)5 ITemplateManager (org.whole.lang.templates.ITemplateManager)5 EnumValues (org.whole.lang.models.model.EnumValues)3 Features (org.whole.lang.models.model.Features)3 IBindingManager (org.whole.lang.bindings.IBindingManager)2 Feature (org.whole.lang.models.model.Feature)2 ArrayList (java.util.ArrayList)1 As (org.whole.lang.grammars.model.As)1 NonTerminal (org.whole.lang.grammars.model.NonTerminal)1 Repeat (org.whole.lang.grammars.model.Repeat)1