Search in sources :

Example 6 with DefinedType

use of nl.tue.buildingsmart.schema.DefinedType 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)

Aggregations

DefinedType (nl.tue.buildingsmart.schema.DefinedType)6 EClass (org.eclipse.emf.ecore.EClass)5 EClassifier (org.eclipse.emf.ecore.EClassifier)3 EntityDefinition (nl.tue.buildingsmart.schema.EntityDefinition)2 IntegerType (nl.tue.buildingsmart.schema.IntegerType)2 RealType (nl.tue.buildingsmart.schema.RealType)2 EAttribute (org.eclipse.emf.ecore.EAttribute)2 DerivedAttribute2 (nl.tue.buildingsmart.schema.DerivedAttribute2)1 EnumerationType (nl.tue.buildingsmart.schema.EnumerationType)1 LogicalType (nl.tue.buildingsmart.schema.LogicalType)1 NamedType (nl.tue.buildingsmart.schema.NamedType)1 NumberType (nl.tue.buildingsmart.schema.NumberType)1 SelectType (nl.tue.buildingsmart.schema.SelectType)1 SimpleType (nl.tue.buildingsmart.schema.SimpleType)1 StringType (nl.tue.buildingsmart.schema.StringType)1 UnderlyingType (nl.tue.buildingsmart.schema.UnderlyingType)1 EEnum (org.eclipse.emf.ecore.EEnum)1 EEnumLiteral (org.eclipse.emf.ecore.EEnumLiteral)1 EReference (org.eclipse.emf.ecore.EReference)1