Search in sources :

Example 31 with UserSettings

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

the class PluginServiceImpl method getAllDeserializersForProject.

@Override
public List<SDeserializerPluginConfiguration> getAllDeserializersForProject(Boolean onlyEnabled, Long poid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        Project project = session.get(poid, OldQuery.getDefault());
        UserSettings userSettings = getUserSettings(session);
        EList<DeserializerPluginConfiguration> deserializers = userSettings.getDeserializers();
        List<SDeserializerPluginConfiguration> sDeserializers = new ArrayList<SDeserializerPluginConfiguration>();
        for (DeserializerPluginConfiguration deserializerPluginConfiguration : deserializers) {
            DeserializerPlugin plugin = getBimServer().getPluginManager().getDeserializerPlugin(deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
            if (plugin == null) {
                StreamingDeserializerPlugin streamingPlugin = getBimServer().getPluginManager().getStreamingDeserializerPlugin(deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
                if (streamingPlugin != null) {
                    if (streamingPlugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
                        if (!onlyEnabled || (deserializerPluginConfiguration.getEnabled() && deserializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
                            sDeserializers.add(getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration));
                        }
                    }
                }
            } else {
                if (plugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
                    if (!onlyEnabled || (deserializerPluginConfiguration.getEnabled() && deserializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
                        sDeserializers.add(getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration));
                    }
                }
            }
        }
        Collections.sort(sDeserializers, new SPluginConfigurationComparator());
        return sDeserializers;
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
    return null;
}
Also used : SPluginConfigurationComparator(org.bimserver.webservices.SPluginConfigurationComparator) Project(org.bimserver.models.store.Project) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) ArrayList(java.util.ArrayList) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 32 with UserSettings

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

the class PluginServiceImpl method getDefaultModelMerger.

public SModelMergerPluginConfiguration getDefaultModelMerger() throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings settings = getUserSettings(session);
        return getBimServer().getSConverter().convertToSObject(settings.getDefaultModelMerger());
    } 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 33 with UserSettings

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

the class PluginServiceImpl method getAllSerializersForPoids.

@Override
public List<SSerializerPluginConfiguration> getAllSerializersForPoids(Boolean onlyEnabled, Set<Long> poids) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        Set<Schema> uniqueSchemas = new HashSet<>();
        for (Long poid : poids) {
            Project project = session.get(poid, OldQuery.getDefault());
            uniqueSchemas.add(Schema.valueOf(project.getSchema().toUpperCase()));
        }
        Set<Schema> schemaOr = new HashSet<>();
        if (uniqueSchemas.size() == 0) {
        // Weird, no schemas
        } else if (uniqueSchemas.size() == 1) {
            // Easy, just add it, and see if there are converter targets and add those too
            Schema schema = uniqueSchemas.iterator().next();
            schemaOr.add(schema);
            // TODO make recursive
            for (Schema target : getBimServer().getSchemaConverterManager().getSchemaTargets(schema)) {
                schemaOr.add(target);
            }
        } else if (uniqueSchemas.size() == 2) {
            // This is harder, if we have 2 schema, we must figure out a way to convert to 1 schema, and then filter the allowed source schemas
            Iterator<Schema> iterator = uniqueSchemas.iterator();
            Schema schema1 = iterator.next();
            Schema schema2 = iterator.next();
            SchemaConverterFactory converter1 = getBimServer().getSchemaConverterManager().getSchemaConverterFactory(schema1, schema2);
            SchemaConverterFactory converter2 = getBimServer().getSchemaConverterManager().getSchemaConverterFactory(schema2, schema1);
            if (converter1 != null) {
                schemaOr.add(schema1);
            }
            if (converter2 != null) {
                schemaOr.add(schema2);
            }
        } else {
            throw new ServerException("Unimplemented, no support for > 2 schemas");
        }
        UserSettings userSettings = getUserSettings(session);
        List<SSerializerPluginConfiguration> sSerializers = new ArrayList<SSerializerPluginConfiguration>();
        for (SerializerPluginConfiguration serializerPluginConfiguration : userSettings.getSerializers()) {
            Plugin plugin = getBimServer().getPluginManager().getPlugin(serializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
            if (plugin instanceof SerializerPlugin) {
                SerializerPlugin serializerPlugin = getBimServer().getPluginManager().getSerializerPlugin(serializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
                for (Schema schema : serializerPlugin.getSupportedSchemas()) {
                    if (schemaOr.contains(schema)) {
                        if (!onlyEnabled || (serializerPluginConfiguration.getEnabled() && serializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
                            sSerializers.add(getBimServer().getSConverter().convertToSObject(serializerPluginConfiguration));
                            break;
                        }
                    }
                }
            } else if (plugin instanceof StreamingSerializerPlugin) {
                StreamingSerializerPlugin streamingSerializerPlugin = (StreamingSerializerPlugin) plugin;
                for (Schema schema : streamingSerializerPlugin.getSupportedSchemas()) {
                    if (schemaOr.contains(schema)) {
                        if (!onlyEnabled || (serializerPluginConfiguration.getEnabled() && serializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
                            sSerializers.add(getBimServer().getSConverter().convertToSObject(serializerPluginConfiguration));
                            break;
                        }
                    }
                }
            }
        }
        Collections.sort(sSerializers, new SPluginConfigurationComparator());
        return sSerializers;
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
    return null;
}
Also used : ServerException(org.bimserver.shared.exceptions.ServerException) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) Schema(org.bimserver.emf.Schema) ArrayList(java.util.ArrayList) StreamingSerializerPlugin(org.bimserver.plugins.serializers.StreamingSerializerPlugin) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) StreamingSerializerPlugin(org.bimserver.plugins.serializers.StreamingSerializerPlugin) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException) SPluginConfigurationComparator(org.bimserver.webservices.SPluginConfigurationComparator) Project(org.bimserver.models.store.Project) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) HashSet(java.util.HashSet) SchemaConverterFactory(org.bimserver.schemaconverter.SchemaConverterFactory) ModelCheckerPlugin(org.bimserver.plugins.modelchecker.ModelCheckerPlugin) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) ModelComparePlugin(org.bimserver.plugins.modelcompare.ModelComparePlugin) ObjectIDMPlugin(org.bimserver.plugins.objectidms.ObjectIDMPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) ServicePlugin(org.bimserver.plugins.services.ServicePlugin) WebModulePlugin(org.bimserver.plugins.web.WebModulePlugin) RenderEnginePlugin(org.bimserver.plugins.renderengine.RenderEnginePlugin) StreamingSerializerPlugin(org.bimserver.plugins.serializers.StreamingSerializerPlugin) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) QueryEnginePlugin(org.bimserver.plugins.queryengine.QueryEnginePlugin) ModelMergerPlugin(org.bimserver.plugins.modelmerger.ModelMergerPlugin) Plugin(org.bimserver.plugins.Plugin)

Example 34 with UserSettings

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

the class PluginServiceImpl method getAllModelCompares.

@Override
public List<SModelComparePluginConfiguration> getAllModelCompares(Boolean onlyEnabled) throws ServerException, UserException {
    requireAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings userSettings = getUserSettings(session);
        List<SModelComparePluginConfiguration> modelCompares = getBimServer().getSConverter().convertToSListModelComparePluginConfiguration(userSettings.getModelCompares());
        Collections.sort(modelCompares, new SPluginConfigurationComparator());
        return modelCompares;
    } 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) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 35 with UserSettings

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

the class PluginServiceImpl method getAllObjectIDMs.

@Override
public List<SObjectIDMPluginConfiguration> getAllObjectIDMs(Boolean onlyEnabled) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings userSettings = getUserSettings(session);
        List<SObjectIDMPluginConfiguration> objectIdms = getBimServer().getSConverter().convertToSListObjectIDMPluginConfiguration(userSettings.getObjectIDMs());
        Collections.sort(objectIdms, new SPluginConfigurationComparator());
        return objectIdms;
    } 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) SObjectIDMPluginConfiguration(org.bimserver.interfaces.objects.SObjectIDMPluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

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