Search in sources :

Example 26 with UserSettings

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

the class GetSerializerByPluginClassNameDatabaseAction method execute.

@Override
public SerializerPluginConfiguration execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    PluginDescriptor pluginDescriptor = getDatabaseSession().querySingle(StorePackage.eINSTANCE.getPluginDescriptor_PluginClassName(), pluginClassName);
    if (pluginDescriptor == null) {
        throw new UserException("No plugin found with classname " + pluginClassName);
    }
    User user = getUserByUoid(authorization.getUoid());
    UserSettings userSettings = user.getUserSettings();
    for (SerializerPluginConfiguration serializerPluginConfiguration : userSettings.getSerializers()) {
        if (serializerPluginConfiguration.getPluginDescriptor() == pluginDescriptor) {
            return serializerPluginConfiguration;
        }
    }
    throw new UserException("No plugin found for this user with classname " + pluginClassName);
}
Also used : PluginDescriptor(org.bimserver.models.store.PluginDescriptor) User(org.bimserver.models.store.User) UserSettings(org.bimserver.models.store.UserSettings) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException)

Example 27 with UserSettings

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

the class PluginServiceImpl method getAllInternalServices.

@Override
public List<SInternalServicePluginConfiguration> getAllInternalServices(Boolean onlyEnabled) throws UserException, ServerException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings userSettings = getUserSettings(session);
        EList<InternalServicePluginConfiguration> services2 = userSettings.getServices();
        List<SInternalServicePluginConfiguration> services = getBimServer().getSConverter().convertToSListInternalServicePluginConfiguration(services2);
        Collections.sort(services, new SPluginConfigurationComparator());
        return services;
    } 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) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 28 with UserSettings

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

the class PluginServiceImpl method getAllSerializers.

@Override
public List<SSerializerPluginConfiguration> getAllSerializers(Boolean onlyEnabled) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings userSettings = getUserSettings(session);
        List<SSerializerPluginConfiguration> sSerializers = new ArrayList<SSerializerPluginConfiguration>();
        for (SerializerPluginConfiguration serializerPluginConfiguration : userSettings.getSerializers()) {
            if (!onlyEnabled || (serializerPluginConfiguration.getEnabled() && serializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
                sSerializers.add(getBimServer().getSConverter().convertToSObject(serializerPluginConfiguration));
            }
        }
        Collections.sort(sSerializers, new SPluginConfigurationComparator());
        return sSerializers;
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
    return null;
}
Also used : SPluginConfigurationComparator(org.bimserver.webservices.SPluginConfigurationComparator) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) ArrayList(java.util.ArrayList) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 29 with UserSettings

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

the class PluginServiceImpl method getDefaultSerializer.

public SSerializerPluginConfiguration getDefaultSerializer() throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings settings = getUserSettings(session);
        return getBimServer().getSConverter().convertToSObject(settings.getDefaultSerializer());
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 30 with UserSettings

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

the class PluginServiceImpl method getDefaultObjectIDM.

public SObjectIDMPluginConfiguration getDefaultObjectIDM() throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings settings = getUserSettings(session);
        return getBimServer().getSConverter().convertToSObject(settings.getDefaultObjectIDM());
    } catch (BimserverDatabaseException e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings)

Aggregations

UserSettings (org.bimserver.models.store.UserSettings)43 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)29 DatabaseSession (org.bimserver.database.DatabaseSession)29 UserException (org.bimserver.shared.exceptions.UserException)22 IOException (java.io.IOException)18 ServerException (org.bimserver.shared.exceptions.ServerException)18 SPluginConfigurationComparator (org.bimserver.webservices.SPluginConfigurationComparator)10 User (org.bimserver.models.store.User)9 SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)7 ArrayList (java.util.ArrayList)6 SetUserSettingDatabaseAction (org.bimserver.database.actions.SetUserSettingDatabaseAction)6 UserSettingsSetter (org.bimserver.database.actions.UserSettingsSetter)6 InternalServicePluginConfiguration (org.bimserver.models.store.InternalServicePluginConfiguration)5 PluginConfiguration (org.bimserver.plugins.PluginConfiguration)5 IfcModelInterface (org.bimserver.emf.IfcModelInterface)4 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)4 DeserializerPluginConfiguration (org.bimserver.models.store.DeserializerPluginConfiguration)4 RenderEnginePluginConfiguration (org.bimserver.models.store.RenderEnginePluginConfiguration)4 List (java.util.List)3 OldQuery (org.bimserver.database.OldQuery)3