use of org.whole.lang.models.model.SimpleName in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testChildStepByName.
@Test
public void testChildStepByName() {
Model model = new XmlModel().create();
SimpleName name = model.getName();
QueriesEntityFactory ef = QueriesEntityFactory.instance;
IEntity result = BehaviorUtils.evaluateFirstResult(ef.createFeatureStep("name"), model);
Assert.assertSame(name, result);
}
use of org.whole.lang.models.model.SimpleName in project whole by wholeplatform.
the class ModelInvariantsTest method testSetOrphanByIndexInSimpleEntity.
@Test
public void testSetOrphanByIndexInSimpleEntity() {
SimpleName oldName = model.getName();
SimpleName newName = ModelsEntityFactory.instance.createSimpleName("name");
int index = model.wIndexOf(oldName);
Assert.assertTrue(model.wContains(oldName));
Assert.assertSame(model, oldName.wGetParent());
Assert.assertTrue(EntityUtils.hasParent(oldName));
Assert.assertSame(NullEntity.instance, newName.wGetParent());
Assert.assertTrue(!EntityUtils.hasParent(newName));
model.wSet(index, newName);
Assert.assertFalse(model.wContains(oldName));
Assert.assertSame(NullEntity.instance, oldName.wGetParent());
Assert.assertTrue(!EntityUtils.hasParent(oldName));
Assert.assertSame(model, newName.wGetParent());
Assert.assertTrue(EntityUtils.hasParent(newName));
model.wSet(index, oldName);
Assert.assertSame(model, oldName.wGetParent());
Assert.assertTrue(EntityUtils.hasParent(oldName));
Assert.assertSame(NullEntity.instance, newName.wGetParent());
Assert.assertTrue(!EntityUtils.hasParent(newName));
}
use of org.whole.lang.models.model.SimpleName in project whole by wholeplatform.
the class ModelInvariantsTest method testSetOrphanByName.
@Test
public void testSetOrphanByName() {
SimpleName oldName = model.getName();
SimpleName newName = ModelsEntityFactory.instance.createSimpleName("name");
Assert.assertTrue(model.wContains(oldName));
Assert.assertSame(model, oldName.wGetParent());
Assert.assertTrue(EntityUtils.hasParent(oldName));
Assert.assertSame(NullEntity.instance, newName.wGetParent());
Assert.assertTrue(!EntityUtils.hasParent(newName));
model.setName(newName);
Assert.assertFalse(model.wContains(oldName));
Assert.assertSame(NullEntity.instance, oldName.wGetParent());
Assert.assertTrue(!EntityUtils.hasParent(oldName));
Assert.assertSame(model, newName.wGetParent());
Assert.assertTrue(EntityUtils.hasParent(newName));
model.setName(oldName);
Assert.assertSame(model, oldName.wGetParent());
Assert.assertTrue(EntityUtils.hasParent(oldName));
Assert.assertSame(NullEntity.instance, newName.wGetParent());
Assert.assertTrue(!EntityUtils.hasParent(newName));
}
use of org.whole.lang.models.model.SimpleName in project whole by wholeplatform.
the class ModelInvariantsTest method testParentedFailures.
@Test
public void testParentedFailures() {
SimpleName name = model.getName();
SimpleEntity simpleEntity = ModelsEntityFactory.instance.createSimpleEntity();
try {
simpleEntity.setName(name);
Assert.fail();
} catch (IllegalArgumentException e) {
simpleEntity.wUnset(name);
}
try {
simpleEntity.getTypes().wAdd(name);
Assert.fail();
} catch (IllegalArgumentException e) {
simpleEntity.getTypes().wRemove(name);
}
try {
simpleEntity.getTypes().wSet(0, name);
Assert.fail();
} catch (IllegalArgumentException e) {
simpleEntity.getTypes().wRemove(0);
}
try {
simpleEntity.getTypes().wAdd(0, name);
Assert.fail();
} catch (IllegalArgumentException e) {
simpleEntity.getTypes().wRemove(0);
}
}
use of org.whole.lang.models.model.SimpleName in project whole by wholeplatform.
the class ModelsJavaModelGeneratorVisitor method visit.
public void visit(Feature feature) {
String name = feature.getName().wStringValue();
// was StringUtils.javaKeywordFilter(name);
String fName = modelInfo.featureImplName(name);
String type = feature.getType().wStringValue();
String fType = modelInfo.entityImplName(type);
String fQType = modelsGen.entityInterfaceQName(fType);
String oName = null;
String ofName = null;
SimpleName oppositeName = feature.getOppositeName();
if (DataTypeUtils.getDataKind(oppositeName).isString()) {
oName = oppositeName.getValue();
// was StringUtils.javaKeywordFilter(oName);
ofName = modelInfo.featureImplName(oName);
}
FeatureModifiers mods = feature.getModifiers();
featureModifiers.clear();
mods.accept(this);
boolean isByReference = mods.wContainsValue(FeatureModifierEnum.reference);
if (isConcrete)
simpleEntityBuilder.addField(fType, fName, name, mods.wContainsValue(FeatureModifierEnum.id), mods.wContainsValue(FeatureModifierEnum.optional), isByReference, mods.wContainsValue(FeatureModifierEnum.shared), mods.wContainsValue(FeatureModifierEnum.derived));
if (modelInfo.isNotInherited(metaName, name))
simpleEntityInterfaceBuilder.addField(fType, fName, name);
modelsGen.modelContextBuilder().addFeature(fType, fName);
modelsGen.visitorsBuilder().addFeature(entityName, fType, fName, name, isByReference);
modelsGen.entityDescriptorEnumBuilder().addFeature(qEntityName, fType, fName, ofName, featureModifiers);
modelsGen.featureDescriptorEnumBuilder().addFeature(fType, fName, name);
if (oName != null)
modelsGen.featureDescriptorEnumBuilder().addFeature(entityName, ofName, oName);
if (isConcrete)
modelsGen.entityFactoryBuilder().addFactoryMethodCase(fQType, fName);
entityAdapterBuilder.addFeature(fType, fName, name);
}
Aggregations