use of org.bimserver.database.query.conditions.Condition in project BIMserver by opensourceBIM.
the class GetAllQueryEnginesDatabaseAction method execute.
@Override
public List<QueryEnginePluginConfiguration> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Condition condition = new IsOfTypeCondition(StorePackage.eINSTANCE.getQueryEnginePluginConfiguration());
Map<Long, QueryEnginePluginConfiguration> result = getDatabaseSession().query(condition, QueryEnginePluginConfiguration.class, OldQuery.getDefault());
List<QueryEnginePluginConfiguration> mapToList = CollectionUtils.mapToList(result);
if (onlyEnabled) {
Iterator<QueryEnginePluginConfiguration> iterator = mapToList.iterator();
while (iterator.hasNext()) {
QueryEnginePluginConfiguration queryEngine = iterator.next();
if (!bimServer.getPluginManager().isEnabled(queryEngine.getPluginDescriptor().getPluginClassName()) || !queryEngine.getEnabled()) {
iterator.remove();
}
}
}
return mapToList;
}
use of org.bimserver.database.query.conditions.Condition in project BIMserver by opensourceBIM.
the class GetAllRenderEnginesDatabaseAction method execute.
@Override
public List<RenderEnginePluginConfiguration> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Condition condition = new IsOfTypeCondition(StorePackage.eINSTANCE.getRenderEnginePluginConfiguration());
Map<Long, RenderEnginePluginConfiguration> result = getDatabaseSession().query(condition, RenderEnginePluginConfiguration.class, OldQuery.getDefault());
List<RenderEnginePluginConfiguration> mapToList = CollectionUtils.mapToList(result);
if (onlyEnabled) {
Iterator<RenderEnginePluginConfiguration> iterator = mapToList.iterator();
while (iterator.hasNext()) {
RenderEnginePluginConfiguration renderEngine = iterator.next();
if (!bimServer.getPluginManager().isEnabled(renderEngine.getPluginDescriptor().getPluginClassName()) || !renderEngine.getEnabled()) {
iterator.remove();
}
}
}
return mapToList;
}
use of org.bimserver.database.query.conditions.Condition in project BIMserver by opensourceBIM.
the class GetAllSerializersDatabaseAction method execute.
@Override
public List<SerializerPluginConfiguration> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Condition condition = new IsOfTypeCondition(StorePackage.eINSTANCE.getSerializerPluginConfiguration());
Map<Long, SerializerPluginConfiguration> result = getDatabaseSession().query(condition, SerializerPluginConfiguration.class, OldQuery.getDefault());
List<SerializerPluginConfiguration> mapToList = CollectionUtils.mapToList(result);
if (onlyEnabled) {
Iterator<SerializerPluginConfiguration> iterator = mapToList.iterator();
while (iterator.hasNext()) {
SerializerPluginConfiguration serializer = iterator.next();
if (!bimServer.getPluginManager().isEnabled(serializer.getPluginDescriptor().getPluginClassName()) || !serializer.getEnabled()) {
iterator.remove();
}
}
}
return mapToList;
}
use of org.bimserver.database.query.conditions.Condition in project BIMserver by opensourceBIM.
the class GetAllUsersDatabaseAction method execute.
@Override
public Set<User> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User actingUser = getUserByUoid(authorization.getUoid());
Condition condition = new IsOfTypeCondition(StorePackage.eINSTANCE.getUser());
condition = condition.and(new Not(new AttributeCondition(StorePackage.eINSTANCE.getUser_UserType(), new EnumLiteral(UserType.SYSTEM))));
if (actingUser.getUserType() != UserType.ADMIN) {
condition = condition.and(new AttributeCondition(StorePackage.eINSTANCE.getUser_State(), new EnumLiteral(ObjectState.ACTIVE)));
}
return CollectionUtils.mapToSet(getDatabaseSession().query(condition, User.class, OldQuery.getDefault()));
}
use of org.bimserver.database.query.conditions.Condition in project BIMserver by opensourceBIM.
the class BimServer method initDatabaseDependantItems.
private void initDatabaseDependantItems() throws BimserverDatabaseException {
notificationsManager.init();
getSerializerFactory().init(pluginManager, bimDatabase, this);
try {
DatabaseSession session = bimDatabase.createSession();
try {
updatePlugins(session);
session.commit();
} catch (ServiceException e) {
LOGGER.error("", e);
} finally {
session.close();
}
session = bimDatabase.createSession();
// createDatabaseObjects(session);
ServerSettings serverSettings = serverSettingsCache.getServerSettings();
for (Entry<PluginContext, WebModulePlugin> entry : pluginManager.getAllWebPlugins(true).entrySet()) {
WebModulePluginConfiguration webPluginConfiguration = find(serverSettings.getWebModules(), entry.getKey().getIdentifier());
if (webPluginConfiguration == null) {
webPluginConfiguration = session.create(WebModulePluginConfiguration.class);
serverSettings.getWebModules().add(webPluginConfiguration);
PluginDescriptor pluginDescriptor = getPluginDescriptor(session, entry.getKey().getIdentifier());
if (pluginDescriptor == null) {
throw new BimserverDatabaseException("No plugin descriptor found: " + entry.getKey().getIdentifier());
}
genericPluginConversion(entry.getKey(), session, webPluginConfiguration, pluginDescriptor);
} else {
if (webPluginConfiguration == serverSettings.getWebModule()) {
setDefaultWebModule(entry.getValue());
}
}
}
// Set the default
// if (serverSettings.getWebModule() == null) {
// WebModulePluginConfiguration bimviewsWebModule = findWebModule(serverSettings, "BIM Views");
// if (bimviewsWebModule != null) {
// serverSettings.setWebModule(bimviewsWebModule);
// setDefaultWebModule(pluginManager.getWebModulePlugin(bimviewsWebModule.getPluginDescriptor().getPluginClassName(), true));
// } else {
// WebModulePluginConfiguration defaultWebModule = findWebModule(serverSettings, "org.bimserver.defaultwebmodule.DefaultWebModulePlugin");
// if (defaultWebModule != null) {
// serverSettings.setWebModule(defaultWebModule);
// setDefaultWebModule(pluginManager.getWebModulePlugin(defaultWebModule.getPluginDescriptor().getPluginClassName(), true));
// }
// }
// }
session.store(serverSettings);
Condition condition = new AttributeCondition(StorePackage.eINSTANCE.getUser_Username(), new StringLiteral("system"));
User systemUser = session.querySingle(condition, User.class, OldQuery.getDefault());
ServerStarted serverStarted = session.create(ServerStarted.class);
serverStarted.setDate(new Date());
serverStarted.setAccessMethod(AccessMethod.INTERNAL);
serverStarted.setExecutor(systemUser);
try {
session.store(serverStarted);
session.commit();
} catch (BimserverLockConflictException e) {
throw new BimserverDatabaseException(e);
} catch (ServiceException e) {
throw new BimserverDatabaseException(e);
} finally {
session.close();
}
webModules = new HashMap<String, WebModulePlugin>();
DatabaseSession ses = bimDatabase.createSession();
try {
List<WebModulePluginConfiguration> webModuleConfigurations = serverSettingsCache.getServerSettings().getWebModules();
for (WebModulePluginConfiguration webModulePluginConfiguration : webModuleConfigurations) {
String contextPath = "";
for (Parameter parameter : webModulePluginConfiguration.getSettings().getParameters()) {
if (parameter.getName().equals("contextPath")) {
contextPath = ((StringType) parameter.getValue()).getValue();
}
}
String identifier = webModulePluginConfiguration.getPluginDescriptor().getIdentifier();
webModules.put(contextPath, (WebModulePlugin) pluginManager.getPlugin(identifier, true));
}
// if (serverSettingsCache.getServerSettings().getWebModule() !=
// null) {
// defaultWebModule = (WebModulePlugin)
// pluginManager.getPlugin(serverSettingsCache.getServerSettings().getWebModule().getPluginDescriptor().getPluginClassName(),
// true);
// }
} finally {
ses.close();
}
Integer protocolBuffersPort = getServerSettingsCache().getServerSettings().getProtocolBuffersPort();
if (protocolBuffersPort >= 1 && protocolBuffersPort <= 65535) {
try {
protocolBuffersServer = new ProtocolBuffersServer(protocolBuffersMetaData, serviceFactory, servicesMap, protocolBuffersPort);
protocolBuffersServer.start();
} catch (Exception e) {
LOGGER.error("", e);
}
}
bimServerClientFactory = new DirectBimServerClientFactory<ServiceInterface>(serverSettingsCache.getServerSettings().getSiteAddress(), serviceFactory, servicesMap, pluginManager, metaDataManager);
pluginManager.setBimServerClientFactory(bimServerClientFactory);
try (DatabaseSession session2 = bimDatabase.createSession()) {
IfcModelInterface pluginBundleVersions = session2.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(), OldQuery.getDefault());
for (PluginBundleVersion pluginBundleVersion : pluginBundleVersions.getAll(PluginBundleVersion.class)) {
if (pluginBundleVersion.getType() == PluginBundleType.MAVEN || pluginBundleVersion.getType() == PluginBundleType.LOCAL) {
PluginBundleVersionIdentifier pluginBundleVersionIdentifier = new PluginBundleVersionIdentifier(pluginBundleVersion.getGroupId(), pluginBundleVersion.getArtifactId(), pluginBundleVersion.getVersion());
IfcModelInterface pluginDescriptors = session2.getAllOfType(StorePackage.eINSTANCE.getPluginDescriptor(), OldQuery.getDefault());
List<SPluginInformation> plugins = new ArrayList<>();
for (PluginDescriptor pluginDescriptor : pluginDescriptors.getAll(PluginDescriptor.class)) {
if (pluginDescriptor.getPluginBundleVersion() == pluginBundleVersion && pluginDescriptor.getEnabled()) {
SPluginInformation sPluginInformation = new SPluginInformation();
sPluginInformation.setEnabled(true);
sPluginInformation.setDescription(pluginDescriptor.getDescription());
sPluginInformation.setIdentifier(pluginDescriptor.getIdentifier());
sPluginInformation.setInstallForAllUsers(pluginDescriptor.isInstallForNewUsers());
sPluginInformation.setInstallForNewUsers(pluginDescriptor.isInstallForNewUsers());
sPluginInformation.setName(pluginDescriptor.getName());
sPluginInformation.setType(pluginManager.getPluginTypeFromClass(pluginDescriptor.getPluginClassName()));
plugins.add(sPluginInformation);
}
}
try {
pluginManager.loadFromPluginDir(pluginBundleVersionIdentifier, getSConverter().convertToSObject(pluginBundleVersion), plugins, serverSettingsCache.getServerSettings().isPluginStrictVersionChecking());
} catch (Exception e) {
LOGGER.error("", e);
}
}
}
} catch (Exception e) {
throw new BimserverDatabaseException(e);
}
} catch (BimserverLockConflictException e) {
throw new BimserverDatabaseException(e);
// } catch (PluginException e) {
// throw new BimserverDatabaseException(e);
}
}
Aggregations