Search in sources :

Example 6 with FieldType

use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.

the class JsonFieldWriter method createValueNode.

private JsonNode createValueNode(Field jsonField) {
    FieldType type = jsonField.getFieldType();
    Object value = jsonField.getValue();
    JsonNode valueNode = null;
    if (FieldType.STRING.equals(type)) {
        if (value != null) {
            valueNode = rootNode.textNode(String.valueOf(value));
        } else {
            valueNode = rootNode.nullNode();
        }
    } else if (FieldType.CHAR.equals(type)) {
        valueNode = rootNode.textNode(Character.toString((char) value));
    } else if (FieldType.BOOLEAN.equals(type)) {
        valueNode = rootNode.booleanNode((Boolean) value);
    } else if (FieldType.INTEGER.equals(type)) {
        valueNode = rootNode.numberNode((Integer) value);
    } else if (FieldType.DOUBLE.equals(type) || FieldType.FLOAT.equals(type)) {
        valueNode = rootNode.numberNode(new BigDecimal(String.valueOf(value)));
    } else if (FieldType.SHORT.equals(type)) {
        valueNode = rootNode.numberNode(Short.valueOf(String.valueOf(value)));
    } else if (FieldType.LONG.equals(type)) {
        valueNode = rootNode.numberNode(Long.valueOf(String.valueOf(value)));
    } else if (FieldType.BYTE.equals(type)) {
        valueNode = rootNode.numberNode(Byte.valueOf(String.valueOf(value)));
    } else {
        valueNode = rootNode.nullNode();
    }
    if (LOG.isDebugEnabled()) {
        String valueClass = value == null ? "null" : value.getClass().getName();
        LOG.debug("Converted JsonField value to ValueNode. Type: " + type + ", value: " + value + "(" + valueClass + "), node class: " + valueNode.getClass().getName() + ", node: " + valueNode);
    }
    return valueNode;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) BigDecimal(java.math.BigDecimal) FieldType(io.atlasmap.v2.FieldType)

Example 7 with FieldType

use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.

the class BaseDefaultAtlasContextTest method populateSourceField.

protected Field populateSourceField(Mapping mapping, FieldType type, Object value, int index) {
    Field field = populateSourceField(mapping, type, value);
    field.setIndex(index);
    return field;
}
Also used : SimpleField(io.atlasmap.v2.SimpleField) Field(io.atlasmap.v2.Field)

Example 8 with FieldType

use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.

the class BaseDefaultAtlasContextTest method populateSourceField.

protected Field populateSourceField(Mapping mapping, String docId, FieldType type, Object value) {
    Field field = populateSourceField(mapping, type, value);
    field.setDocId(docId);
    return field;
}
Also used : SimpleField(io.atlasmap.v2.SimpleField) Field(io.atlasmap.v2.Field)

Example 9 with FieldType

use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.

the class BaseDefaultAtlasContextTest method populateSourceField.

protected Field populateSourceField(Mapping mapping, String docId, FieldType type, Object value, int index) {
    Field field = populateSourceField(mapping, type, value);
    field.setDocId(docId);
    field.setIndex(index);
    return field;
}
Also used : SimpleField(io.atlasmap.v2.SimpleField) Field(io.atlasmap.v2.Field)

Example 10 with FieldType

use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.

the class BaseDefaultAtlasContextTest method prepareTargetField.

protected Field prepareTargetField(Mapping mapping, FieldType type, String path, int index) {
    Field field = prepareTargetField(mapping, path);
    field.setFieldType(type);
    field.setPath(path);
    field.setIndex(index);
    return field;
}
Also used : SimpleField(io.atlasmap.v2.SimpleField) Field(io.atlasmap.v2.Field)

Aggregations

FieldType (io.atlasmap.v2.FieldType)13 Field (io.atlasmap.v2.Field)8 AtlasInternalSession (io.atlasmap.spi.AtlasInternalSession)6 SimpleField (io.atlasmap.v2.SimpleField)6 Test (org.junit.Test)4 Head (io.atlasmap.spi.AtlasInternalSession.Head)3 Audits (io.atlasmap.v2.Audits)3 XmlField (io.atlasmap.xml.v2.XmlField)3 Path (java.nio.file.Path)3 AtlasConverter (io.atlasmap.api.AtlasConverter)2 AtlasException (io.atlasmap.api.AtlasException)2 JavaEnumField (io.atlasmap.java.v2.JavaEnumField)2 JavaField (io.atlasmap.java.v2.JavaField)2 Method (java.lang.reflect.Method)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 XSAttributeDecl (com.sun.xml.xsom.XSAttributeDecl)1 XSAttributeUse (com.sun.xml.xsom.XSAttributeUse)1 XSSimpleType (com.sun.xml.xsom.XSSimpleType)1 AtlasConversionException (io.atlasmap.api.AtlasConversionException)1 AtlasConversionService (io.atlasmap.api.AtlasConversionService)1