Search in sources :

Example 16 with Revision

use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.

the class PluginServiceImpl method getAllSerializersForRoids.

@Override
public List<SSerializerPluginConfiguration> getAllSerializersForRoids(Boolean onlyEnabled, Set<Long> roids) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        Set<Long> poids = new HashSet<>();
        for (Long roid : roids) {
            Revision revision = session.get(roid, OldQuery.getDefault());
            for (ConcreteRevision concreteRevision : revision.getConcreteRevisions()) {
                poids.add(concreteRevision.getProject().getOid());
            }
        }
        return getAllSerializersForPoids(onlyEnabled, poids);
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
    return null;
}
Also used : Revision(org.bimserver.models.store.Revision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) DatabaseSession(org.bimserver.database.DatabaseSession) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException) HashSet(java.util.HashSet)

Example 17 with Revision

use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.

the class LongDownloadOrCheckoutAction method executeAction.

protected void executeAction(BimDatabaseAction<? extends IfcModelInterface> action, DownloadParameters downloadParameters, DatabaseSession session, boolean commit) throws BimserverDatabaseException, UserException, NoSerializerFoundException, ServerException {
    try {
        if (action == null) {
            checkoutResult = new SCheckoutResult();
            checkoutResult.setFile(new CachingDataHandler(getBimServer().getDiskCacheManager(), downloadParameters));
            checkoutResult.setSerializerOid(downloadParameters.getSerializerOid());
        } else {
            Revision revision = session.get(StorePackage.eINSTANCE.getRevision(), downloadParameters.getRoid(), OldQuery.getDefault());
            if (revision == null) {
                throw new UserException("Revision with roid " + downloadParameters.getRoid() + " not found");
            }
            // Little hack to make
            revision.getProject().getGeoTag().load();
            // sure this is
            // lazily loaded,
            // because after the
            // executeAndCommitAction
            // the session won't
            // be usable
            IfcModelInterface ifcModel = session.executeAndCommitAction(action);
            // Session is closed after this
            DatabaseSession newSession = getBimServer().getDatabase().createSession();
            RenderEnginePlugin renderEnginePlugin = null;
            try {
                PluginConfiguration serializerPluginConfiguration = newSession.get(StorePackage.eINSTANCE.getPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
                if (serializerPluginConfiguration != null) {
                    if (serializerPluginConfiguration instanceof MessagingSerializerPluginConfiguration) {
                        try {
                            messagingSerializer = getBimServer().getSerializerFactory().createMessagingSerializer(getUserName(), ifcModel, downloadParameters);
                        } catch (SerializerException e) {
                            e.printStackTrace();
                        }
                    } else if (serializerPluginConfiguration instanceof SerializerPluginConfiguration) {
                        RenderEnginePluginConfiguration renderEngine = ((SerializerPluginConfiguration) serializerPluginConfiguration).getRenderEngine();
                        if (renderEngine != null) {
                            renderEnginePlugin = getBimServer().getPluginManager().getRenderEnginePlugin(renderEngine.getPluginDescriptor().getPluginClassName(), true);
                        }
                        checkoutResult = convertModelToCheckoutResult(revision.getProject(), getUserName(), ifcModel, renderEnginePlugin, downloadParameters);
                    }
                }
            } catch (BimserverDatabaseException e) {
                LOGGER.error("", e);
            } finally {
                newSession.close();
            }
        }
    } finally {
        done();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SCheckoutResult(org.bimserver.interfaces.objects.SCheckoutResult) RenderEnginePlugin(org.bimserver.plugins.renderengine.RenderEnginePlugin) SerializerException(org.bimserver.plugins.serializers.SerializerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) Revision(org.bimserver.models.store.Revision) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) PluginConfiguration(org.bimserver.models.store.PluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException)

Example 18 with Revision

use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.

the class NewRevisionNotification method process.

@Override
public void process() throws BimserverDatabaseException, UserException, ServerException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        Project project = session.get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
        if (project == null) {
            LOGGER.error("Project with oid " + poid + " not found");
            return;
        }
        Revision revision = session.get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
        if (revision == null) {
            LOGGER.error("Revision with roid " + roid + " not found");
            return;
        }
        if (project.isSendEmailOnNewRevision() && sendEmail) {
            sendEmail(session, project, revision);
        }
        for (NewService newService : project.getNewServices()) {
            if (soid == -1 || newService.getOid() == soid) {
                triggerNewRevision(session, getBimServer().getNotificationsManager(), getBimServer(), getBimServer().getNotificationsManager().getSiteAddress(), project, roid, Trigger.NEW_REVISION, newService);
            }
        }
        for (Service service : project.getServices()) {
            if (soid == -1 || service.getOid() == soid) {
                triggerNewRevision(session, getBimServer().getNotificationsManager(), getBimServer(), getBimServer().getNotificationsManager().getSiteAddress(), project, roid, Trigger.NEW_REVISION, service);
            }
        }
        if (soid == -1) {
            // Only execute if we are not triggering a specific service with this notification
            NewRevisionTopic newRevisionTopic = getBimServer().getNotificationsManager().getNewRevisionTopic();
            if (newRevisionTopic != null) {
                newRevisionTopic.process(session, poid, roid, this);
            }
            NewRevisionOnSpecificProjectTopic newRevisionOnSpecificProjectTopic = getBimServer().getNotificationsManager().getNewRevisionOnSpecificProjectTopic(new NewRevisionOnSpecificProjectTopicKey(poid));
            if (newRevisionOnSpecificProjectTopic != null) {
                newRevisionOnSpecificProjectTopic.process(session, poid, roid, this);
            }
        }
    } finally {
        session.close();
    }
}
Also used : Project(org.bimserver.models.store.Project) Revision(org.bimserver.models.store.Revision) DatabaseSession(org.bimserver.database.DatabaseSession) Service(org.bimserver.models.store.Service) NewService(org.bimserver.models.store.NewService) NewService(org.bimserver.models.store.NewService)

Example 19 with Revision

use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.

the class GetAllRevisionsByUserDatabaseAction method execute.

@Override
public Set<Revision> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    User user = getUserByUoid(uoid);
    Condition condition = new HasReferenceToCondition(StorePackage.eINSTANCE.getRevision_User(), user);
    return CollectionUtils.mapToSet(getDatabaseSession().query(condition, Revision.class, OldQuery.getDefault()));
}
Also used : Condition(org.bimserver.database.query.conditions.Condition) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition) User(org.bimserver.models.store.User) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition) Revision(org.bimserver.models.store.Revision)

Example 20 with Revision

use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.

the class GetCheckinWarningsDatabaseAction method checkInterleavingCommits.

private void checkInterleavingCommits(Project project, User user, Set<String> warnings) {
    Checkout lastOwnActiveCheckout = null;
    for (Checkout checkout : project.getCheckouts()) {
        if (checkout.getUser() == user && checkout.getActive()) {
            lastOwnActiveCheckout = checkout;
        }
    }
    if (lastOwnActiveCheckout != null) {
        Project mainProject = project;
        while (mainProject.getParent() != null) {
            mainProject = mainProject.getParent();
        }
        int newRevisionsAfterCheckout = 0;
        for (Revision virtualRevision : mainProject.getRevisions()) {
            if (lastOwnActiveCheckout.getDate().before(virtualRevision.getDate()) && lastOwnActiveCheckout.getRevision() != virtualRevision) {
                newRevisionsAfterCheckout++;
            }
        }
        if (newRevisionsAfterCheckout == 1) {
            warnings.add("Warning, after your last checkout of this project (revision " + lastOwnActiveCheckout.getRevision().getId() + "), a new revision has been checked-in");
        } else if (newRevisionsAfterCheckout > 1) {
            warnings.add("Warning, after your last checkout of this project (revision " + lastOwnActiveCheckout.getRevision().getId() + "), " + newRevisionsAfterCheckout + " new revisions have been checked-in");
        }
    }
}
Also used : Project(org.bimserver.models.store.Project) Checkout(org.bimserver.models.store.Checkout) Revision(org.bimserver.models.store.Revision)

Aggregations

Revision (org.bimserver.models.store.Revision)52 UserException (org.bimserver.shared.exceptions.UserException)39 Project (org.bimserver.models.store.Project)23 PackageMetaData (org.bimserver.emf.PackageMetaData)22 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)20 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)18 OldQuery (org.bimserver.database.OldQuery)17 User (org.bimserver.models.store.User)16 DatabaseSession (org.bimserver.database.DatabaseSession)15 IfcModelInterface (org.bimserver.emf.IfcModelInterface)14 ServerException (org.bimserver.shared.exceptions.ServerException)14 IOException (java.io.IOException)12 Date (java.util.Date)11 ModelHelper (org.bimserver.plugins.ModelHelper)10 HashMap (java.util.HashMap)9 SRevision (org.bimserver.interfaces.objects.SRevision)9 IfcModelSet (org.bimserver.plugins.IfcModelSet)9 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)9 MergeException (org.bimserver.plugins.modelmerger.MergeException)9 SerializerException (org.bimserver.plugins.serializers.SerializerException)8