use of nl.tue.buildingsmart.schema.EnumerationType in project BIMserver by opensourceBIM.
the class Express2EMF method addEnumerations.
private void addEnumerations() {
Iterator<DefinedType> typeIter = schema.getTypes().iterator();
while (typeIter.hasNext()) {
DefinedType type = typeIter.next();
if (type instanceof EnumerationType) {
EEnum enumeration = eFactory.createEEnum();
enumeration.setName(type.getName());
EEnumLiteral nullValue = eFactory.createEEnumLiteral();
nullValue.setName("NULL");
nullValue.setLiteral("NULL");
nullValue.setValue(0);
enumeration.getELiterals().add(nullValue);
int counter = 1;
Iterator<String> values = ((EnumerationType) type).getElements().iterator();
while (values.hasNext()) {
String stringVal = values.next();
if (!stringVal.equals("NULL")) {
EEnumLiteral value = eFactory.createEEnumLiteral();
value.setName(stringVal);
value.setLiteral(stringVal);
value.setValue(counter);
counter++;
enumeration.getELiterals().add(value);
}
}
schemaPack.getEClassifiers().add(enumeration);
}
}
}
use of nl.tue.buildingsmart.schema.EnumerationType 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);
}
}
}
Aggregations