Search in sources :

Example 6 with ValueProperties

use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.

the class EnumerationFactory method store.

@Override
public Value store(Enumeration<?> constraint, TypeReferenceBuilder typeIndex) {
    ValueProperties props = new ValueProperties(2);
    // values
    if (constraint.getValues() != null) {
        ValueList list = new ValueList();
        for (Object value : constraint.getValues()) {
            list.add(Value.simple(value));
        }
        props.put(P_VALUES, Value.complex(list));
    // XXX also store the value type for reconstruction?
    }
    // allow others?
    props.put(P_ALLOW_OTHERS, Value.of(constraint.isAllowOthers()));
    return Value.complex(props);
}
Also used : ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties) ValueList(eu.esdihumboldt.hale.common.core.io.ValueList)

Example 7 with ValueProperties

use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.

the class EnumerationFactory method restore.

@Override
public Enumeration<?> restore(Value value, Definition<?> definition, TypeResolver typeIndex, ClassResolver resolver) throws Exception {
    ValueProperties props = value.as(ValueProperties.class);
    boolean allowOthers = props.get(P_ALLOW_OTHERS).as(Boolean.class, true);
    Collection<Object> values = null;
    if (props.containsKey(P_VALUES)) {
        values = new ArrayList<>();
        ValueList list = props.get(P_VALUES).as(ValueList.class);
        for (Value val : list) {
            // XXX determine value type?
            // XXX for now just use string
            String str = val.as(String.class);
            if (str != null) {
                values.add(str);
            } else {
            // TODO warn?
            }
        }
    }
    return new Enumeration<Object>(values, allowOthers);
}
Also used : Enumeration(eu.esdihumboldt.hale.common.schema.model.constraint.type.Enumeration) ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties) ValueList(eu.esdihumboldt.hale.common.core.io.ValueList) Value(eu.esdihumboldt.hale.common.core.io.Value)

Example 8 with ValueProperties

use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.

the class GeometryMetadataFactory method restore.

@Override
public GeometryMetadata restore(Value value, Definition<?> definition, TypeResolver typeIndex, ClassResolver resolver) throws Exception {
    ValueProperties props = value.as(ValueProperties.class);
    if (props != null) {
        String srs = props.getSafe(NAME_SRS).as(String.class);
        int dimension = props.getSafe(NAME_DIMENSION).as(Integer.class, 0);
        String srsText = props.getSafe(NAME_SRS_TEXT).as(String.class);
        String auth_name = props.getSafe(NAME_AUTH_NAME).as(String.class);
        return new GeometryMetadata(srs, dimension, srsText, auth_name);
    } else {
        return new GeometryMetadata();
    }
}
Also used : ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties) GeometryMetadata(eu.esdihumboldt.hale.common.schema.model.constraint.type.GeometryMetadata)

Example 9 with ValueProperties

use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.

the class DigitCountValidatorFactory method restore.

@Override
public Validator restore(Value value) throws Exception {
    ValueProperties props = value.as(ValueProperties.class);
    Type type = Type.valueOf(props.getSafe(P_TYPE).as(String.class));
    int length = props.getSafe(P_LENGTH).as(Integer.class);
    return new DigitCountValidator(type, length);
}
Also used : Type(eu.esdihumboldt.util.validator.DigitCountValidator.Type) ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties) DigitCountValidator(eu.esdihumboldt.util.validator.DigitCountValidator)

Example 10 with ValueProperties

use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.

the class DigitCountValidatorFactory method store.

@Override
public Value store(DigitCountValidator validator) throws Exception {
    ValueProperties props = new ValueProperties();
    props.put(P_TYPE, Value.of(validator.getType().name()));
    props.put(P_LENGTH, Value.of(validator.getLength()));
    return props.toValue();
}
Also used : ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties)

Aggregations

ValueProperties (eu.esdihumboldt.hale.common.core.io.ValueProperties)26 Value (eu.esdihumboldt.hale.common.core.io.Value)11 ValueList (eu.esdihumboldt.hale.common.core.io.ValueList)8 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)4 Function (com.google.common.base.Function)1 Reference (eu.esdihumboldt.hale.common.schema.model.constraint.property.Reference)1 Enumeration (eu.esdihumboldt.hale.common.schema.model.constraint.type.Enumeration)1 GeometryMetadata (eu.esdihumboldt.hale.common.schema.model.constraint.type.GeometryMetadata)1 DatabaseTable (eu.esdihumboldt.hale.io.jdbc.constraints.DatabaseTable)1 SQLArray (eu.esdihumboldt.hale.io.jdbc.constraints.SQLArray)1 XmlElement (eu.esdihumboldt.hale.io.xsd.model.XmlElement)1 ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)1 DynamicScrolledComposite (eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite)1 DigitCountValidator (eu.esdihumboldt.util.validator.DigitCountValidator)1 Type (eu.esdihumboldt.util.validator.DigitCountValidator.Type)1 LengthValidator (eu.esdihumboldt.util.validator.LengthValidator)1 Type (eu.esdihumboldt.util.validator.LengthValidator.Type)1 NumberValidator (eu.esdihumboldt.util.validator.NumberValidator)1 Type (eu.esdihumboldt.util.validator.NumberValidator.Type)1 BigDecimal (java.math.BigDecimal)1