Search in sources :

Example 1 with ValueType

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;
}
Also used : IOConfigurationType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.IOConfigurationType) ComplexPropertyType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ComplexPropertyType) ValueType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ValueType) Value(eu.esdihumboldt.hale.common.core.io.Value) PropertyType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.PropertyType) ComplexPropertyType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ComplexPropertyType)

Example 2 with ValueType

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;
}
Also used : ComplexPropertyType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ComplexPropertyType) IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) ValueType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ValueType) ElementValue(eu.esdihumboldt.hale.common.core.io.impl.ElementValue) Value(eu.esdihumboldt.hale.common.core.io.Value) PropertyType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.PropertyType) ComplexPropertyType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ComplexPropertyType) ElementValue(eu.esdihumboldt.hale.common.core.io.impl.ElementValue)

Aggregations

Value (eu.esdihumboldt.hale.common.core.io.Value)2 ComplexPropertyType (eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ComplexPropertyType)2 PropertyType (eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.PropertyType)2 ValueType (eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ValueType)2 ElementValue (eu.esdihumboldt.hale.common.core.io.impl.ElementValue)1 IOConfiguration (eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)1 IOConfigurationType (eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.IOConfigurationType)1