Search in sources :

Example 1 with SRenderEnginePluginConfiguration

use of org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration in project BIMserver by opensourceBIM.

the class PluginServiceImpl method getAllRenderEngines.

@Override
public List<SRenderEnginePluginConfiguration> getAllRenderEngines(Boolean onlyEnabled) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings userSettings = getUserSettings(session);
        List<SRenderEnginePluginConfiguration> renderEngines = getBimServer().getSConverter().convertToSListRenderEnginePluginConfiguration(userSettings.getRenderEngines());
        Collections.sort(renderEngines, new SPluginConfigurationComparator());
        return renderEngines;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SPluginConfigurationComparator(org.bimserver.webservices.SPluginConfigurationComparator) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) SRenderEnginePluginConfiguration(org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 2 with SRenderEnginePluginConfiguration

use of org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration in project BIMserver by opensourceBIM.

the class PluginServiceImpl method updateRenderEngine.

@Override
public void updateRenderEngine(SRenderEnginePluginConfiguration renderEngine) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        RenderEnginePluginConfiguration convert = session.get(renderEngine.getOid(), OldQuery.getDefault());
        getBimServer().getSConverter().convertFromSObject(renderEngine, convert, session);
        session.executeAndCommitAction(new UpdateRenderEngineDatabaseAction(session, getInternalAccessMethod(), convert));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : SRenderEnginePluginConfiguration(org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) UpdateRenderEngineDatabaseAction(org.bimserver.database.actions.UpdateRenderEngineDatabaseAction) 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)

Example 3 with SRenderEnginePluginConfiguration

use of org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration in project BIMserver by opensourceBIM.

the class PluginServiceImpl method addRenderEngine.

@Override
public Long addRenderEngine(SRenderEnginePluginConfiguration renderEngine) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        RenderEnginePluginConfiguration convert = getBimServer().getSConverter().convertFromSObject(renderEngine, session);
        return session.executeAndCommitAction(new AddRenderEngineDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), convert));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SRenderEnginePluginConfiguration(org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) DatabaseSession(org.bimserver.database.DatabaseSession) AddRenderEngineDatabaseAction(org.bimserver.database.actions.AddRenderEngineDatabaseAction) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 4 with SRenderEnginePluginConfiguration

use of org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration in project BIMserver by opensourceBIM.

the class TestIfcEngineEmbedded method main.

public static void main(String[] args) {
    // Create a config
    BimServerConfig config = new BimServerConfig();
    Path home = Paths.get("home");
    // Remove the home dir if it's there
    if (WIPE_HOMEDIR) {
        try {
            PathUtils.removeDirectoryWithContent(home);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    config.setHomeDir(home);
    config.setStartEmbeddedWebServer(true);
    config.setPort(8080);
    config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
    config.setClassPath(System.getProperty("java.class.path"));
    // Create a BIMserver
    BimServer bimServer = new BimServer(config);
    BimServerClientInterface client = null;
    try {
        // Load plugins
        Path[] pluginDirs = new Path[] {// TODO: Set these up yourself...
        };
        LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), pluginDirs);
        // Start it
        bimServer.start();
        // Get a client, not using any protocol (direct connection)
        client = bimServer.getBimServerClientFactory().create();
        // Setup the server
        if (bimServer.getServerInfo().getServerState() == ServerState.NOT_SETUP) {
            client.getAdminInterface().setup("http://localhost:8080", "Administrator", "admin@bimserver.org", "admin", null, null, null);
        }
        // Authenticate
        client.setAuthentication(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Iterate over the IfcEngines and see if there is one matching the classname specified above
        boolean engineFound = false;
        for (SRenderEnginePluginConfiguration conf : client.getPluginInterface().getAllRenderEngines(false)) {
            SPluginDescriptor pluginDescriptor = client.getPluginInterface().getPluginDescriptor(conf.getPluginDescriptorId());
            if (RENDER_ENGINE.equals(pluginDescriptor.getPluginClassName())) {
                client.getPluginInterface().setDefaultRenderEngine(conf.getOid());
                engineFound = true;
                LOGGER.info("Using " + conf.getName());
                break;
            }
        }
        if (!engineFound) {
            throw new RenderEngineException("No IfcEnginePlugin found with name " + RENDER_ENGINE);
        }
        // Get a deserializer
        SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", -1L);
        if (deserializer == null) {
            throw new Exception("No deserializer found for IFC-SPF. Make sure plugin directories are correctly configured");
        }
        Thread[] threads = new Thread[TEST_FILES.length];
        AddProjectCheckinDownloadAction[] contexts = new AddProjectCheckinDownloadAction[TEST_FILES.length];
        for (int i = 0; i < TEST_FILES.length; ++i) {
            (threads[i] = new Thread(contexts[i] = new AddProjectCheckinDownloadAction(bimServer, TEST_FILES[i]))).start();
        }
        for (int i = 0; i < TEST_FILES.length; ++i) {
            threads[i].join();
        }
        for (int i = 0; i < TEST_FILES.length; ++i) {
            contexts[i].verify();
        }
        System.exit(0);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    } finally {
        try {
            client.disconnect();
        } catch (Throwable t) {
        }
        try {
            bimServer.stop();
        } catch (Throwable t) {
        }
    }
}
Also used : Path(java.nio.file.Path) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) SRenderEnginePluginConfiguration(org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration) BimServer(org.bimserver.BimServer) IOException(java.io.IOException) BimServerConfig(org.bimserver.BimServerConfig) LocalDevelopmentResourceFetcher(org.bimserver.shared.LocalDevelopmentResourceFetcher) IOException(java.io.IOException) RenderEngineException(org.bimserver.plugins.renderengine.RenderEngineException) SPluginDescriptor(org.bimserver.interfaces.objects.SPluginDescriptor) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) RenderEngineException(org.bimserver.plugins.renderengine.RenderEngineException)

Aggregations

IOException (java.io.IOException)4 SRenderEnginePluginConfiguration (org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration)4 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)3 DatabaseSession (org.bimserver.database.DatabaseSession)3 ServerException (org.bimserver.shared.exceptions.ServerException)3 UserException (org.bimserver.shared.exceptions.UserException)3 RenderEnginePluginConfiguration (org.bimserver.models.store.RenderEnginePluginConfiguration)2 Path (java.nio.file.Path)1 BimServer (org.bimserver.BimServer)1 BimServerConfig (org.bimserver.BimServerConfig)1 AddRenderEngineDatabaseAction (org.bimserver.database.actions.AddRenderEngineDatabaseAction)1 UpdateRenderEngineDatabaseAction (org.bimserver.database.actions.UpdateRenderEngineDatabaseAction)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)1 SPluginDescriptor (org.bimserver.interfaces.objects.SPluginDescriptor)1 UserSettings (org.bimserver.models.store.UserSettings)1 RenderEngineException (org.bimserver.plugins.renderengine.RenderEngineException)1 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)1 LocalDevelopmentResourceFetcher (org.bimserver.shared.LocalDevelopmentResourceFetcher)1 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)1 SPluginConfigurationComparator (org.bimserver.webservices.SPluginConfigurationComparator)1