Search in sources :

Example 1 with LogicalType

use of nl.tue.buildingsmart.schema.LogicalType in project BIMserver by opensourceBIM.

the class Express2EMF method x.

private EAttribute x(DefinedType type, EClass testType) {
    EAttribute wrapperAttrib = eFactory.createEAttribute();
    wrapperAttrib.setName("wrappedValue");
    if (type.getDomain() instanceof IntegerType) {
        wrapperAttrib.setEType(ePackage.getELong());
    } else if (type.getDomain() instanceof RealType) {
        wrapperAttrib.setEType(ePackage.getEDouble());
    } else if (type.getDomain() instanceof StringType) {
        wrapperAttrib.setEType(ePackage.getEString());
    } else if (type.getDomain() instanceof BooleanType) {
        wrapperAttrib.setEType(schemaPack.getEClassifier("Tristate"));
    } else if (type.getDomain() instanceof NumberType) {
        wrapperAttrib.setEType(ePackage.getEDouble());
    } else if (type.getDomain() instanceof BinaryType) {
        wrapperAttrib.setEType(ePackage.getEByteArray());
    } else if (type.getDomain() instanceof LogicalType) {
        wrapperAttrib.setEType(schemaPack.getEClassifier("Tristate"));
    }
    wrapperAttrib.setUnsettable(true);
    testType.getEStructuralFeatures().add(wrapperAttrib);
    if (wrapperAttrib.getEType() == ePackage.getEDouble()) {
        EAttribute doubleStringAttribute = eFactory.createEAttribute();
        doubleStringAttribute.setEType(ePackage.getEString());
        doubleStringAttribute.setName("wrappedValueAsString");
        doubleStringAttribute.getEAnnotations().add(createAsStringAnnotation());
        doubleStringAttribute.getEAnnotations().add(createHiddenAnnotation());
        doubleStringAttribute.setUnsettable(true);
        testType.getEStructuralFeatures().add(doubleStringAttribute);
    }
    return wrapperAttrib;
}
Also used : IntegerType(nl.tue.buildingsmart.schema.IntegerType) EAttribute(org.eclipse.emf.ecore.EAttribute) NumberType(nl.tue.buildingsmart.schema.NumberType) BinaryType(nl.tue.buildingsmart.schema.BinaryType) StringType(nl.tue.buildingsmart.schema.StringType) BooleanType(nl.tue.buildingsmart.schema.BooleanType) LogicalType(nl.tue.buildingsmart.schema.LogicalType) RealType(nl.tue.buildingsmart.schema.RealType)

Example 2 with LogicalType

use of nl.tue.buildingsmart.schema.LogicalType in project BIMserver by opensourceBIM.

the class Express2EMF method addSelects.

private void addSelects() {
    Iterator<DefinedType> typeIter = schema.getTypes().iterator();
    while (typeIter.hasNext()) {
        DefinedType type = typeIter.next();
        if (type instanceof SelectType) {
            EClass selectType = getOrCreateEClass(type.getName());
            selectType.setInterface(true);
            selectType.setAbstract(true);
            Iterator<NamedType> entIter = ((SelectType) type).getSelections().iterator();
            while (entIter.hasNext()) {
                NamedType nt = entIter.next();
                if (nt instanceof EntityDefinition) {
                    EClass choice = getOrCreateEClass(nt.getName());
                    choice.getESuperTypes().add(selectType);
                } else if (nt instanceof DefinedType) {
                    UnderlyingType domain = ((DefinedType) nt).getDomain();
                    if (domain instanceof RealType || domain instanceof StringType || domain instanceof IntegerType || domain instanceof NumberType || domain instanceof LogicalType) {
                        EClass choice = getOrCreateEClass(nt.getName());
                        choice.getESuperTypes().add(selectType);
                    } else if (domain instanceof DefinedType) {
                        DefinedType dt2 = (DefinedType) (domain);
                        if (dt2.getDomain() instanceof RealType) {
                            EClass choice = getOrCreateEClass(nt.getName());
                            choice.getESuperTypes().add(selectType);
                        }
                    } else if (nt instanceof SelectType) {
                    } else {
                        if (nt.getName().equals("IfcComplexNumber") || nt.getName().equals("IfcCompoundPlaneAngleMeasure") || nt.getName().equals("IfcBoolean") || nt.getName().equals("IfcNullStyle")) {
                            EClass choice = getOrCreateEClass(nt.getName());
                            choice.getESuperTypes().add(selectType);
                        } else {
                            System.out.println("The domain is null for " + selectType.getName() + " " + nt.getName());
                        }
                    }
                }
            }
        }
    }
    typeIter = schema.getTypes().iterator();
    while (typeIter.hasNext()) {
        DefinedType type = typeIter.next();
        if (type instanceof SelectType) {
            EClass selectType = (EClass) schemaPack.getEClassifier(type.getName());
            Iterator<NamedType> entIter = ((SelectType) type).getSelections().iterator();
            while (entIter.hasNext()) {
                NamedType nt = entIter.next();
                if (nt instanceof SelectType) {
                    EClass choice = getOrCreateEClass(nt.getName());
                    choice.getESuperTypes().add(selectType);
                }
            }
        }
    }
}
Also used : StringType(nl.tue.buildingsmart.schema.StringType) NamedType(nl.tue.buildingsmart.schema.NamedType) SelectType(nl.tue.buildingsmart.schema.SelectType) LogicalType(nl.tue.buildingsmart.schema.LogicalType) DefinedType(nl.tue.buildingsmart.schema.DefinedType) RealType(nl.tue.buildingsmart.schema.RealType) IntegerType(nl.tue.buildingsmart.schema.IntegerType) EntityDefinition(nl.tue.buildingsmart.schema.EntityDefinition) EClass(org.eclipse.emf.ecore.EClass) NumberType(nl.tue.buildingsmart.schema.NumberType) UnderlyingType(nl.tue.buildingsmart.schema.UnderlyingType)

Example 3 with LogicalType

use of nl.tue.buildingsmart.schema.LogicalType in project BIMserver by opensourceBIM.

the class Express2EMF method processAttribute.

private void processAttribute(EntityDefinition ent, Attribute attrib) {
    if (attrib.getName().equals("RasterCode")) {
        System.out.println();
    }
    ExplicitAttribute expAttrib = (ExplicitAttribute) attrib;
    BaseType domain = expAttrib.getDomain();
    if (ent.getName().equals("IfcRelConnectsPathElements") && (attrib.getName().equals("RelatingPriorities") || attrib.getName().equals("RelatedPriorities"))) {
        // HACK, express parser does not recognize LIST [0:?] OF NUMBER
        EClass cls = (EClass) schemaPack.getEClassifier(ent.getName());
        EAttribute eAttribute = eFactory.createEAttribute();
        eAttribute.setName(attrib.getName());
        eAttribute.setUpperBound(-1);
        eAttribute.setUnique(false);
        eAttribute.setEType(EcorePackage.eINSTANCE.getELong());
        eAttribute.setUnsettable(expAttrib.isOptional());
        cls.getEStructuralFeatures().add(eAttribute);
        return;
    }
    if (domain instanceof NamedType) {
        NamedType nt = (NamedType) domain;
        if (nt instanceof EnumerationType) {
            EAttribute enumAttrib = eFactory.createEAttribute();
            enumAttrib.setUnsettable(expAttrib.isOptional());
            enumAttrib.setName(attrib.getName());
            EClassifier eType = schemaPack.getEClassifier(nt.getName());
            enumAttrib.setEType(eType);
            EClass cls = (EClass) schemaPack.getEClassifier(ent.getName());
            cls.getEStructuralFeatures().add(enumAttrib);
        } else {
            EClass eType = (EClass) schemaPack.getEClassifier(nt.getName());
            EClass cls = (EClass) schemaPack.getEClassifier(ent.getName());
            // If the DEFINED type is already a wrapped value, we prefer not to use wrappedValue indirection
            boolean wrapped = superTypeIsWrapped(eType);
            if (wrapped) {
                EAttribute eAttribute = eFactory.createEAttribute();
                eAttribute.setUnsettable(expAttrib.isOptional());
                eAttribute.setName(attrib.getName());
                if (eAttribute.getName().equals("RefLatitude") || eAttribute.getName().equals("RefLongitude")) {
                    eAttribute.setUpperBound(3);
                    eAttribute.setUnique(false);
                }
                EClassifier type = ((EClass) eType).getEStructuralFeature("wrappedValue").getEType();
                eAttribute.setEType(type);
                cls.getEStructuralFeatures().add(eAttribute);
                if (type == EcorePackage.eINSTANCE.getEDouble()) {
                    EAttribute doubleStringAttribute = eFactory.createEAttribute();
                    doubleStringAttribute.setName(attrib.getName() + "AsString");
                    doubleStringAttribute.getEAnnotations().add(createAsStringAnnotation());
                    doubleStringAttribute.getEAnnotations().add(createHiddenAnnotation());
                    doubleStringAttribute.setEType(EcorePackage.eINSTANCE.getEString());
                    doubleStringAttribute.setUnsettable(expAttrib.isOptional());
                    cls.getEStructuralFeatures().add(doubleStringAttribute);
                }
            } else {
                EReference eRef = eFactory.createEReference();
                eRef.setName(attrib.getName());
                // Hardcoded hack to fix multiplicity for
                // IfcSpatialStructureElement which references
                // RefLatitude and RefLongitude
                eRef.setUnsettable(expAttrib.isOptional());
                eRef.setEType(eType);
                cls.getEStructuralFeatures().add(eRef);
            }
        }
    } else if (domain instanceof AggregationType) {
        BaseType bt = ((AggregationType) domain).getElement_type();
        EClass cls = (EClass) schemaPack.getEClassifier(ent.getName());
        if (bt instanceof NamedType) {
            NamedType nt = (NamedType) bt;
            EClassifier eType = schemaPack.getEClassifier(nt.getName());
            if (superTypeIsWrapped((EClass) eType)) {
                EAttribute eAttribute = eFactory.createEAttribute();
                eAttribute.setName(attrib.getName());
                if (eAttribute.getName().equals("RefLatitude") || eAttribute.getName().equals("RefLongitude")) {
                    eAttribute.setUpperBound(3);
                } else {
                    eAttribute.setUpperBound(-1);
                }
                EClassifier type = ((EClass) eType).getEStructuralFeature("wrappedValue").getEType();
                eAttribute.setEType(type);
                eAttribute.setUnsettable(expAttrib.isOptional());
                eAttribute.setUnique(false);
                cls.getEStructuralFeatures().add(eAttribute);
                if (type == EcorePackage.eINSTANCE.getEDouble()) {
                    EAttribute doubleStringAttribute = eFactory.createEAttribute();
                    doubleStringAttribute.setName(attrib.getName() + "AsString");
                    doubleStringAttribute.getEAnnotations().add(createAsStringAnnotation());
                    doubleStringAttribute.getEAnnotations().add(createHiddenAnnotation());
                    doubleStringAttribute.setEType(EcorePackage.eINSTANCE.getEString());
                    doubleStringAttribute.setUpperBound(-1);
                    doubleStringAttribute.setUnsettable(expAttrib.isOptional());
                    doubleStringAttribute.setUpperBound(eAttribute.getUpperBound());
                    doubleStringAttribute.setUnique(false);
                    cls.getEStructuralFeatures().add(doubleStringAttribute);
                }
            } else if (eType == EcorePackage.eINSTANCE.getEDouble()) {
                EAttribute eAttribute = eFactory.createEAttribute();
                eAttribute.setName(attrib.getName());
                eAttribute.setUnsettable(expAttrib.isOptional());
                eAttribute.setUnique(false);
                eAttribute.setEType(EcorePackage.eINSTANCE.getEAttribute());
                cls.getEStructuralFeatures().add(eAttribute);
                EAttribute doubleStringAttribute = eFactory.createEAttribute();
                doubleStringAttribute.getEAnnotations().add(createHiddenAnnotation());
                doubleStringAttribute.getEAnnotations().add(createAsStringAnnotation());
                doubleStringAttribute.setName(attrib.getName() + "AsString");
                doubleStringAttribute.setUpperBound(-1);
                doubleStringAttribute.setEType(EcorePackage.eINSTANCE.getEString());
                doubleStringAttribute.setUnsettable(expAttrib.isOptional());
                doubleStringAttribute.setUpperBound(eAttribute.getUpperBound());
                doubleStringAttribute.setUnique(false);
                cls.getEStructuralFeatures().add(doubleStringAttribute);
            } else {
                EReference eRef = eFactory.createEReference();
                eRef.setUpperBound(-1);
                eRef.setName(attrib.getName());
                // Hardcoded hack to fix multiplicity for
                // IfcSpatialStructureElement which references
                // RefLatitude and RefLongitude
                eRef.setUnsettable(expAttrib.isOptional());
                eRef.setEType(eType);
                eRef.setUnique(false);
                // EClass cls = (EClass)
                // schemaPack.getEClassifier(ent.getName());
                cls.getEStructuralFeatures().add(eRef);
            }
        // EClassifier eType = schemaPack.getEClassifier(nt.getName());
        // eRef.setEType(eType);
        // cls.getEStructuralFeatures().add(eRef);
        } else if (bt instanceof RealType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setUnsettable(expAttrib.isOptional());
            eAttribute.setName(attrib.getName());
            eAttribute.setUpperBound(-1);
            eAttribute.setUnique(false);
            eAttribute.setEType(EcorePackage.eINSTANCE.getEDouble());
            cls.getEStructuralFeatures().add(eAttribute);
            EAttribute doubleStringAttribute = eFactory.createEAttribute();
            doubleStringAttribute.getEAnnotations().add(createHiddenAnnotation());
            doubleStringAttribute.getEAnnotations().add(createAsStringAnnotation());
            doubleStringAttribute.setName(attrib.getName() + "AsString");
            doubleStringAttribute.setUpperBound(-1);
            doubleStringAttribute.setEType(EcorePackage.eINSTANCE.getEString());
            doubleStringAttribute.setUnsettable(expAttrib.isOptional());
            doubleStringAttribute.setUpperBound(eAttribute.getUpperBound());
            doubleStringAttribute.setUnique(false);
            cls.getEStructuralFeatures().add(doubleStringAttribute);
        } else if (bt instanceof IntegerType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setName(attrib.getName());
            eAttribute.setUpperBound(-1);
            eAttribute.setUnique(false);
            eAttribute.setEType(EcorePackage.eINSTANCE.getELong());
            eAttribute.setUnsettable(expAttrib.isOptional());
            cls.getEStructuralFeatures().add(eAttribute);
        } else if (bt instanceof NumberType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setName(attrib.getName());
            eAttribute.setUpperBound(-1);
            eAttribute.setUnique(false);
            eAttribute.setEType(EcorePackage.eINSTANCE.getELong());
            eAttribute.setUnsettable(expAttrib.isOptional());
            cls.getEStructuralFeatures().add(eAttribute);
        } else if (bt instanceof LogicalType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setName(attrib.getName());
            eAttribute.setUpperBound(-1);
            eAttribute.setUnique(false);
            eAttribute.setEType(EcorePackage.eINSTANCE.getEBoolean());
            eAttribute.setUnsettable(expAttrib.isOptional());
            cls.getEStructuralFeatures().add(eAttribute);
        } else if (bt instanceof BinaryType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setUnsettable(expAttrib.isOptional());
            eAttribute.setUpperBound(-1);
            eAttribute.setName(attrib.getName());
            eAttribute.setUnique(false);
            eAttribute.setEType(EcorePackage.eINSTANCE.getEByteArray());
            cls.getEStructuralFeatures().add(eAttribute);
        } else if (bt == null) {
            // These are the new 2-dimensional arrays in IFC4, there are 10 of them (more in add2)
            addTwoDimensionalArray(ent.getName(), attrib.getName());
        }
        if (domain instanceof ArrayType) {
        // TODO this is not yet implmented in simpelSDAI
        // eAttrib.setLowerBound(((nl.tue.buildingsmart.express.dictionary
        // .ArrayType)domain).getLower_index());
        // One fix for this has been implemented in addHackedTypes
        }
    } else {
        EClass cls = (EClass) schemaPack.getEClassifier(ent.getName());
        if (domain == null) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setUnsettable(expAttrib.isOptional());
            eAttribute.setName(attrib.getName());
            eAttribute.setEType(tristate);
            cls.getEStructuralFeatures().add(eAttribute);
        } else if (domain instanceof IntegerType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setUnsettable(expAttrib.isOptional());
            eAttribute.setName(attrib.getName());
            eAttribute.setEType(EcorePackage.eINSTANCE.getELong());
            cls.getEStructuralFeatures().add(eAttribute);
        } else if (domain instanceof LogicalType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setUnsettable(expAttrib.isOptional());
            eAttribute.setName(attrib.getName());
            eAttribute.setEType(EcorePackage.eINSTANCE.getEBoolean());
            cls.getEStructuralFeatures().add(eAttribute);
        } else if (domain instanceof RealType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setUnsettable(expAttrib.isOptional());
            eAttribute.setName(attrib.getName());
            eAttribute.setEType(EcorePackage.eINSTANCE.getEDouble());
            cls.getEStructuralFeatures().add(eAttribute);
            EAttribute eAttributeAsString = eFactory.createEAttribute();
            eAttributeAsString.getEAnnotations().add(createAsStringAnnotation());
            eAttributeAsString.getEAnnotations().add(createHiddenAnnotation());
            eAttributeAsString.setUnsettable(expAttrib.isOptional());
            eAttributeAsString.setName(attrib.getName() + "AsString");
            eAttributeAsString.setEType(EcorePackage.eINSTANCE.getEString());
            cls.getEStructuralFeatures().add(eAttributeAsString);
        } else if (domain instanceof StringType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setUnsettable(expAttrib.isOptional());
            eAttribute.setName(attrib.getName());
            eAttribute.setEType(EcorePackage.eINSTANCE.getEString());
            cls.getEStructuralFeatures().add(eAttribute);
        } else if (domain instanceof BinaryType) {
            EAttribute eAttribute = eFactory.createEAttribute();
            eAttribute.setUnsettable(expAttrib.isOptional());
            eAttribute.setName(attrib.getName());
            eAttribute.setEType(EcorePackage.eINSTANCE.getEByteArray());
            cls.getEStructuralFeatures().add(eAttribute);
        } else {
            throw new RuntimeException("Unknown type: " + domain);
        }
    }
}
Also used : BinaryType(nl.tue.buildingsmart.schema.BinaryType) StringType(nl.tue.buildingsmart.schema.StringType) NamedType(nl.tue.buildingsmart.schema.NamedType) EnumerationType(nl.tue.buildingsmart.schema.EnumerationType) EClassifier(org.eclipse.emf.ecore.EClassifier) LogicalType(nl.tue.buildingsmart.schema.LogicalType) AggregationType(nl.tue.buildingsmart.schema.AggregationType) RealType(nl.tue.buildingsmart.schema.RealType) IntegerType(nl.tue.buildingsmart.schema.IntegerType) ArrayType(nl.tue.buildingsmart.schema.ArrayType) EClass(org.eclipse.emf.ecore.EClass) EAttribute(org.eclipse.emf.ecore.EAttribute) NumberType(nl.tue.buildingsmart.schema.NumberType) BaseType(nl.tue.buildingsmart.schema.BaseType) EReference(org.eclipse.emf.ecore.EReference) ExplicitAttribute(nl.tue.buildingsmart.schema.ExplicitAttribute)

Aggregations

IntegerType (nl.tue.buildingsmart.schema.IntegerType)3 LogicalType (nl.tue.buildingsmart.schema.LogicalType)3 NumberType (nl.tue.buildingsmart.schema.NumberType)3 RealType (nl.tue.buildingsmart.schema.RealType)3 StringType (nl.tue.buildingsmart.schema.StringType)3 BinaryType (nl.tue.buildingsmart.schema.BinaryType)2 NamedType (nl.tue.buildingsmart.schema.NamedType)2 EAttribute (org.eclipse.emf.ecore.EAttribute)2 EClass (org.eclipse.emf.ecore.EClass)2 AggregationType (nl.tue.buildingsmart.schema.AggregationType)1 ArrayType (nl.tue.buildingsmart.schema.ArrayType)1 BaseType (nl.tue.buildingsmart.schema.BaseType)1 BooleanType (nl.tue.buildingsmart.schema.BooleanType)1 DefinedType (nl.tue.buildingsmart.schema.DefinedType)1 EntityDefinition (nl.tue.buildingsmart.schema.EntityDefinition)1 EnumerationType (nl.tue.buildingsmart.schema.EnumerationType)1 ExplicitAttribute (nl.tue.buildingsmart.schema.ExplicitAttribute)1 SelectType (nl.tue.buildingsmart.schema.SelectType)1 UnderlyingType (nl.tue.buildingsmart.schema.UnderlyingType)1 EClassifier (org.eclipse.emf.ecore.EClassifier)1