use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method init.
@BeforeEach
public void init() throws AtlasException {
mapping = AtlasTestData.generateAtlasMapping();
context = new DefaultAtlasContext(DefaultAtlasContextFactory.getInstance(), mapping) {
protected void init() {
// hijack initialization
}
};
previewContext = new DefaultAtlasPreviewContext(DefaultAtlasContextFactory.getInstance());
sourceModule = mockAtlasModule();
DataSource sds = new DataSource();
sds.setDataSourceType(DataSourceType.SOURCE);
sourceModule.setDataSource(sds);
targetModule = mockAtlasModule();
DataSource tds = new DataSource();
tds.setDataSourceType(DataSourceType.TARGET);
targetModule.setDataSource(tds);
context.getSourceModules().put(AtlasConstants.DEFAULT_SOURCE_DOCUMENT_ID, sourceModule);
context.getTargetModules().put(AtlasConstants.DEFAULT_TARGET_DOCUMENT_ID, targetModule);
ConstantModule constantModule = new ConstantModule();
constantModule.setConversionService(DefaultAtlasConversionService.getInstance());
context.getSourceModules().put(AtlasConstants.CONSTANTS_DOCUMENT_ID, constantModule);
PropertyModule sourcePropertyModule = new PropertyModule(new DefaultAtlasPropertyStrategy());
sourcePropertyModule.setConversionService(DefaultAtlasConversionService.getInstance());
context.getSourceModules().put(AtlasConstants.PROPERTIES_SOURCE_DOCUMENT_ID, sourcePropertyModule);
PropertyModule targetPropertyModule = new PropertyModule(new DefaultAtlasPropertyStrategy());
targetPropertyModule.setConversionService(DefaultAtlasConversionService.getInstance());
context.getTargetModules().put(AtlasConstants.PROPERTIES_TARGET_DOCUMENT_ID, targetPropertyModule);
recreateSession();
}
use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateMultiSourceMapping.
protected AtlasMapping generateMultiSourceMapping() {
AtlasMapping mapping = generateSeparateAtlasMapping();
DataSource source1 = new DataSource();
source1.setUri("xml:foo1");
source1.setDataSourceType(DataSourceType.SOURCE);
source1.setId("xml1");
DataSource source2 = new DataSource();
source2.setUri("xml:foo2");
source2.setDataSourceType(DataSourceType.SOURCE);
source2.setId("xml2");
DataSource target = new DataSource();
target.setUri("xml:bar");
target.setDataSourceType(DataSourceType.TARGET);
target.setId("target1");
mapping.getDataSource().add(source1);
mapping.getDataSource().add(source2);
mapping.getDataSource().add(target);
Mapping fm = (Mapping) mapping.getMappings().getMapping().get(0);
fm.getInputField().get(0).setDocId("xml1");
fm.getOutputField().get(0).setDocId("target1");
fm.getOutputField().get(1).setDocId("target1");
return mapping;
}
use of io.atlasmap.v2.DataSource in project syndesis-qe by syndesisio.
the class AtlasMapperGenerator method processSources.
/**
* Gets list of output data shapes for preceding steps.
*
* @param precedingSteps
* @return
*/
private List<DataSource> processSources(List<StepDefinition> precedingSteps) {
List<DataSource> sources = new ArrayList<>();
for (StepDefinition s : precedingSteps) {
DataShape outDataShape = s.getConnectorDescriptor().get().getOutputDataShape().get();
sources.add(createDataSource(outDataShape, s, DataSourceType.SOURCE));
}
return sources;
}
use of io.atlasmap.v2.DataSource in project syndesis-qe by syndesisio.
the class AtlasMapperGenerator method createDataSource.
/**
* Used to generate data source elements for atlasMapping. There are three types of them: Java, Json, XML.
*
* TODO(tplevko): update also for XML
*
* @param dataShape
* @param step
* @param dataSourceType
* @return
*/
private DataSource createDataSource(DataShape dataShape, StepDefinition step, DataSourceType dataSourceType) {
DataShapeKinds dataShapeKind = dataShape.getKind();
DataSource source = null;
if (dataShapeKind.toString().contains("json")) {
source = new JsonDataSource();
source.setUri("atlas:" + "json:" + step.getStep().getId().get());
} else if (dataShapeKind.toString().contains("java")) {
source = new DataSource();
source.setUri("atlas:" + "java:" + step.getStep().getId().get() + "?className=" + dataShape.getType());
} else if (dataShapeKind.toString().contains("xml")) {
source = new XmlDataSource();
// TODO(tplevko): find out how should look the XML datasource definition
}
source.setId(step.getStep().getId().get());
source.setDataSourceType(dataSourceType);
return source;
}
use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.
the class ConcurrencyChaosMonkeyTest method generateMappingURI.
protected URI generateMappingURI() throws Exception {
AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
mapping.setName("mockMapping");
DataSource src = new DataSource();
src.setDataSourceType(DataSourceType.SOURCE);
src.setUri("atlas:java?className=twitter4j.Status");
DataSource tgt = new DataSource();
tgt.setDataSourceType(DataSourceType.TARGET);
tgt.setUri("atlas:java?className=org.apache.camel.salesforce.dto.Contact");
mapping.getDataSource().add(src);
mapping.getDataSource().add(tgt);
Mapping sepMapping = AtlasModelFactory.createMapping(MappingType.SEPARATE);
JavaField jNameField = new JavaField();
jNameField.setName("Name");
jNameField.setPath("User.name");
jNameField.setGetMethod("getName");
jNameField.setFieldType(FieldType.STRING);
JavaField jFirstNameField = new JavaField();
jFirstNameField.setName("FirstName");
jFirstNameField.setPath("FirstName");
jFirstNameField.setSetMethod("setFirstName");
jFirstNameField.setFieldType(FieldType.STRING);
jFirstNameField.setIndex(0);
JavaField jLastNameField = new JavaField();
jLastNameField.setName("LastName");
jLastNameField.setPath("LastName");
jLastNameField.setSetMethod("setLastName");
jLastNameField.setFieldType(FieldType.STRING);
jLastNameField.setIndex(1);
sepMapping.getInputField().add(jNameField);
sepMapping.getOutputField().add(jFirstNameField);
sepMapping.getOutputField().add(jLastNameField);
mapping.getMappings().getMapping().add(sepMapping);
Mapping textDescMapping = AtlasModelFactory.createMapping(MappingType.MAP);
JavaField jTextField = new JavaField();
jTextField.setName("Text");
jTextField.setPath("Text");
jTextField.setGetMethod("getText");
jTextField.setFieldType(FieldType.STRING);
JavaField jDescField = new JavaField();
jDescField.setName("Description");
jDescField.setPath("description");
jDescField.setSetMethod("setDescription");
jDescField.setFieldType(FieldType.STRING);
textDescMapping.getInputField().add(jTextField);
textDescMapping.getOutputField().add(jDescField);
mapping.getMappings().getMapping().add(textDescMapping);
Mapping screenTitleMapping = AtlasModelFactory.createMapping(MappingType.MAP);
JavaField jScreenField = new JavaField();
jScreenField.setName("ScreenName");
jScreenField.setPath("User.screenName");
jScreenField.setGetMethod("getScreenName");
jScreenField.setFieldType(FieldType.STRING);
JavaField jTitleField = new JavaField();
jTitleField.setName("Title");
jTitleField.setPath("Title");
jTitleField.setSetMethod("setTitle");
jTitleField.setFieldType(FieldType.STRING);
screenTitleMapping.getInputField().add(jScreenField);
screenTitleMapping.getOutputField().add(jTitleField);
mapping.getMappings().getMapping().add(screenTitleMapping);
File mappingFile = new File("target/junit-atlasmapping.xml");
atlasContextFactory.getMappingService().saveMappingAsFile(mapping, mappingFile);
return mappingFile.toURI();
}
Aggregations