Search in sources :

Example 1 with InverseAttribute

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

the class PackageMetaData method isInverse.

public boolean isInverse(EReference eReference) {
    if (isInverseCache.containsKey(eReference)) {
        return isInverseCache.get(eReference);
    }
    EntityDefinition entityBN = schemaDefinition.getEntityBNNoCaseConvert(upperCases.get(eReference.getEContainingClass()));
    if (entityBN == null) {
        return false;
    }
    Attribute attributeBNWithSuper = entityBN.getAttributeBNWithSuper(eReference.getName());
    boolean isInverse = entityBN != null && attributeBNWithSuper instanceof InverseAttribute;
    if (!isInverse) {
        if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcElement_ContainedInStructure()) {
            isInverse = true;
        } else if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcAnnotation_ContainedInStructure()) {
            isInverse = true;
        } else if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcGrid_ContainedInStructure()) {
            isInverse = true;
        }
        if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcRepresentation_LayerAssignments()) {
            isInverse = true;
        } else if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcRepresentationItem_LayerAssignments()) {
            isInverse = true;
        }
        if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcObjectDefinition_HasAssociations()) {
            isInverse = true;
        } else if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcPropertyDefinition_HasAssociations()) {
            isInverse = true;
        }
        if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcDimensionCurve_AnnotatedBySymbols()) {
            isInverse = true;
        }
        if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcElement_ReferencedInStructures()) {
            isInverse = true;
        }
        if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcProductDefinitionShape_ShapeOfProduct()) {
            isInverse = true;
        }
        if (eReference == Ifc2x3tc1Package.eINSTANCE.getIfcStructuralItem_AssignedStructuralActivity()) {
            isInverse = true;
        }
    }
    isInverseCache.put(eReference, isInverse);
    return isInverse;
}
Also used : EntityDefinition(nl.tue.buildingsmart.schema.EntityDefinition) EAttribute(org.eclipse.emf.ecore.EAttribute) Attribute(nl.tue.buildingsmart.schema.Attribute) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) ExplicitAttribute(nl.tue.buildingsmart.schema.ExplicitAttribute) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute)

Example 2 with InverseAttribute

use of nl.tue.buildingsmart.schema.InverseAttribute 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);
    }
}
Also used : EntityDefinition(nl.tue.buildingsmart.schema.EntityDefinition) EAttribute(org.eclipse.emf.ecore.EAttribute) Attribute(nl.tue.buildingsmart.schema.Attribute) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) ExplicitAttribute(nl.tue.buildingsmart.schema.ExplicitAttribute) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) HashSet(java.util.HashSet) ExplicitAttribute(nl.tue.buildingsmart.schema.ExplicitAttribute)

Example 3 with InverseAttribute

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

the class SharedJsonDeserializer method processRef.

@SuppressWarnings({ "unchecked", "rawtypes" })
private void processRef(IfcModelInterface model, WaitingList<Long> waitingList, IdEObjectImpl object, EStructuralFeature eStructuralFeature, int index, AbstractEList list, long refOid) throws DeserializeException {
    EntityDefinition entityBN = model.getPackageMetaData().getSchemaDefinition().getEntityBN(object.eClass().getName());
    Attribute attributeBN = entityBN.getAttributeBNWithSuper(eStructuralFeature.getName());
    if (skipInverses && attributeBN instanceof InverseAttribute && ((EReference) eStructuralFeature).getEOpposite() != null) {
    // skip
    } else {
        if (model.contains(refOid)) {
            EObject referencedObject = model.get(refOid);
            if (referencedObject != null) {
                addToList(eStructuralFeature, index, list, referencedObject);
            }
        } else {
            waitingList.add(refOid, new ListWaitingObject(-1, object, (EReference) eStructuralFeature, index));
        }
    }
}
Also used : EntityDefinition(nl.tue.buildingsmart.schema.EntityDefinition) EAttribute(org.eclipse.emf.ecore.EAttribute) Attribute(nl.tue.buildingsmart.schema.Attribute) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) EObject(org.eclipse.emf.ecore.EObject) ListWaitingObject(org.bimserver.shared.ListWaitingObject) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) EReference(org.eclipse.emf.ecore.EReference)

Example 4 with InverseAttribute

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

the class Express2EMF method addInverseAttribute.

private void addInverseAttribute(Attribute attrib, EClass cls) {
    InverseAttribute inverseAttribute = (InverseAttribute) attrib;
    EReference eRef = eFactory.createEReference();
    // Inverses are always optional?
    eRef.setUnsettable(true);
    eRef.getEAnnotations().add(createInverseAnnotation());
    eRef.setName(attrib.getName());
    if (inverseAttribute.getMax_cardinality() != null) {
        IntegerBound max_cardinality = (IntegerBound) inverseAttribute.getMax_cardinality();
        if (max_cardinality.getBound_value() == -1) {
            eRef.setUpperBound(max_cardinality.getBound_value());
        } else {
            eRef.setUpperBound(max_cardinality.getBound_value() + 1);
        }
    }
    String type = (inverseAttribute).getDomain().getName();
    EClass classifier = (EClass) schemaPack.getEClassifier(type);
    eRef.setEType(classifier);
    String reverseName = inverseAttribute.getInverted_attr().getName();
    EReference reference = (EReference) classifier.getEStructuralFeature(reverseName);
    reference.getEAnnotations().add(createInverseAnnotation());
    if (eRef.getEType() == classifier && reference.getEType() == cls) {
        if (eRef.isMany()) {
            eRef.setUnique(true);
        }
        if (reference.isMany()) {
            reference.setUnique(true);
        }
        reference.setEOpposite(eRef);
        eRef.setEOpposite(reference);
    } else {
        System.out.println("Inverse mismatch");
        System.out.println(classifier.getName() + "." + reference.getName() + " => " + cls.getName() + "." + eRef.getName());
    }
    cls.getEStructuralFeatures().add(eRef);
}
Also used : IntegerBound(nl.tue.buildingsmart.schema.IntegerBound) EClass(org.eclipse.emf.ecore.EClass) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) EReference(org.eclipse.emf.ecore.EReference)

Example 5 with InverseAttribute

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

the class Express2EMF method addInverses.

private void addInverses() {
    Iterator<EntityDefinition> entIter = schema.getEntities().iterator();
    while (entIter.hasNext()) {
        EntityDefinition ent = (EntityDefinition) entIter.next();
        Iterator<Attribute> attribIter = ent.getAttributes(false).iterator();
        EClass cls = (EClass) schemaPack.getEClassifier(ent.getName());
        // }
        while (attribIter.hasNext()) {
            Attribute attrib = (Attribute) attribIter.next();
            // } else {
            if (attrib instanceof InverseAttribute) {
                addInverseAttribute(attrib, cls);
            }
        // }
        }
    }
}
Also used : EntityDefinition(nl.tue.buildingsmart.schema.EntityDefinition) EClass(org.eclipse.emf.ecore.EClass) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) EAttribute(org.eclipse.emf.ecore.EAttribute) Attribute(nl.tue.buildingsmart.schema.Attribute) ExplicitAttribute(nl.tue.buildingsmart.schema.ExplicitAttribute) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute)

Aggregations

InverseAttribute (nl.tue.buildingsmart.schema.InverseAttribute)8 Attribute (nl.tue.buildingsmart.schema.Attribute)7 EntityDefinition (nl.tue.buildingsmart.schema.EntityDefinition)7 EAttribute (org.eclipse.emf.ecore.EAttribute)5 EReference (org.eclipse.emf.ecore.EReference)5 ExplicitAttribute (nl.tue.buildingsmart.schema.ExplicitAttribute)3 EClass (org.eclipse.emf.ecore.EClass)3 List (java.util.List)2 ListWaitingObject (org.bimserver.shared.ListWaitingObject)2 EObject (org.eclipse.emf.ecore.EObject)2 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)2 JsonToken (com.google.gson.stream.JsonToken)1 HashSet (java.util.HashSet)1 IntegerBound (nl.tue.buildingsmart.schema.IntegerBound)1 SchemaDefinition (nl.tue.buildingsmart.schema.SchemaDefinition)1 IdEObject (org.bimserver.emf.IdEObject)1 IfcGloballyUniqueId (org.bimserver.models.ifc2x3tc1.IfcGloballyUniqueId)1 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)1 WaitingList (org.bimserver.shared.WaitingList)1 AbstractEList (org.eclipse.emf.common.util.AbstractEList)1