use of org.bimserver.models.log.ExtendedDataAddedToRevision in project BIMserver by opensourceBIM.
the class AddExtendedDataToRevisionDatabaseAction method execute.
@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
authorization.canWriteExtendedData(roid);
User actingUser = getUserByUoid(authorization.getUoid());
getIdEObject().setUser(actingUser);
getIdEObject().setAdded(new Date());
File file = getIdEObject().getFile();
getIdEObject().setSize(file.getData().length);
super.execute();
Revision revision = getRevisionByRoid(roid);
if (revision == null) {
throw new UserException("Revision with roid " + roid + " not found");
}
revision.getExtendedData().add(getIdEObject());
getDatabaseSession().store(revision);
getIdEObject().setProject(revision.getProject());
getIdEObject().setRevision(revision);
if (getIdEObject().getSchema() != null) {
getDatabaseSession().store(getIdEObject().getSchema());
}
final ExtendedDataAddedToRevision extendedDataAddedToRevision = getDatabaseSession().create(ExtendedDataAddedToRevision.class);
extendedDataAddedToRevision.setAccessMethod(getAccessMethod());
extendedDataAddedToRevision.setDate(new Date());
extendedDataAddedToRevision.setExecutor(actingUser);
extendedDataAddedToRevision.setExtendedData(getIdEObject());
extendedDataAddedToRevision.setRevision(revision);
final long poid = revision.getProject().getOid();
final long roid = revision.getOid();
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new NewExtendedDataOnRevisionNotification(bimServer, getIdEObject().getOid(), poid, roid, -1));
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(extendedDataAddedToRevision));
}
});
return null;
}
Aggregations