use of org.bimserver.notifications.NewExtendedDataOnRevisionNotification in project BIMserver by opensourceBIM.
the class ServiceImpl method triggerNewExtendedData.
@Override
public void triggerNewExtendedData(Long edid, Long soid) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
ExtendedData extendedData = (ExtendedData) session.get(StorePackage.eINSTANCE.getExtendedData(), edid, OldQuery.getDefault());
SExtendedDataAddedToRevision newExtendedData = new SExtendedDataAddedToRevision();
newExtendedData.setRevisionId(extendedData.getRevision().getOid());
newExtendedData.setExtendedDataId(edid);
getBimServer().getNotificationsManager().notify(new NewExtendedDataOnRevisionNotification(getBimServer(), edid, extendedData.getRevision().getProject().getOid(), extendedData.getRevision().getOid(), soid));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.notifications.NewExtendedDataOnRevisionNotification 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