use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateMultiSourceMapping.
protected AtlasMapping generateMultiSourceMapping() {
AtlasMapping mapping = generateSeparateAtlasMapping();
DataSource sourceA = generateDataSource("srcId", "srcUri", DataSourceType.SOURCE);
mapping.getDataSource().add(sourceA);
DataSource targetA = generateDataSource("tgtId", "tgtUri", DataSourceType.TARGET);
mapping.getDataSource().add(targetA);
DataSource targetB = generateDataSource("tgtId", "tgtUri", DataSourceType.TARGET);
mapping.getDataSource().add(targetB);
Mapping fm = (Mapping) mapping.getMappings().getMapping().get(0);
fm.getInputField().get(0).setDocId("docid");
fm.getOutputField().get(0).setDocId("docid");
fm.getOutputField().get(1).setDocId("docid");
populateMapping(fm, MappingType.MAP, "MapPropertyFieldAlias", ",", ",");
populateMappingString(fm, "description", "id", "lookupTableName", "strategy", "strategyClassName");
return mapping;
}
use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateDataSource.
private void generateDataSource(AtlasMapping atlasMapping) {
DataSource src = generateDataSource("srcId", "srcUri", DataSourceType.SOURCE);
DataSource tgt = generateDataSource("tgtId", "tgtUri", DataSourceType.TARGET);
atlasMapping.getDataSource().add(src);
atlasMapping.getDataSource().add(tgt);
}
use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.
the class XmlModule method processPreTargetExecution.
@Override
public void processPreTargetExecution(AtlasInternalSession session) throws AtlasException {
XmlNamespaces xmlNs = null;
String template = null;
DataSource ds = getDataSource();
if (ds instanceof XmlDataSource) {
xmlNs = ((XmlDataSource) ds).getXmlNamespaces();
template = ((XmlDataSource) ds).getTemplate();
}
Map<String, String> nsMap = new HashMap<String, String>();
if (xmlNs != null && xmlNs.getXmlNamespace() != null && !xmlNs.getXmlNamespace().isEmpty()) {
for (XmlNamespace ns : xmlNs.getXmlNamespace()) {
nsMap.put(ns.getAlias(), ns.getUri());
}
}
XmlFieldWriter writer = new XmlFieldWriter(getClassLoader(), nsMap, template);
session.setFieldWriter(getDocId(), writer);
if (LOG.isDebugEnabled()) {
LOG.debug("{}: processPreTargetExcution completed", getDocId());
}
}
use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.
the class XmlValidationServiceTest 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 AtlasEndpoint method populateTargetDocuments.
private void populateTargetDocuments(AtlasSession session, Exchange exchange) {
Message outMessage = exchange.getOut();
outMessage.setHeaders(exchange.getIn().getHeaders());
outMessage.setAttachments(exchange.getIn().getAttachments());
if (session.getMapping().getDataSource() == null) {
return;
}
DataSource[] targetDataSources = session.getMapping().getDataSource().stream().filter(ds -> ds.getDataSourceType() == DataSourceType.TARGET).toArray(DataSource[]::new);
if (targetDataSources.length == 0) {
Object newBody = session.getDefaultTargetDocument();
outMessage.setBody(newBody);
return;
}
if (targetDataSources.length == 1) {
String docId = targetDataSources[0].getId();
if (docId == null || docId.isEmpty()) {
Object newBody = session.getDefaultTargetDocument();
outMessage.setBody(newBody);
} else {
Object newBody = session.getTargetDocument(docId);
outMessage.setBody(newBody);
}
setContentType(targetDataSources[0], outMessage);
return;
}
Map<String, Object> targetDocuments = new HashMap<>();
for (DataSource ds : targetDataSources) {
String docId = ds.getId();
if (docId == null || docId.isEmpty()) {
targetDocuments.put(io.atlasmap.api.AtlasConstants.DEFAULT_TARGET_DOCUMENT_ID, session.getDefaultTargetDocument());
Object newBody = session.getDefaultTargetDocument();
outMessage.setBody(newBody);
setContentType(ds, outMessage);
} else {
targetDocuments.put(docId, session.getTargetDocument(docId));
}
}
switch(targetMapMode) {
case MAP:
if (targetMapName != null) {
exchange.setProperty(targetMapName, targetDocuments);
} else {
outMessage.setBody(targetDocuments);
}
break;
case MESSAGE_HEADER:
targetDocuments.remove(io.atlasmap.api.AtlasConstants.DEFAULT_TARGET_DOCUMENT_ID);
outMessage.getHeaders().putAll(targetDocuments);
break;
case EXCHANGE_PROPERTY:
targetDocuments.remove(io.atlasmap.api.AtlasConstants.DEFAULT_TARGET_DOCUMENT_ID);
exchange.getProperties().putAll(targetDocuments);
break;
}
}
Aggregations