use of org.whole.lang.models.model.ComponentModifiers in project whole by wholeplatform.
the class ByChildAPITest method testAbstractSetCompositeEntity.
@Test
public void testAbstractSetCompositeEntity() {
ModelsEntityFactory mf = ModelsEntityFactory.instance(RegistryConfigurations.STRICT);
ComponentModifier o = mf.createComponentModifier(ComponentModifierEnum.ordered);
ComponentModifier r = mf.createComponentModifier(ComponentModifierEnum.reference);
ComponentModifier s = mf.createComponentModifier(ComponentModifierEnum.derived);
ComponentModifier[] modifiersArray = new ComponentModifier[] { o, r, s };
ComponentModifiers modifiers = mf.createComponentModifiers(modifiersArray);
unorderedCompositeOperationsEntityTest(modifiersArray, modifiers);
commonOperationsEntityTest(modifiersArray, modifiersArray, modifiers);
uniqueOperationsEntityTest(modifiersArray, modifiers);
propertyChangeEntityTest(modifiersArray, modifiers, mf.createComponentModifier(ComponentModifierEnum.unique));
}
use of org.whole.lang.models.model.ComponentModifiers in project whole by wholeplatform.
the class ModelsJavaModelGeneratorVisitor method visit.
public void visit(CompositeEntity entity) {
entityModifiers.clear();
isConcrete = true;
entity.getModifiers().accept(this);
metaName = entity.getName().wStringValue();
// was entity.getName().wStringValue();
entityName = modelInfo.entityImplName(metaName);
qEntityName = modelsGen.entityInterfaceQName(entityName);
String specificComponentType = entity.getComponentType().wStringValue();
String componentType = specificComponentType;
String componentQType = modelsGen.entityInterfaceQName(componentType);
// if (singleFeature.getCardinality().isOptional())
modelsGen.putOptionalEntity(componentType);
String compositeType, javaCompositeType, abstractAdapterType;
ComponentModifiers modifiers = entity.getComponentModifiers();
compositeModifiers.clear();
modifiers.accept(this);
modelsGen.putComposite(entityName, componentType);
simpleEntityBuilder = null;
boolean isByReference = modifiers.wContainsValue(ComponentModifierEnum.reference);
boolean isUnique = modifiers.wContainsValue(ComponentModifierEnum.unique);
boolean isOrdered = modifiers.wContainsValue(ComponentModifierEnum.ordered);
boolean hasStrict = isUnique || !isOrdered;
if (hasStrict) {
if (isUnique) {
if (isOrdered) {
compositeType = AbstractUniqueListCompositeEntity.class.getName();
javaCompositeType = List.class.getName();
abstractAdapterType = AbstractListEntityAdapter.class.getName();
} else {
compositeType = AbstractSetCompositeEntity.class.getName();
javaCompositeType = Set.class.getName();
abstractAdapterType = AbstractSetEntityAdapter.class.getName();
}
} else {
compositeType = AbstractBagCompositeEntity.class.getName();
javaCompositeType = Collection.class.getName();
abstractAdapterType = AbstractCollectionEntityAdapter.class.getName();
}
modelsGen.compositeEntityBuilder(entityName, componentType, compositeType, isByReference, true);
compositeType = AbstractCollectionCompositeEntity.class.getName();
} else {
compositeType = AbstractListCompositeEntity.class.getName();
javaCompositeType = List.class.getName();
abstractAdapterType = AbstractListEntityAdapter.class.getName();
}
modelsGen.compositeEntityBuilder(entityName, componentType, compositeType, isByReference, false);
anyEntityBuilder = modelsGen.compositeEntityInterfaceBuilder(entityName, componentType, javaCompositeType);
entityAdapterBuilder = modelsGen.compositeEntityAdapterBuilder(entityName, abstractAdapterType, componentType);
modelsGen.adapterRegistryBuilder().addFactoryProduct(entityName);
modelsGen.implRegistryBuilder().addFactoryProduct(entityName);
if (hasStrict)
modelsGen.strictImplRegistryBuilder().addFactoryProduct(entityName);
entity.getTypes().accept(this);
modelsGen.visitorsBuilder().addCompositeEntity(entityName, componentType, isOrdered, isByReference);
if (hasUI)
modelsGen.partFactoryVisitorBuilder().addPartFactoryVisitMethod(entityName, CompositeColumnPartName);
modelsGen.entityFactoryBuilder().addFactoryMethodWithVarArgsCase(entityName, componentQType, "entities");
modelsGen.entityDescriptorEnumBuilder().addCompositeEntity(entityName, metaName, qEntityName, entityModifiers, specificComponentType, compositeModifiers);
// modelsGen.entityDescriptorEnumBuilder().addSupertypes(qEntityName, metaName, modelInfo.allSuperTypes(metaName));
}
use of org.whole.lang.models.model.ComponentModifiers in project whole by wholeplatform.
the class ByChildAPITest method testAbstractListEntity.
@Test
public void testAbstractListEntity() {
ModelsEntityFactory mf = ModelsEntityFactory.instance;
ComponentModifier o = mf.createComponentModifier(ComponentModifierEnum.ordered);
ComponentModifier r1 = mf.createComponentModifier(ComponentModifierEnum.reference);
ComponentModifier r2 = mf.createComponentModifier(ComponentModifierEnum.reference);
ComponentModifier s = mf.createComponentModifier(ComponentModifierEnum.derived);
ComponentModifier[] modifiersArray = new ComponentModifier[] { o, r1, r2, s };
int[] businessEquivalence = new int[] { 0, 1, 1, 3 };
ComponentModifiers modifiers = mf.createComponentModifiers(modifiersArray);
orderedCompositeOperationsEntityTest(modifiersArray, businessEquivalence, modifiers);
commonOperationsEntityTest(modifiersArray, modifiersArray, modifiers);
propertyChangeEntityTest(modifiersArray, modifiers, mf.createComponentModifier(ComponentModifierEnum.reference));
}
Aggregations