Search in sources :

Example 1 with ExtendedDataAddedToProject

use of org.bimserver.models.log.ExtendedDataAddedToProject in project BIMserver by opensourceBIM.

the class AddExtendedDataToProjectDatabaseAction method execute.

@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    super.execute();
    User actingUser = getUserByUoid(authorization.getUoid());
    Project project = getProjectByPoid(poid);
    if (project == null) {
        throw new UserException("Project with poid " + poid + " not found");
    }
    project.getExtendedData().add(getIdEObject());
    getDatabaseSession().store(project);
    final ExtendedDataAddedToProject extendedDataAddedToProject = getDatabaseSession().create(ExtendedDataAddedToProject.class);
    extendedDataAddedToProject.setAccessMethod(getAccessMethod());
    extendedDataAddedToProject.setDate(new Date());
    extendedDataAddedToProject.setExecutor(actingUser);
    extendedDataAddedToProject.setExtendedData(getIdEObject());
    extendedDataAddedToProject.setProject(project);
    getDatabaseSession().addPostCommitAction(new PostCommitAction() {

        @Override
        public void execute() throws UserException {
            bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(extendedDataAddedToProject));
        }
    });
    return null;
}
Also used : ExtendedDataAddedToProject(org.bimserver.models.log.ExtendedDataAddedToProject) Project(org.bimserver.models.store.Project) User(org.bimserver.models.store.User) ExtendedDataAddedToProject(org.bimserver.models.log.ExtendedDataAddedToProject) SConverter(org.bimserver.interfaces.SConverter) PostCommitAction(org.bimserver.database.PostCommitAction) UserException(org.bimserver.shared.exceptions.UserException) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 PostCommitAction (org.bimserver.database.PostCommitAction)1 SConverter (org.bimserver.interfaces.SConverter)1 ExtendedDataAddedToProject (org.bimserver.models.log.ExtendedDataAddedToProject)1 Project (org.bimserver.models.store.Project)1 User (org.bimserver.models.store.User)1 UserException (org.bimserver.shared.exceptions.UserException)1