Search in sources :

Example 21 with ConcreteRevision

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

the class AdminServiceImpl method regenerateGeometry.

@Override
public void regenerateGeometry(Long croid) throws ServerException, UserException {
    LOGGER.info("Regenerating geometry for concrete revision" + croid);
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        // Normally we wouldn't be allowed to change existing data
        session.setOverwriteEnabled(true);
        ConcreteRevision concreteRevision = session.get(StorePackage.eINSTANCE.getConcreteRevision(), croid, OldQuery.getDefault());
        PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(concreteRevision.getProject().getSchema());
        IfcModelInterface model = new BasicIfcModel(packageMetaData, null);
        session.getMap(model, new OldQuery(packageMetaData, concreteRevision.getProject().getId(), concreteRevision.getId(), -1));
        User user = session.get(getAuthorization().getUoid(), OldQuery.getDefault());
        UserSettings userSettings = user.getUserSettings();
        RenderEnginePluginConfiguration defaultRenderEngine = userSettings.getDefaultRenderEngine();
        if (defaultRenderEngine == null) {
            throw new BimBotsException("No default render engine has been selected for this user");
        }
        RenderEnginePool pool = getBimServer().getRenderEnginePools().getRenderEnginePool(model.getPackageMetaData().getSchema(), defaultRenderEngine.getPluginDescriptor().getPluginClassName(), new PluginConfiguration(defaultRenderEngine.getSettings()));
        new GeometryGenerator(getBimServer()).generateGeometry(pool, getBimServer().getPluginManager(), session, model, concreteRevision.getProject().getId(), concreteRevision.getId(), true, null);
        session.commit();
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : User(org.bimserver.models.store.User) RenderEnginePool(org.bimserver.renderengine.RenderEnginePool) DatabaseSession(org.bimserver.database.DatabaseSession) PackageMetaData(org.bimserver.emf.PackageMetaData) IfcModelInterface(org.bimserver.emf.IfcModelInterface) UserSettings(org.bimserver.models.store.UserSettings) GeometryGenerator(org.bimserver.GeometryGenerator) BimBotsException(org.bimserver.bimbots.BimBotsException) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) UserException(org.bimserver.shared.exceptions.UserException) BimBotsException(org.bimserver.bimbots.BimBotsException) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) OldQuery(org.bimserver.database.OldQuery) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) PluginConfiguration(org.bimserver.plugins.PluginConfiguration)

Example 22 with ConcreteRevision

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

the class BimServer method cleanupStaleData.

private void cleanupStaleData() throws BimserverDatabaseException {
    long s = System.nanoTime();
    try (DatabaseSession session = bimDatabase.createSession()) {
        for (Project project : session.getAll(Project.class)) {
            int recordsRemoved = 0;
            if (project.getName().equals("INT-Store")) {
                continue;
            }
            if (project.getRevisions().size() == 0) {
                recordsRemoved += checkPidRid(session, project, project.getId(), 0);
            } else {
                ConcreteRevision lastConcreteRevision = project.getLastConcreteRevision();
                if (lastConcreteRevision != null) {
                    recordsRemoved += checkPidRid(session, project, project.getId(), lastConcreteRevision.getId());
                }
            }
            if (recordsRemoved > 0) {
                LOGGER.info("Removed " + recordsRemoved + " stale records for project " + project.getName());
            }
        }
    }
    long e = System.nanoTime();
    LOGGER.info("Checking for stale records took " + ((e - s) / 1000000) + " ms");
}
Also used : Project(org.bimserver.models.store.Project) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) DatabaseSession(org.bimserver.database.DatabaseSession)

Aggregations

ConcreteRevision (org.bimserver.models.store.ConcreteRevision)22 Revision (org.bimserver.models.store.Revision)19 UserException (org.bimserver.shared.exceptions.UserException)18 PackageMetaData (org.bimserver.emf.PackageMetaData)11 OldQuery (org.bimserver.database.OldQuery)10 IfcModelInterface (org.bimserver.emf.IfcModelInterface)10 Project (org.bimserver.models.store.Project)10 User (org.bimserver.models.store.User)9 IfcModelSet (org.bimserver.plugins.IfcModelSet)8 ModelHelper (org.bimserver.plugins.ModelHelper)8 MergeException (org.bimserver.plugins.modelmerger.MergeException)8 HashMap (java.util.HashMap)7 IfcModel (org.bimserver.ifc.IfcModel)7 Date (java.util.Date)6 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)6 GeometryGeneratingException (org.bimserver.GeometryGeneratingException)5 IdEObject (org.bimserver.emf.IdEObject)5 BasicIfcModel (org.bimserver.ifc.BasicIfcModel)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 GenerateGeometryResult (org.bimserver.GenerateGeometryResult)4