use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class TracingGarbageCollector method sweep.
public void sweep() {
Map<Long, IdEObject> objects = ifcModel.getObjects();
Iterator<Long> iterator = objects.keySet().iterator();
while (iterator.hasNext()) {
Long next = iterator.next();
IdEObject idEObject = objects.get(next);
if (!referencedObjects.contains(idEObject)) {
iterator.remove();
}
}
}
use of org.bimserver.emf.IdEObject 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));
}
}
}
}
}
}
}
use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class ServiceImpl method getUserRelatedLogs.
@Override
public List<SLogAction> getUserRelatedLogs(Long uoid) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
List<LogAction> logActions = new ArrayList<LogAction>();
User user = session.get(getAuthorization().getUoid(), OldQuery.getDefault());
IfcModelInterface projectsModel = session.getAllOfType(StorePackage.eINSTANCE.getProject(), OldQuery.getDefault());
logActions.addAll(user.getLogs());
for (IdEObject idEObject : projectsModel.getValues()) {
if (idEObject instanceof Project) {
Project project = (Project) idEObject;
if ((user.getUserType() == UserType.ADMIN || (project.getState() == ObjectState.ACTIVE) && getAuthorization().hasRightsOnProjectOrSuperProjectsOrSubProjects(user, project))) {
logActions.addAll(project.getLogs());
}
}
}
Collections.sort(logActions, new Comparator<LogAction>() {
@Override
public int compare(LogAction o1, LogAction o2) {
return o1.getDate().compareTo(o2.getDate());
}
});
return getBimServer().getSConverter().convertToSListLogAction(logActions);
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations