Search in sources :

Example 1 with SchemaDefinition

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

Aggregations

List (java.util.List)1 Attribute (nl.tue.buildingsmart.schema.Attribute)1 EntityDefinition (nl.tue.buildingsmart.schema.EntityDefinition)1 InverseAttribute (nl.tue.buildingsmart.schema.InverseAttribute)1 SchemaDefinition (nl.tue.buildingsmart.schema.SchemaDefinition)1 IdEObject (org.bimserver.emf.IdEObject)1 EReference (org.eclipse.emf.ecore.EReference)1