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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations