Search in sources :

Example 21 with Field

use of org.batfish.z3.Field in project atlasmap by atlasmap.

the class AtlasModuleSupportTest method testListTargetPathsListOfBaseMapping.

@Test
public void testListTargetPathsListOfBaseMapping() {
    List<BaseMapping> mappings = null;
    assertEquals(0, AtlasModuleSupport.listTargetPaths(mappings).size());
    mappings = new ArrayList<>();
    assertEquals(0, AtlasModuleSupport.listTargetPaths(mappings).size());
    Mapping mapping = new Mapping();
    Field field = new MockField();
    field.setPath("MockPath");
    mapping.getOutputField().add(field);
    mappings.add(mapping);
    assertEquals(1, AtlasModuleSupport.listTargetPaths(mappings).size());
    Collection collection = null;
    mappings.add(collection);
    assertEquals(1, AtlasModuleSupport.listTargetPaths(mappings).size());
    collection = new Collection();
    mappings.add(collection);
    assertEquals(1, AtlasModuleSupport.listTargetPaths(mappings).size());
    Mappings mapings = new Mappings();
    collection.setMappings(mapings);
    assertEquals(1, AtlasModuleSupport.listTargetPaths(mappings).size());
}
Also used : MockField(io.atlasmap.v2.MockField) Field(io.atlasmap.v2.Field) MockField(io.atlasmap.v2.MockField) Mappings(io.atlasmap.v2.Mappings) Collection(io.atlasmap.v2.Collection) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Test(org.junit.Test)

Example 22 with Field

use of org.batfish.z3.Field in project atlasmap by atlasmap.

the class BaseDefaultAtlasContextTest method prepareTargetField.

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

Example 23 with Field

use of org.batfish.z3.Field in project atlasmap by atlasmap.

the class BaseDefaultAtlasContextTest method populateSourceField.

protected Field populateSourceField(Mapping mapping, FieldType type, Object value) {
    Field field = new SimpleField();
    field.setFieldType(type);
    field.setPath("/testPath" + value);
    mapping.getInputField().add(field);
    reader.sources.put(field.getPath(), value);
    return field;
}
Also used : SimpleField(io.atlasmap.v2.SimpleField) Field(io.atlasmap.v2.Field) SimpleField(io.atlasmap.v2.SimpleField)

Example 24 with Field

use of org.batfish.z3.Field in project atlasmap by atlasmap.

the class DocumentJavaFieldReader method read.

@Override
public void read(AtlasInternalSession session) throws AtlasException {
    try {
        Field sourceField = session.head().getSourceField();
        Method getter = null;
        if (sourceField.getFieldType() == null && (sourceField instanceof JavaField || sourceField instanceof JavaEnumField)) {
            getter = resolveGetMethod(sourceDocument, sourceField);
            if (getter == null) {
                AtlasUtil.addAudit(session, sourceField.getDocId(), String.format("Unable to auto-detect sourceField type path=%s docId=%s", sourceField.getPath(), sourceField.getDocId()), sourceField.getPath(), AuditStatus.WARN, null);
                return;
            }
            Class<?> returnType = getter.getReturnType();
            sourceField.setFieldType(conversionService.fieldTypeFromClass(returnType));
            if (LOG.isTraceEnabled()) {
                LOG.trace("Auto-detected sourceField type p=" + sourceField.getPath() + " t=" + sourceField.getFieldType());
            }
        }
        populateSourceFieldValue(session, sourceField, sourceDocument, getter);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Processed input field sPath=" + sourceField.getPath() + " sV=" + sourceField.getValue() + " sT=" + sourceField.getFieldType() + " docId: " + sourceField.getDocId());
        }
    } catch (Exception e) {
        throw new AtlasException(e);
    }
}
Also used : JavaEnumField(io.atlasmap.java.v2.JavaEnumField) Field(io.atlasmap.v2.Field) JavaField(io.atlasmap.java.v2.JavaField) JavaEnumField(io.atlasmap.java.v2.JavaEnumField) JavaField(io.atlasmap.java.v2.JavaField) Method(java.lang.reflect.Method) AtlasException(io.atlasmap.api.AtlasException) AtlasException(io.atlasmap.api.AtlasException)

Example 25 with Field

use of org.batfish.z3.Field in project atlasmap by atlasmap.

the class BaseDocumentWriterTest method write.

protected void write(String path, StateEnumClassLong targetValue) throws AtlasException {
    Field field = createEnumField(path, targetValue);
    setTargetValue(targetValue);
    write(field);
}
Also used : Field(io.atlasmap.v2.Field) JavaEnumField(io.atlasmap.java.v2.JavaEnumField) JavaField(io.atlasmap.java.v2.JavaField)

Aggregations

Field (io.atlasmap.v2.Field)60 JavaField (io.atlasmap.java.v2.JavaField)15 Mapping (io.atlasmap.v2.Mapping)15 AtlasMapping (io.atlasmap.v2.AtlasMapping)14 SimpleField (io.atlasmap.v2.SimpleField)14 BaseMapping (io.atlasmap.v2.BaseMapping)12 JavaEnumField (io.atlasmap.java.v2.JavaEnumField)11 Test (org.junit.Test)11 JsonField (io.atlasmap.json.v2.JsonField)8 LookupTable (io.atlasmap.v2.LookupTable)8 XmlField (io.atlasmap.xml.v2.XmlField)7 AtlasException (io.atlasmap.api.AtlasException)6 ConstantField (io.atlasmap.v2.ConstantField)6 AtlasConversionException (io.atlasmap.api.AtlasConversionException)5 JsonDocument (io.atlasmap.json.v2.JsonDocument)5 PropertyField (io.atlasmap.v2.PropertyField)5 ArrayList (java.util.ArrayList)5 AtlasInternalSession (io.atlasmap.spi.AtlasInternalSession)4 AtlasModule (io.atlasmap.spi.AtlasModule)3 FieldType (io.atlasmap.v2.FieldType)3