use of nl.tue.buildingsmart.schema.ExplicitAttribute in project BIMserver by opensourceBIM.
the class PackageMetaData method buildUseForDatabaseStorage.
private void buildUseForDatabaseStorage(EClass eClass) {
if (this.getSchemaDefinition() != null) {
HashSet<EStructuralFeature> set = new HashSet<>();
for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) {
EntityDefinition entityBN = this.getSchemaDefinition().getEntityBN(eClass.getName());
if (entityBN == null) {
set.add(eStructuralFeature);
} else {
if (!entityBN.isDerived(eStructuralFeature.getName())) {
boolean derived = false;
if (eStructuralFeature.getEAnnotation("hidden") != null) {
if (eStructuralFeature.getEAnnotation("asstring") == null) {
} else {
if (entityBN.isDerived(eStructuralFeature.getName().substring(0, eStructuralFeature.getName().length() - 8))) {
derived = true;
} else {
set.add(eStructuralFeature);
}
}
}
Attribute attribute = entityBN.getAttributeBNWithSuper(eStructuralFeature.getName());
if (attribute == null) {
// geometry, *AsString
if (!derived) {
set.add(eStructuralFeature);
}
} else {
if (attribute instanceof ExplicitAttribute || attribute instanceof InverseAttribute) {
if (!entityBN.isDerived(attribute.getName())) {
set.add(eStructuralFeature);
}
}
}
}
}
}
useForDatabaseStorage.put(eClass, set);
}
}
use of nl.tue.buildingsmart.schema.ExplicitAttribute in project BIMserver by opensourceBIM.
the class PackageMetaData method buildUseForSerializationSet.
private void buildUseForSerializationSet(EClass eClass) {
if (this.getSchemaDefinition() != null) {
if (!useForSerialization.containsKey(eClass)) {
HashSet<EStructuralFeature> set = new HashSet<>();
for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) {
EntityDefinition entityBN = this.getSchemaDefinition().getEntityBN(eClass.getName());
// }
if (entityBN != null) {
Attribute attribute = entityBN.getAttributeBNWithSuper(eStructuralFeature.getName());
if (attribute != null && attribute instanceof ExplicitAttribute) {
if (!entityBN.isDerived(eStructuralFeature.getName()) || entityBN.isDerivedOverride(eStructuralFeature.getName())) {
set.add(eStructuralFeature);
}
}
}
}
useForSerialization.put(eClass, set);
}
}
}
use of nl.tue.buildingsmart.schema.ExplicitAttribute in project BIMserver by opensourceBIM.
the class Express2EMF method addAttributes.
private void addAttributes() {
Iterator<EntityDefinition> entIter = schema.getEntities().iterator();
while (entIter.hasNext()) {
EntityDefinition ent = (EntityDefinition) entIter.next();
Iterator<Attribute> attribIter = ent.getAttributes(false).iterator();
while (attribIter.hasNext()) {
Attribute attrib = (Attribute) attribIter.next();
if (attrib instanceof ExplicitAttribute) {
processAttribute(ent, attrib);
}
}
}
}
use of nl.tue.buildingsmart.schema.ExplicitAttribute 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