Search in sources :

Example 11 with BasicIfcModel

use of org.bimserver.ifc.BasicIfcModel 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(OperationType.POSSIBLY_WRITE);
    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", BimBotDefaultErrorCode.NO_RENDER_ENGINE);
        }
        RenderEnginePool pool = getBimServer().getRenderEnginePools().getRenderEnginePool(model.getPackageMetaData().getSchema(), defaultRenderEngine.getPluginDescriptor().getPluginClassName(), getBimServer().getPluginSettingsCache().getPluginSettings(defaultRenderEngine.getOid()));
        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)

Aggregations

BasicIfcModel (org.bimserver.ifc.BasicIfcModel)11 IfcModelInterface (org.bimserver.emf.IfcModelInterface)9 PackageMetaData (org.bimserver.emf.PackageMetaData)8 OldQuery (org.bimserver.database.OldQuery)7 UserException (org.bimserver.shared.exceptions.UserException)7 ModelHelper (org.bimserver.plugins.ModelHelper)6 IfcModel (org.bimserver.ifc.IfcModel)5 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)5 Revision (org.bimserver.models.store.Revision)5 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)4 IfcModelSet (org.bimserver.plugins.IfcModelSet)4 MergeException (org.bimserver.plugins.modelmerger.MergeException)4 DatabaseSession (org.bimserver.database.DatabaseSession)3 IdEObject (org.bimserver.emf.IdEObject)3 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)3 Project (org.bimserver.models.store.Project)3 User (org.bimserver.models.store.User)3 Serializer (org.bimserver.plugins.serializers.Serializer)3 SerializerPlugin (org.bimserver.plugins.serializers.SerializerPlugin)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2