use of eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ValueType in project hale by halestudio.
the class ProjectToJaxb method toIOConfigurationType.
/**
* Converts an I/O configuration to its JAXB representation.
*
* @param config the I/O configuration
* @return the JAXB representation
*/
public static IOConfigurationType toIOConfigurationType(IOConfiguration config) {
if (config == null) {
return null;
}
IOConfigurationType result = new IOConfigurationType();
result.setActionId(config.getActionId());
result.setProviderId(config.getProviderId());
for (Entry<String, Value> setting : config.getProviderConfiguration().entrySet()) {
Object property = createProperty(setting.getKey(), setting.getValue());
if (property instanceof PropertyType) {
result.getAbstractSetting().add(of.createSetting((PropertyType) property));
} else if (property instanceof ComplexPropertyType) {
result.getAbstractSetting().add(of.createComplexSetting((ComplexPropertyType) property));
}
}
// cache
Value cache = config.getCache();
if (cache != null && cache.getValue() != null) {
ValueType value = new ValueType();
if (cache.isRepresentedAsDOM()) {
value.setAny(cache.getDOMRepresentation());
} else {
value.setValue(cache.getStringRepresentation());
}
result.setCache(value);
}
return result;
}
use of eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ValueType in project hale by halestudio.
the class JaxbToProject method toIOConfiguration.
/**
* Convert a JAXB representation to an {@link IOConfiguration}.
*
* @param config the JAXB representation
* @return the I/O configuration
*/
public static IOConfiguration toIOConfiguration(IOConfigurationType config) {
if (config == null) {
return null;
}
IOConfiguration result = new IOConfiguration();
result.setActionId(config.getActionId());
result.setProviderId(config.getProviderId());
for (JAXBElement<?> setting : config.getAbstractSetting()) {
Object value = setting.getValue();
if (value instanceof PropertyType) {
addProperty(result.getProviderConfiguration(), (PropertyType) value);
} else if (value instanceof ComplexPropertyType) {
addProperty(result.getProviderConfiguration(), (ComplexPropertyType) value);
}
}
// cache
ValueType cache = config.getCache();
if (cache != null) {
Value value = Value.NULL;
if (cache.getAny() != null) {
value = new ElementValue(cache.getAny(), null);
} else if (cache.getValue() != null) {
value = Value.of(cache.getValue());
}
result.setCache(value);
}
return result;
}
Aggregations