Search in sources :

Example 6 with SQLArray

use of eu.esdihumboldt.hale.io.jdbc.constraints.SQLArray in project hale by halestudio.

the class SQLArrayFactory method restore.

@Override
public SQLArray restore(Value value, Definition<?> definition, TypeResolver typeIndex, ClassResolver resolver) throws Exception {
    ValueProperties props = value.as(ValueProperties.class);
    if (props != null) {
        // read element class
        Class<?> elementType = null;
        String className = props.getSafe(NAME_ELEMENT_CLASS).as(String.class);
        if (className != null) {
            elementType = resolver.loadClass(className);
        }
        // read element database type name
        String elementTypeName = props.getSafe(NAME_ELEMENT_TYPE_NAME).as(String.class);
        // read dimension
        int dimension = props.getSafe(NAME_DIMENSION).as(Integer.class, 0);
        // read array dimension sizes
        int[] sizes = null;
        ValueList sizeList = props.getSafe(NAME_SIZES).as(ValueList.class);
        if (sizeList != null) {
            sizes = new int[sizeList.size()];
            int index = 0;
            for (Value size : sizeList) {
                sizes[index] = size.as(Integer.class, 0);
                index++;
            }
        }
        return new SQLArray(elementType, elementTypeName, dimension, sizes);
    }
    return SQLArray.NO_ARRAY;
}
Also used : ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties) ValueList(eu.esdihumboldt.hale.common.core.io.ValueList) Value(eu.esdihumboldt.hale.common.core.io.Value) SQLArray(eu.esdihumboldt.hale.io.jdbc.constraints.SQLArray)

Aggregations

SQLArray (eu.esdihumboldt.hale.io.jdbc.constraints.SQLArray)6 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)4 QName (javax.xml.namespace.QName)4 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)3 DefaultTypeDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)3 GeometryProperty (eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty)2 Reference (eu.esdihumboldt.hale.common.schema.model.constraint.property.Reference)2 DefaultPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition)2 DefaultValue (eu.esdihumboldt.hale.io.jdbc.constraints.DefaultValue)2 GeometryAdvisorConstraint (eu.esdihumboldt.hale.io.jdbc.constraints.internal.GeometryAdvisorConstraint)2 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)1 Value (eu.esdihumboldt.hale.common.core.io.Value)1 ValueList (eu.esdihumboldt.hale.common.core.io.ValueList)1 ValueProperties (eu.esdihumboldt.hale.common.core.io.ValueProperties)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 AutoGenerated (eu.esdihumboldt.hale.common.schema.model.constraint.property.AutoGenerated)1 GeometryType (eu.esdihumboldt.hale.common.schema.model.constraint.type.GeometryType)1 SQLType (eu.esdihumboldt.hale.io.jdbc.constraints.SQLType)1 CustomType (eu.esdihumboldt.hale.io.jdbc.extension.internal.CustomType)1 GeometryTypeInfo (eu.esdihumboldt.hale.io.jdbc.extension.internal.GeometryTypeInfo)1