@Override public List<SLogAction> getLogs() throws ServerException, UserException { requireRealUserAuthentication(); DatabaseSession session = getBimServer().getDatabase().createSession(); try { BimDatabaseAction<List<LogAction>> action = new GetLogsDatabaseAction(session, getInternalAccessMethod(), getAuthorization()); List<LogAction> logs = session.executeAndCommitAction(action); List<SLogAction> convertToSListLogAction = getBimServer().getSConverter().convertToSListLogAction(logs); Collections.sort(convertToSListLogAction, new SLogComparator(true)); return convertToSListLogAction; } catch (Exception e) { return handleException(e); } finally { session.close(); } }
@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(); } }