Search in sources :

Example 1 with ComponentModifiers

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));
}
Also used : ComponentModifiers(org.whole.lang.models.model.ComponentModifiers) ComponentModifier(org.whole.lang.models.model.ComponentModifier) ModelsEntityFactory(org.whole.lang.models.factories.ModelsEntityFactory) Test(org.junit.Test)

Example 2 with ComponentModifiers

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));
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AbstractBagCompositeEntity(org.whole.lang.model.AbstractBagCompositeEntity) AbstractCollectionEntityAdapter(org.whole.lang.model.adapters.AbstractCollectionEntityAdapter) AbstractSetCompositeEntity(org.whole.lang.model.AbstractSetCompositeEntity) AbstractSetEntityAdapter(org.whole.lang.model.adapters.AbstractSetEntityAdapter) ComponentModifiers(org.whole.lang.models.model.ComponentModifiers) AbstractListEntityAdapter(org.whole.lang.model.adapters.AbstractListEntityAdapter) AbstractCollectionCompositeEntity(org.whole.lang.model.AbstractCollectionCompositeEntity) Collection(java.util.Collection) List(java.util.List) ArrayList(java.util.ArrayList) AbstractListCompositeEntity(org.whole.lang.model.AbstractListCompositeEntity) AbstractUniqueListCompositeEntity(org.whole.lang.model.AbstractUniqueListCompositeEntity)

Example 3 with ComponentModifiers

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));
}
Also used : ComponentModifiers(org.whole.lang.models.model.ComponentModifiers) ComponentModifier(org.whole.lang.models.model.ComponentModifier) ModelsEntityFactory(org.whole.lang.models.factories.ModelsEntityFactory) Test(org.junit.Test)

Aggregations

ComponentModifiers (org.whole.lang.models.model.ComponentModifiers)3 Test (org.junit.Test)2 ModelsEntityFactory (org.whole.lang.models.factories.ModelsEntityFactory)2 ComponentModifier (org.whole.lang.models.model.ComponentModifier)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 AbstractBagCompositeEntity (org.whole.lang.model.AbstractBagCompositeEntity)1 AbstractCollectionCompositeEntity (org.whole.lang.model.AbstractCollectionCompositeEntity)1 AbstractListCompositeEntity (org.whole.lang.model.AbstractListCompositeEntity)1 AbstractSetCompositeEntity (org.whole.lang.model.AbstractSetCompositeEntity)1 AbstractUniqueListCompositeEntity (org.whole.lang.model.AbstractUniqueListCompositeEntity)1 AbstractCollectionEntityAdapter (org.whole.lang.model.adapters.AbstractCollectionEntityAdapter)1 AbstractListEntityAdapter (org.whole.lang.model.adapters.AbstractListEntityAdapter)1 AbstractSetEntityAdapter (org.whole.lang.model.adapters.AbstractSetEntityAdapter)1