Search in sources :

Example 1 with ValueProperties

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

the class NumberValidatorFactory 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));
    BigDecimal val = props.getSafe(P_VALUE).as(BigDecimal.class);
    return new NumberValidator(type, val);
}
Also used : Type(eu.esdihumboldt.util.validator.NumberValidator.Type) ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties) NumberValidator(eu.esdihumboldt.util.validator.NumberValidator) BigDecimal(java.math.BigDecimal)

Example 2 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 3 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)

Example 4 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 5 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)

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