Search in sources :

Example 11 with EntityDefinition

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

the class TracingGarbageCollector method mark.

@SuppressWarnings("rawtypes")
public void mark(Set<? extends IdEObject> rootObjects) {
    referencedObjects.addAll(rootObjects);
    SchemaDefinition schema = ifcModel.getPackageMetaData().getSchemaDefinition();
    for (IdEObject rootObject : rootObjects) {
        for (EReference eReference : rootObject.eClass().getEAllReferences()) {
            Attribute attributeBNWithSuper = null;
            if (schema != null) {
                EntityDefinition entityBN = schema.getEntityBN(rootObject.eClass().getName());
                if (entityBN == null) {
                    LOGGER.info(rootObject.eClass().getName() + " not found");
                } else {
                    attributeBNWithSuper = entityBN.getAttributeBNWithSuper(eReference.getName());
                    if (attributeBNWithSuper == null) {
                        LOGGER.info(eReference.getName() + " not found");
                    }
                }
            }
            if (schema == null || !(attributeBNWithSuper instanceof InverseAttribute)) {
                Object referredObject = rootObject.eGet(eReference);
                if (eReference.isMany()) {
                    List list = (List) referredObject;
                    for (Object o : list) {
                        if (!referencedObjects.contains(o)) {
                            mark(makeSet((IdEObject) o));
                        }
                    }
                } else {
                    IdEObject referredIdEObject = (IdEObject) referredObject;
                    if (referredIdEObject != null) {
                        if (!referencedObjects.contains(referredObject)) {
                            mark(makeSet(referredIdEObject));
                        }
                    }
                }
            }
        }
    }
}
Also used : EntityDefinition(nl.tue.buildingsmart.schema.EntityDefinition) SchemaDefinition(nl.tue.buildingsmart.schema.SchemaDefinition) IdEObject(org.bimserver.emf.IdEObject) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) Attribute(nl.tue.buildingsmart.schema.Attribute) IdEObject(org.bimserver.emf.IdEObject) List(java.util.List) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) EReference(org.eclipse.emf.ecore.EReference)

Example 12 with EntityDefinition

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

the class AbstractObjectIDM method isInverse.

protected boolean isInverse(EStructuralFeature eStructuralFeature) throws ObjectIDMException {
    if (eStructuralFeature instanceof EReference && eStructuralFeature.getEContainingClass().getEAnnotation("wrapped") == null) {
        if (eStructuralFeature.getEAnnotation("hidden") == null && eStructuralFeature.getEContainingClass().getEAnnotation("hidden") == null) {
            EntityDefinition entityBN = packageMetaData.getSchemaDefinition().getEntityBN(eStructuralFeature.getEContainingClass().getName());
            if (entityBN == null) {
                throw new ObjectIDMException(eStructuralFeature.getEContainingClass().getName() + " not found");
            }
            Attribute attribute = entityBN.getAttributeBNWithSuper(eStructuralFeature.getName());
            return attribute instanceof InverseAttribute;
        } else {
            return false;
        }
    }
    return false;
}
Also used : EntityDefinition(nl.tue.buildingsmart.schema.EntityDefinition) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) Attribute(nl.tue.buildingsmart.schema.Attribute) InverseAttribute(nl.tue.buildingsmart.schema.InverseAttribute) EReference(org.eclipse.emf.ecore.EReference)

Aggregations

EntityDefinition (nl.tue.buildingsmart.schema.EntityDefinition)12 Attribute (nl.tue.buildingsmart.schema.Attribute)9 InverseAttribute (nl.tue.buildingsmart.schema.InverseAttribute)9 EAttribute (org.eclipse.emf.ecore.EAttribute)8 ExplicitAttribute (nl.tue.buildingsmart.schema.ExplicitAttribute)5 EClass (org.eclipse.emf.ecore.EClass)5 EReference (org.eclipse.emf.ecore.EReference)5 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)3 HashSet (java.util.HashSet)2 List (java.util.List)2 DefinedType (nl.tue.buildingsmart.schema.DefinedType)2 ListWaitingObject (org.bimserver.shared.ListWaitingObject)2 EObject (org.eclipse.emf.ecore.EObject)2 JsonToken (com.google.gson.stream.JsonToken)1 DerivedAttribute2 (nl.tue.buildingsmart.schema.DerivedAttribute2)1 IntegerType (nl.tue.buildingsmart.schema.IntegerType)1 LogicalType (nl.tue.buildingsmart.schema.LogicalType)1 NamedType (nl.tue.buildingsmart.schema.NamedType)1 NumberType (nl.tue.buildingsmart.schema.NumberType)1 RealType (nl.tue.buildingsmart.schema.RealType)1