Search in sources :

Example 26 with DataSource

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

the class DefaultAtlasContext method processSourceFieldMappings.

private void processSourceFieldMappings(DefaultAtlasSession session, List<Field> sourceFields) throws AtlasException {
    for (Field sourceField : sourceFields) {
        session.head().setSourceField(sourceField);
        AtlasModule module = resolveModule(FieldDirection.SOURCE, sourceField);
        if (module == null) {
            AtlasUtil.addAudit(session, sourceField.getDocId(), String.format("Module not found for docId '%s'", sourceField.getDocId()), sourceField.getPath(), AuditStatus.ERROR, null);
            return;
        }
        if (!module.isSupportedField(sourceField)) {
            AtlasUtil.addAudit(session, sourceField.getDocId(), String.format("Unsupported source field type '%s' for DataSource '%s'", sourceField.getClass().getName(), module.getUri()), sourceField.getPath(), AuditStatus.ERROR, null);
            return;
        }
        module.processSourceFieldMapping(session);
    }
}
Also used : PropertyField(io.atlasmap.v2.PropertyField) Field(io.atlasmap.v2.Field) SimpleField(io.atlasmap.v2.SimpleField) ConstantField(io.atlasmap.v2.ConstantField) AtlasModule(io.atlasmap.spi.AtlasModule)

Example 27 with DataSource

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

the class BaseModuleValidationService method validateMapping.

@Override
public List<Validation> validateMapping(AtlasMapping mapping) {
    List<Validation> validations = new ArrayList<>();
    if (getMode() == AtlasModuleMode.UNSET) {
        Validation validation = new Validation();
        validation.setMessage(String.format("No mode specified for %s/%s, skipping module validations", this.getModuleDetail().name(), this.getClass().getSimpleName()));
    }
    if (mapping != null && mapping.getMappings() != null && mapping.getMappings().getMapping() != null && !mapping.getMappings().getMapping().isEmpty()) {
        validateMappingEntries(mapping.getMappings().getMapping(), validations);
    }
    boolean found = false;
    for (DataSource ds : mapping.getDataSource()) {
        if (ds.getUri() != null && ds.getUri().startsWith(getModuleDetail().uri())) {
            found = true;
            break;
        }
    }
    if (!found) {
        Validation validation = new Validation();
        validation.setScope(ValidationScope.DATA_SOURCE);
        validation.setMessage(String.format("No DataSource with '%s' uri specified", getModuleDetail().uri()));
        validation.setStatus(ValidationStatus.ERROR);
        validations.add(validation);
    }
    return validations;
}
Also used : Validation(io.atlasmap.v2.Validation) ArrayList(java.util.ArrayList) DataSource(io.atlasmap.v2.DataSource)

Example 28 with DataSource

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

the class JsonValidationServiceTest method generateDataSource.

protected DataSource generateDataSource(String uri, DataSourceType type) {
    DataSource ds = new DataSource();
    ds.setUri(uri);
    ds.setDataSourceType(type);
    return ds;
}
Also used : DataSource(io.atlasmap.v2.DataSource)

Example 29 with DataSource

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

the class JsonJsonFlatMappingTest method generateDataSource.

protected DataSource generateDataSource(String uri, DataSourceType type) {
    DataSource ds = new DataSource();
    ds.setUri(uri);
    ds.setDataSourceType(type);
    return ds;
}
Also used : DataSource(io.atlasmap.v2.DataSource)

Example 30 with DataSource

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

the class OverloadedFieldActionsTest method generateMappingDayOfWeek.

protected AtlasMapping generateMappingDayOfWeek(Class<?> clazz) {
    AtlasMapping m = new AtlasMapping();
    DataSource s = new DataSource();
    s.setDataSourceType(DataSourceType.SOURCE);
    s.setUri("atlas:java?className=io.atlasmap.java.test.SourceFlatPrimitiveClass");
    DataSource t = new DataSource();
    t.setDataSourceType(DataSourceType.TARGET);
    t.setUri("atlas:java?className=io.atlasmap.java.test.TargetFlatPrimitiveClass");
    m.getDataSource().add(s);
    m.getDataSource().add(t);
    Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
    JavaField srcF = new JavaField();
    Actions acts = new Actions();
    srcF.setActions(acts);
    JavaField tgtF = new JavaField();
    if (clazz.isAssignableFrom(String.class)) {
        srcF.setPath("boxedStringField");
        srcF.getActions().getActions().add(new DayOfWeekString());
        tgtF.setPath("boxedStringField");
    } else if (clazz.isAssignableFrom(Integer.class)) {
        srcF.setPath("intField");
        srcF.getActions().getActions().add(new DayOfWeekInteger());
        tgtF.setPath("boxedStringField");
    }
    mfm.getInputField().add(srcF);
    mfm.getOutputField().add(tgtF);
    Mappings maps = new Mappings();
    maps.getMapping().add(mfm);
    m.setMappings(maps);
    return m;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) JavaField(io.atlasmap.java.v2.JavaField) Mappings(io.atlasmap.v2.Mappings) Actions(io.atlasmap.v2.Actions) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) DataSource(io.atlasmap.v2.DataSource)

Aggregations

DataSource (io.atlasmap.v2.DataSource)54 AtlasMapping (io.atlasmap.v2.AtlasMapping)16 ArrayList (java.util.ArrayList)14 Mapping (io.atlasmap.v2.Mapping)11 XmlDataSource (io.atlasmap.xml.v2.XmlDataSource)10 Mappings (io.atlasmap.v2.Mappings)8 JsonDataSource (io.atlasmap.json.v2.JsonDataSource)7 Test (org.junit.Test)7 File (java.io.File)6 AtlasContext (io.atlasmap.api.AtlasContext)5 AtlasSession (io.atlasmap.api.AtlasSession)5 JavaField (io.atlasmap.java.v2.JavaField)5 AtlasException (io.atlasmap.api.AtlasException)4 XmlNamespaces (io.atlasmap.xml.v2.XmlNamespaces)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 AtlasModule (io.atlasmap.spi.AtlasModule)3 HashMap (java.util.HashMap)3 Exchange (org.apache.camel.Exchange)3