Search in sources :

Example 6 with ObjectType

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

the class AddInternalServiceDatabaseAction method execute.

@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    User user = getDatabaseSession().get(StorePackage.eINSTANCE.getUser(), authorization.getUoid(), OldQuery.getDefault());
    InternalServicePluginConfiguration idEObject = getIdEObject();
    idEObject.setUserSettings(user.getUserSettings());
    Plugin plugin = bimServer.getPluginManager().getPlugin(idEObject.getPluginDescriptor().getIdentifier(), true);
    ObjectType settings = bimServer.convertSettings(getDatabaseSession(), plugin);
    user.getUserSettings().getServices().add(idEObject);
    idEObject.setSettings(settings);
    getDatabaseSession().store(user.getUserSettings());
    return super.execute();
}
Also used : ObjectType(org.bimserver.models.store.ObjectType) User(org.bimserver.models.store.User) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) Plugin(org.bimserver.plugins.Plugin)

Example 7 with ObjectType

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

the class SerializerFactory method create.

public Serializer create(Project project, String username, IfcModelInterface model, RenderEnginePlugin renderEnginePlugin, DownloadParameters downloadParameters) throws SerializerException {
    DatabaseSession session = bimDatabase.createSession();
    try {
        SerializerPluginConfiguration serializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getSerializerPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
        if (serializerPluginConfiguration != null) {
            SerializerPlugin serializerPlugin = (SerializerPlugin) pluginManager.getPlugin(serializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
            if (serializerPlugin != null) {
                ObjectType settings = serializerPluginConfiguration.getSettings();
                Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration(settings));
                if (!serializerPlugin.getSupportedSchemas().contains(model.getPackageMetaData().getSchema())) {
                    SchemaConverterFactory converterFactory = null;
                    for (Schema schema : serializerPlugin.getSupportedSchemas()) {
                        converterFactory = bimServer.getSchemaConverterManager().getSchemaConverterFactory(model.getPackageMetaData().getSchema(), schema);
                        if (converterFactory != null) {
                            break;
                        }
                    }
                    if (converterFactory == null) {
                        throw new SerializerException("No usable converter found for schema " + model.getPackageMetaData().getSchema() + " for serializer " + serializerPlugin.getClass().getName());
                    }
                    try {
                        IfcModel targetModel = new BasicIfcModel(bimServer.getMetaDataManager().getPackageMetaData(converterFactory.getTargetSchema().getEPackageName()), new HashMap<Integer, Long>(), (int) model.size());
                        SchemaConverter converter = converterFactory.create(model, targetModel);
                        converter.convert();
                        model = targetModel;
                    } catch (SchemaConverterException e) {
                        throw new SerializerException(e);
                    } catch (IfcModelInterfaceException e) {
                        throw new SerializerException(e);
                    }
                }
                if (serializer != null) {
                    try {
                        ProjectInfo projectInfo = new ProjectInfo();
                        projectInfo.setName(project.getName());
                        projectInfo.setDescription(project.getDescription());
                        GeoTag geoTag = project.getGeoTag();
                        if (geoTag != null && geoTag.getEnabled()) {
                            projectInfo.setX(geoTag.getX());
                            projectInfo.setY(geoTag.getY());
                            projectInfo.setZ(geoTag.getZ());
                            projectInfo.setDirectionAngle(geoTag.getDirectionAngle());
                        } else {
                            projectInfo.setX(4.8900);
                            projectInfo.setY(52.3700);
                        }
                        projectInfo.setAuthorName(username);
                        serializer.init(model, projectInfo, true);
                        return serializer;
                    } catch (NullPointerException e) {
                        LOGGER.error("", e);
                    }
                }
            }
        }
    } catch (BimserverDatabaseException e) {
        LOGGER.error("", e);
    } finally {
        session.close();
    }
    return null;
}
Also used : GeoTag(org.bimserver.models.store.GeoTag) DatabaseSession(org.bimserver.database.DatabaseSession) Schema(org.bimserver.emf.Schema) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) MessagingSerializerPlugin(org.bimserver.plugins.serializers.MessagingSerializerPlugin) SerializerException(org.bimserver.plugins.serializers.SerializerException) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) ObjectType(org.bimserver.models.store.ObjectType) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) IfcModel(org.bimserver.ifc.IfcModel) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SchemaConverterException(org.bimserver.schemaconverter.SchemaConverterException) ProjectInfo(org.bimserver.plugins.serializers.ProjectInfo) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) SchemaConverter(org.bimserver.schemaconverter.SchemaConverter) MessagingSerializer(org.bimserver.plugins.serializers.MessagingSerializer) Serializer(org.bimserver.plugins.serializers.Serializer) SchemaConverterFactory(org.bimserver.schemaconverter.SchemaConverterFactory)

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