Search in sources :

Example 1 with NewExtendedDataOnRevisionNotification

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();
    }
}
Also used : ExtendedData(org.bimserver.models.store.ExtendedData) StoreExtendedData(org.bimserver.models.store.StoreExtendedData) SExtendedData(org.bimserver.interfaces.objects.SExtendedData) DatabaseSession(org.bimserver.database.DatabaseSession) SExtendedDataAddedToRevision(org.bimserver.interfaces.objects.SExtendedDataAddedToRevision) NewExtendedDataOnRevisionNotification(org.bimserver.notifications.NewExtendedDataOnRevisionNotification) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Example 2 with NewExtendedDataOnRevisionNotification

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;
}
Also used : User(org.bimserver.models.store.User) ExtendedDataAddedToRevision(org.bimserver.models.log.ExtendedDataAddedToRevision) Revision(org.bimserver.models.store.Revision) SConverter(org.bimserver.interfaces.SConverter) PostCommitAction(org.bimserver.database.PostCommitAction) ExtendedDataAddedToRevision(org.bimserver.models.log.ExtendedDataAddedToRevision) UserException(org.bimserver.shared.exceptions.UserException) NewExtendedDataOnRevisionNotification(org.bimserver.notifications.NewExtendedDataOnRevisionNotification) File(org.bimserver.models.store.File) Date(java.util.Date)

Aggregations

NewExtendedDataOnRevisionNotification (org.bimserver.notifications.NewExtendedDataOnRevisionNotification)2 UserException (org.bimserver.shared.exceptions.UserException)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 Date (java.util.Date)1 MessagingException (javax.mail.MessagingException)1 AddressException (javax.mail.internet.AddressException)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 PostCommitAction (org.bimserver.database.PostCommitAction)1 SConverter (org.bimserver.interfaces.SConverter)1 SExtendedData (org.bimserver.interfaces.objects.SExtendedData)1 SExtendedDataAddedToRevision (org.bimserver.interfaces.objects.SExtendedDataAddedToRevision)1 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)1 ExtendedDataAddedToRevision (org.bimserver.models.log.ExtendedDataAddedToRevision)1 ExtendedData (org.bimserver.models.store.ExtendedData)1 File (org.bimserver.models.store.File)1 Revision (org.bimserver.models.store.Revision)1 StoreExtendedData (org.bimserver.models.store.StoreExtendedData)1