Search in sources :

Example 1 with ObjectType

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

the class BimServer method convertSettings.

public ObjectType convertSettings(DatabaseSession session, Plugin plugin) throws BimserverDatabaseException {
    ObjectType settings = session.create(ObjectType.class);
    ObjectDefinition settingsDefinition = plugin.getSettingsDefinition();
    if (plugin.getSettingsDefinition() != null) {
        for (ParameterDefinition parameterDefinition : settingsDefinition.getParameters()) {
            Parameter parameter = session.create(Parameter.class);
            parameter.setName(parameterDefinition.getName());
            parameter.setIdentifier(parameterDefinition.getIdentifier());
            if (parameterDefinition.getDefaultValue() != null) {
                Type value = cloneAndAdd(session, parameterDefinition.getDefaultValue());
                parameter.setValue(value);
            }
            settings.getParameters().add(parameter);
        }
    }
    return settings;
}
Also used : ObjectType(org.bimserver.models.store.ObjectType) StringType(org.bimserver.models.store.StringType) LongType(org.bimserver.models.store.LongType) PluginBundleType(org.bimserver.models.store.PluginBundleType) DoubleType(org.bimserver.models.store.DoubleType) ObjectType(org.bimserver.models.store.ObjectType) BooleanType(org.bimserver.models.store.BooleanType) Type(org.bimserver.models.store.Type) Parameter(org.bimserver.models.store.Parameter) ObjectDefinition(org.bimserver.models.store.ObjectDefinition) ParameterDefinition(org.bimserver.models.store.ParameterDefinition)

Example 2 with ObjectType

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

the class SerializerFactory method createMessagingSerializer.

public MessagingSerializer createMessagingSerializer(String username, IfcModelInterface model, DownloadParameters downloadParameters) throws SerializerException {
    DatabaseSession session = bimDatabase.createSession();
    try {
        MessagingSerializerPluginConfiguration serializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getMessagingSerializerPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
        if (serializerPluginConfiguration != null) {
            MessagingSerializerPlugin serializerPlugin = (MessagingSerializerPlugin) pluginManager.getPlugin(serializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
            if (serializerPlugin != null) {
                ObjectType settings = serializerPluginConfiguration.getSettings();
                MessagingSerializer serializer = serializerPlugin.createSerializer(new PluginConfiguration(settings));
                if (serializer != null) {
                    try {
                        serializer.init(model, null, pluginManager, model.getPackageMetaData(), true);
                        return serializer;
                    } catch (NullPointerException e) {
                        LOGGER.error("", e);
                    }
                }
            }
        }
    } catch (BimserverDatabaseException e) {
        LOGGER.error("", e);
    } finally {
        session.close();
    }
    return null;
}
Also used : MessagingSerializerPlugin(org.bimserver.plugins.serializers.MessagingSerializerPlugin) MessagingSerializer(org.bimserver.plugins.serializers.MessagingSerializer) ObjectType(org.bimserver.models.store.ObjectType) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration)

Example 3 with ObjectType

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

the class ServiceImpl method checkinInternal.

private Long checkinInternal(Long topicId, final Long poid, final String comment, Long deserializerOid, Long fileSize, String fileName, InputStream originalInputStream, Boolean merge, Boolean sync, final DatabaseSession session, String username, String userUsername, Project project, Path file, long newServiceId) throws BimserverDatabaseException, UserException, IOException, DeserializeException, CannotBeScheduledException {
    if (getBimServer().getCheckinsInProgress().containsKey(poid)) {
        throw new UserException("Checkin in progress on this project, please try again later");
    }
    getBimServer().getCheckinsInProgress().put(poid, getAuthorization().getUoid());
    DeserializerPluginConfiguration deserializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getDeserializerPluginConfiguration(), deserializerOid, OldQuery.getDefault());
    if (deserializerPluginConfiguration == null) {
        throw new UserException("Deserializer with oid " + deserializerOid + " not found");
    } else {
        PluginBundleVersion pluginBundleVersion = deserializerPluginConfiguration.getPluginDescriptor().getPluginBundleVersion();
        Plugin plugin = getBimServer().getPluginManager().getPlugin(deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
        if (plugin != null) {
            if (plugin instanceof DeserializerPlugin) {
                DeserializerPlugin deserializerPlugin = (DeserializerPlugin) plugin;
                ObjectType settings = deserializerPluginConfiguration.getSettings();
                Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration(settings));
                OutputStream outputStream = Files.newOutputStream(file);
                InputStream inputStream = new MultiplexingInputStream(originalInputStream, outputStream);
                deserializer.init(getBimServer().getDatabase().getMetaDataManager().getPackageMetaData(project.getSchema()));
                IfcModelInterface model = null;
                try {
                    model = deserializer.read(inputStream, fileName, fileSize, null);
                } finally {
                    inputStream.close();
                }
                CheckinDatabaseAction checkinDatabaseAction = new CheckinDatabaseAction(getBimServer(), null, getInternalAccessMethod(), poid, getAuthorization(), model, comment, fileName, merge, newServiceId);
                LongCheckinAction longAction = new LongCheckinAction(topicId, getBimServer(), username, userUsername, getAuthorization(), checkinDatabaseAction);
                getBimServer().getLongActionManager().start(longAction);
                if (sync) {
                    longAction.waitForCompletion();
                }
                return longAction.getProgressTopic().getKey().getId();
            } else if (plugin instanceof StreamingDeserializerPlugin) {
                StreamingDeserializerPlugin streaminDeserializerPlugin = (StreamingDeserializerPlugin) plugin;
                ObjectType settings = deserializerPluginConfiguration.getSettings();
                StreamingDeserializer streamingDeserializer = streaminDeserializerPlugin.createDeserializer(new PluginConfiguration(settings));
                streamingDeserializer.init(getBimServer().getDatabase().getMetaDataManager().getPackageMetaData(project.getSchema()));
                RestartableInputStream restartableInputStream = new RestartableInputStream(originalInputStream, file);
                StreamingCheckinDatabaseAction checkinDatabaseAction = new StreamingCheckinDatabaseAction(getBimServer(), null, getInternalAccessMethod(), poid, getAuthorization(), comment, fileName, restartableInputStream, streamingDeserializer, fileSize, newServiceId, pluginBundleVersion);
                LongStreamingCheckinAction longAction = new LongStreamingCheckinAction(topicId, getBimServer(), username, userUsername, getAuthorization(), checkinDatabaseAction);
                getBimServer().getLongActionManager().start(longAction);
                if (sync) {
                    longAction.waitForCompletion();
                }
                return longAction.getProgressTopic().getKey().getId();
            } else {
                throw new UserException("No (enabled) (streaming) deserializer found with oid " + deserializerOid);
            }
        } else {
            throw new UserException("No (enabled) (streaming) deserializer found with oid " + deserializerOid);
        }
    }
}
Also used : MultiplexingInputStream(org.bimserver.utils.MultiplexingInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) MultiplexingInputStream(org.bimserver.utils.MultiplexingInputStream) InputStream(java.io.InputStream) IfcModelInterface(org.bimserver.emf.IfcModelInterface) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) CheckinDatabaseAction(org.bimserver.database.actions.CheckinDatabaseAction) StreamingCheckinDatabaseAction(org.bimserver.database.actions.StreamingCheckinDatabaseAction) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration) StreamingDeserializer(org.bimserver.plugins.deserializers.StreamingDeserializer) ObjectType(org.bimserver.models.store.ObjectType) Deserializer(org.bimserver.plugins.deserializers.Deserializer) StreamingDeserializer(org.bimserver.plugins.deserializers.StreamingDeserializer) LongStreamingCheckinAction(org.bimserver.longaction.LongStreamingCheckinAction) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) LongCheckinAction(org.bimserver.longaction.LongCheckinAction) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SQueryEnginePluginConfiguration(org.bimserver.interfaces.objects.SQueryEnginePluginConfiguration) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException) PluginBundleVersion(org.bimserver.models.store.PluginBundleVersion) StreamingCheckinDatabaseAction(org.bimserver.database.actions.StreamingCheckinDatabaseAction) StreamingSerializerPlugin(org.bimserver.plugins.serializers.StreamingSerializerPlugin) QueryEnginePlugin(org.bimserver.plugins.queryengine.QueryEnginePlugin) MessagingSerializerPlugin(org.bimserver.plugins.serializers.MessagingSerializerPlugin) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) MessagingStreamingSerializerPlugin(org.bimserver.plugins.serializers.MessagingStreamingSerializerPlugin) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) Plugin(org.bimserver.plugins.Plugin)

Example 4 with ObjectType

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

the class PluginServiceImpl method getPluginSettings.

public SObjectType getPluginSettings(Long poid) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        PluginConfiguration pluginConfiguration = session.get(StorePackage.eINSTANCE.getPluginConfiguration(), poid, OldQuery.getDefault());
        ObjectType settings = pluginConfiguration.getSettings();
        return getBimServer().getSConverter().convertToSObject(settings);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SObjectType(org.bimserver.interfaces.objects.SObjectType) ObjectType(org.bimserver.models.store.ObjectType) DatabaseSession(org.bimserver.database.DatabaseSession) SRenderEnginePluginConfiguration(org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration) SObjectIDMPluginConfiguration(org.bimserver.interfaces.objects.SObjectIDMPluginConfiguration) PluginConfiguration(org.bimserver.models.store.PluginConfiguration) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) SQueryEnginePluginConfiguration(org.bimserver.interfaces.objects.SQueryEnginePluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) ModelComparePluginConfiguration(org.bimserver.models.store.ModelComparePluginConfiguration) QueryEnginePluginConfiguration(org.bimserver.models.store.QueryEnginePluginConfiguration) WebModulePluginConfiguration(org.bimserver.models.store.WebModulePluginConfiguration) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration) ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) SWebModulePluginConfiguration(org.bimserver.interfaces.objects.SWebModulePluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) SModelMergerPluginConfiguration(org.bimserver.interfaces.objects.SModelMergerPluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 5 with ObjectType

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

the class PluginServiceImpl method setPluginSettings.

@Override
public void setPluginSettings(Long poid, SObjectType settings) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        ObjectType convertedSettings = getBimServer().getSConverter().convertFromSObject(settings, session);
        SetPluginSettingsDatabaseAction action = new SetPluginSettingsDatabaseAction(session, getInternalAccessMethod(), poid, convertedSettings);
        session.executeAndCommitAction(action);
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
    session = getBimServer().getDatabase().createSession();
    try {
        PluginConfiguration pluginConfiguration = session.get(StorePackage.eINSTANCE.getPluginConfiguration(), poid, OldQuery.getDefault());
        if (pluginConfiguration instanceof InternalServicePluginConfiguration) {
            ServicePlugin servicePlugin = getBimServer().getPluginManager().getServicePlugin(pluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
            SInternalServicePluginConfiguration sInternalService = (SInternalServicePluginConfiguration) getBimServer().getSConverter().convertToSObject(pluginConfiguration);
            servicePlugin.unregister(sInternalService);
            servicePlugin.register(getAuthorization().getUoid(), sInternalService, new org.bimserver.plugins.PluginConfiguration(settings));
        }
    } catch (BimserverDatabaseException e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : SObjectType(org.bimserver.interfaces.objects.SObjectType) ObjectType(org.bimserver.models.store.ObjectType) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) ServicePlugin(org.bimserver.plugins.services.ServicePlugin) SetPluginSettingsDatabaseAction(org.bimserver.database.actions.SetPluginSettingsDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) SRenderEnginePluginConfiguration(org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration) SObjectIDMPluginConfiguration(org.bimserver.interfaces.objects.SObjectIDMPluginConfiguration) PluginConfiguration(org.bimserver.models.store.PluginConfiguration) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) SQueryEnginePluginConfiguration(org.bimserver.interfaces.objects.SQueryEnginePluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) ModelComparePluginConfiguration(org.bimserver.models.store.ModelComparePluginConfiguration) QueryEnginePluginConfiguration(org.bimserver.models.store.QueryEnginePluginConfiguration) WebModulePluginConfiguration(org.bimserver.models.store.WebModulePluginConfiguration) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration) ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) SWebModulePluginConfiguration(org.bimserver.interfaces.objects.SWebModulePluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) SModelMergerPluginConfiguration(org.bimserver.interfaces.objects.SModelMergerPluginConfiguration) 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)

Aggregations

ObjectType (org.bimserver.models.store.ObjectType)7 SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)5 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)4 DatabaseSession (org.bimserver.database.DatabaseSession)4 InternalServicePluginConfiguration (org.bimserver.models.store.InternalServicePluginConfiguration)4 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)3 SQueryEnginePluginConfiguration (org.bimserver.interfaces.objects.SQueryEnginePluginConfiguration)3 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)3 DeserializerPluginConfiguration (org.bimserver.models.store.DeserializerPluginConfiguration)3 PluginConfiguration (org.bimserver.plugins.PluginConfiguration)3 MessagingSerializerPlugin (org.bimserver.plugins.serializers.MessagingSerializerPlugin)3 IOException (java.io.IOException)2 SInternalServicePluginConfiguration (org.bimserver.interfaces.objects.SInternalServicePluginConfiguration)2 SModelComparePluginConfiguration (org.bimserver.interfaces.objects.SModelComparePluginConfiguration)2 SModelMergerPluginConfiguration (org.bimserver.interfaces.objects.SModelMergerPluginConfiguration)2 SObjectIDMPluginConfiguration (org.bimserver.interfaces.objects.SObjectIDMPluginConfiguration)2 SObjectType (org.bimserver.interfaces.objects.SObjectType)2 SRenderEnginePluginConfiguration (org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration)2 SWebModulePluginConfiguration (org.bimserver.interfaces.objects.SWebModulePluginConfiguration)2 MessagingSerializerPluginConfiguration (org.bimserver.models.store.MessagingSerializerPluginConfiguration)2