Search in sources :

Example 6 with AtlasMappingService

use of io.atlasmap.core.AtlasMappingService in project atlasmap by atlasmap.

the class XmlJsonFlatMappingTest method testCreateXmlJsonFlatFieldMapping.

@Test
public void testCreateXmlJsonFlatFieldMapping() throws Exception {
    AtlasMapping atlasMapping = generateXmlJsonFlatMapping();
    AtlasMappingService atlasMappingService = new AtlasMappingService(Arrays.asList("io.atlasmap.v2", "io.atlasmap.json.v2", "io.atlasmap.xml.v2"));
    File path = new File("target/reference-mappings/xmlToJson");
    path.mkdirs();
    atlasMappingService.saveMappingAsFile(atlasMapping, new File(path, "atlasmapping-flatprimitive.xml"));
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) AtlasMappingService(io.atlasmap.core.AtlasMappingService) File(java.io.File) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Example 7 with AtlasMappingService

use of io.atlasmap.core.AtlasMappingService in project atlasmap by atlasmap.

the class JsonJsonFlatMappingTest method testCreateJsonJavaFlatFieldMappings.

@Test
public void testCreateJsonJavaFlatFieldMappings() throws Exception {
    AtlasMapping atlasMapping = generateJsonJsonFlatMapping();
    AtlasMappingService atlasMappingService = new AtlasMappingService(Arrays.asList("io.atlasmap.v2", "io.atlasmap.json.v2"));
    File path = new File("target/reference-mappings/jsonToJson");
    path.mkdirs();
    atlasMappingService.saveMappingAsFile(atlasMapping, new File(path, "atlasmapping-flatprimitive.xml"));
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) AtlasMappingService(io.atlasmap.core.AtlasMappingService) File(java.io.File) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Example 8 with AtlasMappingService

use of io.atlasmap.core.AtlasMappingService in project atlasmap by atlasmap.

the class JavaJavaComplexListTest method testGenerateListMappingBasic.

@Test
public void testGenerateListMappingBasic() throws Exception {
    AtlasMapping a = AtlasModelFactory.createAtlasMapping();
    a.setName("JavaJavaComplexListBase");
    DataSource s = new DataSource();
    s.setDataSourceType(DataSourceType.SOURCE);
    s.setUri("atlas:java?className=io.atlasmap.java.test.SourceOrderList");
    DataSource t = new DataSource();
    t.setDataSourceType(DataSourceType.TARGET);
    t.setUri("atlas:java?className=io.atlasmap.java.test.TargetOrderList");
    JavaField f1 = AtlasJavaModelFactory.createJavaField();
    f1.setPath("/numberOrders");
    f1.setModifiers(null);
    JavaField f2 = AtlasJavaModelFactory.createJavaField();
    f2.setPath("/orderBatchNumber");
    f2.setModifiers(null);
    Mapping m1 = AtlasModelFactory.createMapping(MappingType.MAP);
    m1.getInputField().add(f1);
    m1.getOutputField().add(f1);
    Mapping m2 = AtlasModelFactory.createMapping(MappingType.MAP);
    m2.getInputField().add(f2);
    m2.getOutputField().add(f2);
    JavaCollection cm = new JavaCollection();
    cm.setMappingType(MappingType.COLLECTION);
    cm.setCollectionType(CollectionType.LIST);
    JavaField f3 = AtlasJavaModelFactory.createJavaField();
    f3.setPath("/orders<>/orderId");
    f3.setModifiers(null);
    Mapping m3 = AtlasModelFactory.createMapping(MappingType.MAP);
    m3.getInputField().add(f3);
    m3.getOutputField().add(f3);
    if (cm.getMappings() == null) {
        cm.setMappings(new Mappings());
    }
    cm.getMappings().getMapping().add(m3);
    a.getDataSource().addAll(Arrays.asList(s, t));
    a.getMappings().getMapping().addAll(Arrays.asList(m1, m2, cm));
    AtlasMappingService atlasMappingService = new AtlasMappingService(Arrays.asList("io.atlasmap.v2", "io.atlasmap.java.v2", "io.atlasmap.xml.v2"));
    File path = new File("target/reference-mappings/javaToJava");
    path.mkdirs();
    atlasMappingService.saveMappingAsFile(a, new File(path, "atlasmapping-complex-list-autodetect-base.xml"));
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) JavaField(io.atlasmap.java.v2.JavaField) JavaCollection(io.atlasmap.java.v2.JavaCollection) Mappings(io.atlasmap.v2.Mappings) AtlasMappingService(io.atlasmap.core.AtlasMappingService) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) DataSource(io.atlasmap.v2.DataSource) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Aggregations

AtlasMappingService (io.atlasmap.core.AtlasMappingService)8 AtlasMapping (io.atlasmap.v2.AtlasMapping)8 File (java.io.File)8 Test (org.junit.Test)8 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)7 JavaCollection (io.atlasmap.java.v2.JavaCollection)1 JavaField (io.atlasmap.java.v2.JavaField)1 DataSource (io.atlasmap.v2.DataSource)1 Mapping (io.atlasmap.v2.Mapping)1 Mappings (io.atlasmap.v2.Mappings)1