Search in sources :

Example 1 with ObjectDefinition

use of org.bimserver.models.store.ObjectDefinition 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 ObjectDefinition

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

the class AbstractSerializerPlugin method getSettingsDefinition.

@Override
public ObjectDefinition getSettingsDefinition() {
    ObjectDefinition objectDefinition = StoreFactory.eINSTANCE.createObjectDefinition();
    ParameterDefinition extensionParameter = StoreFactory.eINSTANCE.createParameterDefinition();
    extensionParameter.setIdentifier(EXTENSION);
    extensionParameter.setName(EXTENSION);
    extensionParameter.setDescription("Extension of the downloaded file");
    PrimitiveDefinition stringType = StoreFactory.eINSTANCE.createPrimitiveDefinition();
    stringType.setType(PrimitiveEnum.STRING);
    extensionParameter.setType(stringType);
    StringType defaultExtensionValue = StoreFactory.eINSTANCE.createStringType();
    defaultExtensionValue.setValue(getDefaultExtension());
    extensionParameter.setDefaultValue(defaultExtensionValue);
    objectDefinition.getParameters().add(extensionParameter);
    ParameterDefinition contentTypeParameter = StoreFactory.eINSTANCE.createParameterDefinition();
    contentTypeParameter.setIdentifier(CONTENT_TYPE);
    contentTypeParameter.setName(CONTENT_TYPE);
    contentTypeParameter.setDescription("Content-Type in the HTTP header of the downloaded file");
    contentTypeParameter.setType(stringType);
    StringType defaultContentTypeValue = StoreFactory.eINSTANCE.createStringType();
    defaultContentTypeValue.setValue(getDefaultContentType());
    contentTypeParameter.setDefaultValue(defaultContentTypeValue);
    objectDefinition.getParameters().add(contentTypeParameter);
    return objectDefinition;
}
Also used : StringType(org.bimserver.models.store.StringType) ObjectDefinition(org.bimserver.models.store.ObjectDefinition) PrimitiveDefinition(org.bimserver.models.store.PrimitiveDefinition) ParameterDefinition(org.bimserver.models.store.ParameterDefinition)

Example 3 with ObjectDefinition

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

the class AbstractWebModulePlugin method getSettingsDefinition.

@Override
public ObjectDefinition getSettingsDefinition() {
    ObjectDefinition objectDefinition = StoreFactory.eINSTANCE.createObjectDefinition();
    PrimitiveDefinition stringDefinition = StoreFactory.eINSTANCE.createPrimitiveDefinition();
    stringDefinition.setType(PrimitiveEnum.STRING);
    ParameterDefinition contextPathParameter = StoreFactory.eINSTANCE.createParameterDefinition();
    contextPathParameter.setIdentifier("contextPath");
    contextPathParameter.setName("contextPath");
    contextPathParameter.setDescription("Context Path to run this Web Module on");
    StringType defaultValue = StoreFactory.eINSTANCE.createStringType();
    defaultValue.setValue(getDefaultContextPath());
    contextPathParameter.setDefaultValue(defaultValue);
    contextPathParameter.setType(stringDefinition);
    objectDefinition.getParameters().add(contextPathParameter);
    return objectDefinition;
}
Also used : StringType(org.bimserver.models.store.StringType) ObjectDefinition(org.bimserver.models.store.ObjectDefinition) PrimitiveDefinition(org.bimserver.models.store.PrimitiveDefinition) ParameterDefinition(org.bimserver.models.store.ParameterDefinition)

Example 4 with ObjectDefinition

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

the class PluginServiceImpl method getPluginObjectDefinition.

@Override
public SObjectDefinition getPluginObjectDefinition(Long oid) throws ServerException, UserException {
    if (oid == -1) {
        return null;
    }
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        PluginDescriptor pluginDescriptor = session.get(oid, OldQuery.getDefault());
        if (pluginDescriptor == null) {
            throw new UserException("No PluginDescriptor found with oid " + oid);
        }
        Plugin plugin = getBimServer().getPluginManager().getPlugin(pluginDescriptor.getPluginClassName(), false);
        if (plugin == null) {
            throw new UserException("No plugin with class name " + pluginDescriptor.getPluginClassName() + " found");
        }
        ObjectDefinition settingsDefinition = plugin.getSettingsDefinition();
        return getBimServer().getSConverter().convertToSObject(settingsDefinition);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SObjectIDMPluginDescriptor(org.bimserver.interfaces.objects.SObjectIDMPluginDescriptor) PluginDescriptor(org.bimserver.models.store.PluginDescriptor) SPluginDescriptor(org.bimserver.interfaces.objects.SPluginDescriptor) DatabaseSession(org.bimserver.database.DatabaseSession) SObjectDefinition(org.bimserver.interfaces.objects.SObjectDefinition) ObjectDefinition(org.bimserver.models.store.ObjectDefinition) UserException(org.bimserver.shared.exceptions.UserException) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException) 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)

Aggregations

ObjectDefinition (org.bimserver.models.store.ObjectDefinition)4 ParameterDefinition (org.bimserver.models.store.ParameterDefinition)3 StringType (org.bimserver.models.store.StringType)3 PrimitiveDefinition (org.bimserver.models.store.PrimitiveDefinition)2 IOException (java.io.IOException)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 SObjectDefinition (org.bimserver.interfaces.objects.SObjectDefinition)1 SObjectIDMPluginDescriptor (org.bimserver.interfaces.objects.SObjectIDMPluginDescriptor)1 SPluginDescriptor (org.bimserver.interfaces.objects.SPluginDescriptor)1 BooleanType (org.bimserver.models.store.BooleanType)1 DoubleType (org.bimserver.models.store.DoubleType)1 LongType (org.bimserver.models.store.LongType)1 ObjectType (org.bimserver.models.store.ObjectType)1 Parameter (org.bimserver.models.store.Parameter)1 PluginBundleType (org.bimserver.models.store.PluginBundleType)1 PluginDescriptor (org.bimserver.models.store.PluginDescriptor)1 Type (org.bimserver.models.store.Type)1 Plugin (org.bimserver.plugins.Plugin)1 DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)1