use of org.whole.lang.models.model.SimpleEntity in project whole by wholeplatform.
the class ModelInfo method addInheritedFeatures.
protected void addInheritedFeatures(SimpleEntity entity, Types types, Set<String> entityTypes, Map<String, Set<String>> entityFeatures) {
ScannerIterator<IEntity> i = IteratorFactory.childReverseScannerIterator();
i.reset(types);
for (IEntity type : i) {
String typeName = type.wStringValue();
entityTypes.remove(typeName);
SimpleEntity declaration = (SimpleEntity) nameEntityMap.get(typeName);
if (declaration != null) {
ScannerIterator<Feature> i2 = IteratorFactory.<Feature>childReverseScannerIterator();
i2.reset(declaration.getFeatures());
for (Feature feature : i2) {
if (entityFeatures.get(entity.getName().wStringValue()).add(feature.getName().wStringValue()))
entity.getFeatures().wAdd(0, EntityUtils.clone(feature));
}
addInheritedFeatures(entity, declaration.getTypes(), entityTypes, entityFeatures);
}
}
}
use of org.whole.lang.models.model.SimpleEntity in project whole by wholeplatform.
the class ModelInfo method sortFeatures.
public void sortFeatures(Model model) {
for (String entityName : simpleEntityTypes) {
SimpleEntity e = (SimpleEntity) nameEntityMap.get(entityName);
Features features = e.getFeatures();
Collections.sort(features, new Comparator<Feature>() {
public int compare(Feature f1, Feature f2) {
boolean f1IsReference = f1.getModifiers().wContainsValue(FeatureModifierEnum.reference);
boolean f2IsReference = f2.getModifiers().wContainsValue(FeatureModifierEnum.reference);
if (f2IsReference)
return f1IsReference ? 0 : -1;
else
return !f1IsReference ? 0 : +1;
}
});
}
}
use of org.whole.lang.models.model.SimpleEntity in project whole by wholeplatform.
the class ModelInfo method addInheritedFeatures.
public void addInheritedFeatures(Model model) {
for (String entityName : simpleEntityTypes) {
SimpleEntity e = (SimpleEntity) nameEntityMap.get(entityName);
addInheritedFeatures(e, e.getTypes(), new HashSet<String>(simpleEntityTypes), simpleEntityFeatures);
}
}
use of org.whole.lang.models.model.SimpleEntity in project whole by wholeplatform.
the class ControlQueriesTest method testChoose4.
@Test
public void testChoose4() {
Model model = new ModelsModel().create();
ModelDeclarations decls = model.getDeclarations();
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("choose4");
int i = 0;
IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, model, bm);
while (iterator.hasNext()) {
IEntity result = iterator.next();
assertSame(result, bm.wGet("type"));
assertTrue(result instanceof ClassDeclaration);
ClassDeclaration classDecl = (ClassDeclaration) result;
IEntity decl = decls.wGet(i++);
String name = "", superClassName = "";
switch(decl.wGetEntityOrd()) {
case ModelsEntityDescriptorEnum.SimpleEntity_ord:
SimpleEntity simpleEntity = (SimpleEntity) decl;
name = simpleEntity.getName().wStringValue();
superClassName = "AbstractSimpleEntity";
break;
case ModelsEntityDescriptorEnum.CompositeEntity_ord:
CompositeEntity compositeEntity = (CompositeEntity) decl;
name = compositeEntity.getName().wStringValue();
superClassName = "AbstractCompositeEntity";
break;
case ModelsEntityDescriptorEnum.DataEntity_ord:
DataEntity dataEntity = (DataEntity) decl;
name = dataEntity.getName().wStringValue();
superClassName = "AbstractDataEntity";
break;
case ModelsEntityDescriptorEnum.EnumEntity_ord:
EnumEntity enumEntity = (EnumEntity) decl;
name = enumEntity.getName().wStringValue();
superClassName = "AbstractEnumEntity";
break;
}
assertEquals(name, classDecl.getName().wStringValue());
assertEquals(superClassName, classDecl.getSuperclassType().wStringValue());
}
}
use of org.whole.lang.models.model.SimpleEntity in project whole by wholeplatform.
the class ControlQueriesTest method testFor1.
@Test
public void testFor1() {
Model model = new XmlModel().create();
ModelDeclarations decls = model.getDeclarations();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("for1");
int i = 0;
for (IEntity name : BehaviorUtils.compileAndLazyEvaluate(query, model)) {
while (!Matcher.match(ModelsEntityDescriptorEnum.SimpleEntity, decls.wGet(i))) i++;
assertEquals(((SimpleEntity) decls.wGet(i++)).getName().wStringValue(), name.wStringValue());
}
assertTrue(i > 0);
}
Aggregations