Search in sources :

Example 6 with DeserializerPluginConfiguration

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

the class PluginServiceImpl method updateDeserializer.

@Override
public void updateDeserializer(SDeserializerPluginConfiguration deserializer) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        DeserializerPluginConfiguration convert = session.get(deserializer.getOid(), OldQuery.getDefault());
        getBimServer().getSConverter().convertFromSObject(deserializer, convert, session);
        session.executeAndCommitAction(new UpdateDeserializerDatabaseAction(session, getInternalAccessMethod(), convert));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration) UpdateDeserializerDatabaseAction(org.bimserver.database.actions.UpdateDeserializerDatabaseAction) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 7 with DeserializerPluginConfiguration

use of org.bimserver.models.store.DeserializerPluginConfiguration 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 8 with DeserializerPluginConfiguration

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

the class DeleteDeserializerDatabaseAction method execute.

@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    DeserializerPluginConfiguration object = getDatabaseSession().get(geteClass(), getOid(), OldQuery.getDefault());
    UserSettings settings = object.getUserSettings();
    settings.getDeserializers().remove(object);
    getDatabaseSession().store(settings);
    return super.execute();
}
Also used : UserSettings(org.bimserver.models.store.UserSettings) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration)

Aggregations

DeserializerPluginConfiguration (org.bimserver.models.store.DeserializerPluginConfiguration)8 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)6 UserException (org.bimserver.shared.exceptions.UserException)6 IOException (java.io.IOException)5 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)5 DatabaseSession (org.bimserver.database.DatabaseSession)5 ServerException (org.bimserver.shared.exceptions.ServerException)5 UserSettings (org.bimserver.models.store.UserSettings)4 ArrayList (java.util.ArrayList)3 DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)3 StreamingDeserializerPlugin (org.bimserver.plugins.deserializers.StreamingDeserializerPlugin)3 Plugin (org.bimserver.plugins.Plugin)2 QueryEnginePlugin (org.bimserver.plugins.queryengine.QueryEnginePlugin)2 MessagingSerializerPlugin (org.bimserver.plugins.serializers.MessagingSerializerPlugin)2 MessagingStreamingSerializerPlugin (org.bimserver.plugins.serializers.MessagingStreamingSerializerPlugin)2 SerializerPlugin (org.bimserver.plugins.serializers.SerializerPlugin)2 StreamingSerializerPlugin (org.bimserver.plugins.serializers.StreamingSerializerPlugin)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1