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;
}
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;
}
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;
}
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();
}
}
Aggregations