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();
}
}
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();
}
}
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();
}
}
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) {
}
}
}
Aggregations