use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.
the class JavaJsonFlatMappingTest method generateDataSource.
protected DataSource generateDataSource(String uri, DataSourceType type) {
DataSource ds = new DataSource();
ds.setUri(uri);
ds.setDataSourceType(type);
return ds;
}
use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.
the class BaseMappingTest method getAtlasMappingFullValid.
protected AtlasMapping getAtlasMappingFullValid() {
AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
mapping.setName("thisis_a_valid.name");
DataSource src = new DataSource();
src.setDataSourceType(DataSourceType.SOURCE);
src.setUri("atlas:java?2");
DataSource tgt = new DataSource();
tgt.setDataSourceType(DataSourceType.TARGET);
tgt.setUri("atlas:java?3");
mapping.getDataSource().add(src);
mapping.getDataSource().add(tgt);
Mapping mapFieldMapping = AtlasModelFactory.createMapping(MappingType.MAP);
MockField inputField = AtlasModelFactory.createMockField();
inputField.setFieldType(FieldType.STRING);
inputField.setCustom("java.lang.String");
inputField.setName("inputName");
mapFieldMapping.getInputField().add(inputField);
MockField outputField = AtlasModelFactory.createMockField();
outputField.setFieldType(FieldType.STRING);
outputField.setCustom("java.lang.String");
outputField.setName("outputName");
mapFieldMapping.getOutputField().add(outputField);
Mapping separateMapping = AtlasModelFactory.createMapping(MappingType.SEPARATE);
MockField sIJavaField = AtlasModelFactory.createMockField();
sIJavaField.setFieldType(FieldType.STRING);
sIJavaField.setCustom("java.lang.String");
sIJavaField.setName("inputName");
separateMapping.getInputField().add(sIJavaField);
MockField sOJavaField = AtlasModelFactory.createMockField();
sOJavaField.setFieldType(FieldType.STRING);
sOJavaField.setCustom("java.lang.String");
sOJavaField.setName("outputName");
sOJavaField.setIndex(0);
separateMapping.getOutputField().add(sOJavaField);
mapping.getMappings().getMapping().add(mapFieldMapping);
mapping.getMappings().getMapping().add(separateMapping);
return mapping;
}
use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.
the class BaseJsonValidationServiceTest method generateDataSource.
protected DataSource generateDataSource(String uri, DataSourceType type) {
DataSource ds = new DataSource();
ds.setUri(uri);
ds.setDataSourceType(type);
return ds;
}
use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.
the class XmlFieldReader method getSourceNamespaces.
private Optional<XmlNamespaces> getSourceNamespaces(AtlasInternalSession session, Field field) {
DataSource dataSource = null;
AtlasMapping mapping = session.getMapping();
// this is to simplify tests which uses mocks
if (mapping == null || mapping.getDataSource() == null || field.getDocId() == null) {
return Optional.empty();
}
List<DataSource> dataSources = mapping.getDataSource();
for (DataSource source : dataSources) {
if (!source.getDataSourceType().equals(DataSourceType.SOURCE)) {
continue;
}
if (field.getDocId().equals(source.getId())) {
dataSource = source;
break;
}
}
if (dataSource == null || !XmlDataSource.class.isInstance(dataSource)) {
return Optional.empty();
}
XmlDataSource xmlDataSource = XmlDataSource.class.cast(dataSource);
return xmlDataSource.getXmlNamespaces() != null ? Optional.of(xmlDataSource.getXmlNamespaces()) : Optional.empty();
}
use of com.google.cloud.bigquery.datatransfer.v1.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;
}
Aggregations