Search in sources :

Example 1 with InputType

use of com.enonic.xp.inputtype.InputType in project xp by enonic.

the class JsonToPropertyTreeTranslator method mapValue.

private void mapValue(final PropertySet parent, final String key, final JsonNode value) {
    final Property parentProperty = parent.getProperty();
    final Input input = getInput(parentProperty, key);
    if (input == null) {
        if (this.strictMode) {
            throw new IllegalArgumentException("No mapping defined for property " + key + " with value " + resolveStringValue(value));
        }
        parent.addProperty(key, resolveCoreValue(value));
    } else {
        final InputType type = this.inputTypeResolver.resolve(input.getInputType());
        final Value mappedPropertyValue = type.createValue(resolveCoreValue(value), input.getInputTypeConfig());
        parent.addProperty(key, mappedPropertyValue);
    }
}
Also used : Input(com.enonic.xp.form.Input) InputType(com.enonic.xp.inputtype.InputType) Value(com.enonic.xp.data.Value) Property(com.enonic.xp.data.Property)

Example 2 with InputType

use of com.enonic.xp.inputtype.InputType in project xp by enonic.

the class FormJsonToPropertyTreeTranslator method mapValue.

private void mapValue(final PropertySet parent, final String key, final JsonNode value) {
    final Property parentProperty = parent.getProperty();
    final Input input = getInput(parentProperty, key);
    if (input == null) {
        if (this.strictMode && !isOptionSetSelection(key, parentProperty)) {
            throw new IllegalArgumentException("No mapping defined for property " + key + " with value " + resolveStringValue(value));
        }
        parent.addProperty(key, resolveCoreValue(value));
    } else {
        final InputType type = this.inputTypeResolver.resolve(input.getInputType());
        final Value mappedPropertyValue = type.createValue(resolveCoreValue(value), input.getInputTypeConfig());
        parent.addProperty(key, mappedPropertyValue);
    }
}
Also used : Input(com.enonic.xp.form.Input) InputType(com.enonic.xp.inputtype.InputType) Value(com.enonic.xp.data.Value) Property(com.enonic.xp.data.Property)

Example 3 with InputType

use of com.enonic.xp.inputtype.InputType in project xp by enonic.

the class InputValidationVisitor method checkValidity.

private void checkValidity(final Input input, final Property property) {
    if (property == null) {
        return;
    }
    final InputType type = this.inputTypeResolver.resolve(input.getInputType());
    type.validate(property, input.getInputTypeConfig());
}
Also used : InputType(com.enonic.xp.inputtype.InputType)

Aggregations

InputType (com.enonic.xp.inputtype.InputType)3 Property (com.enonic.xp.data.Property)2 Value (com.enonic.xp.data.Value)2 Input (com.enonic.xp.form.Input)2