Search in sources :

Example 6 with BaseMapping

use of io.atlasmap.v2.BaseMapping in project atlasmap by atlasmap.

the class JavaJavaFlatMappingTest method generateJavaJavaFlatMapping.

protected AtlasMapping generateJavaJavaFlatMapping() {
    AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
    atlasMapping.setName("JavaJavaFlatMapping");
    atlasMapping.getDataSource().add(generateDataSource("atlas:java?className=io.atlasmap.java.test.SourceFlatPrimitiveClass", DataSourceType.SOURCE));
    atlasMapping.getDataSource().add(generateDataSource("atlas:java?className=io.atlasmap.java.test.TargetFlatPrimitiveClass", DataSourceType.TARGET));
    List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
    // Add fieldMappings
    for (String fieldName : FLAT_FIELDS) {
        Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
        mfm.getInputField().add(generateJavaField(fieldName));
        mfm.getOutputField().add(generateJavaField(fieldName));
        mappings.add(mfm);
    }
    return atlasMapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping)

Example 7 with BaseMapping

use of io.atlasmap.v2.BaseMapping in project atlasmap by atlasmap.

the class JavaJavaDateTimeMappingTest method doTest.

private void doTest(int offset) throws Exception {
    AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
    atlasMapping.setName("JavaJavaDateTimeMapping");
    addDataSource(atlasMapping, "atlas:java?className=io.atlasmap.java.test.DateTimeClass", DataSourceType.SOURCE);
    addDataSource(atlasMapping, "atlas:java?className=io.atlasmap.java.test.DateTimeClass", DataSourceType.TARGET);
    List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
    for (int i = 0; i < DATE_TIME_FIELDS.length; i++) {
        int targetIndex = offset + i < DATE_TIME_FIELDS.length ? offset + i : offset + i - DATE_TIME_FIELDS.length;
        JavaField sourceField = copyJavaField(DATE_TIME_FIELDS[i]);
        JavaField targetField = copyJavaField(DATE_TIME_FIELDS[targetIndex]);
        if (UNSUPPORTED.containsKey(sourceField.getFieldType()) && UNSUPPORTED.get(sourceField.getFieldType()).equals(targetField.getFieldType())) {
            sourceField = copyJavaField(targetField);
        }
        Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
        mfm.getInputField().add(sourceField);
        mfm.getOutputField().add(targetField);
        mappings.add(mfm);
    }
    AtlasContext context = ((DefaultAtlasContextFactory) atlasContextFactory).createContext(atlasMapping);
    AtlasSession session = context.createSession();
    session.setDefaultSourceDocument(createSource());
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof DateTimeClass);
    validateTarget((DateTimeClass) object);
}
Also used : DefaultAtlasContextFactory(io.atlasmap.core.DefaultAtlasContextFactory) AtlasMapping(io.atlasmap.v2.AtlasMapping) JavaField(io.atlasmap.java.v2.JavaField) DateTimeClass(io.atlasmap.java.test.DateTimeClass) AtlasContext(io.atlasmap.api.AtlasContext) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) AtlasSession(io.atlasmap.api.AtlasSession) BaseMapping(io.atlasmap.v2.BaseMapping)

Example 8 with BaseMapping

use of io.atlasmap.v2.BaseMapping in project atlasmap by atlasmap.

the class JsonJavaFlatMappingTest method generateJsonJavaFlatMapping.

protected AtlasMapping generateJsonJavaFlatMapping() {
    AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
    atlasMapping.setName("JsonJavaFlatMapping");
    atlasMapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.SOURCE));
    atlasMapping.getDataSource().add(generateDataSource("atlas:java?className=io.atlasmap.java.test.TargetFlatPrimitiveClass", DataSourceType.TARGET));
    List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
    // Add fieldMappings
    for (String fieldName : FLAT_FIELDS) {
        Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
        mfm.getInputField().add(generateJsonField("/" + fieldName));
        mfm.getOutputField().add(generateJavaField("/" + fieldName));
        mappings.add(mfm);
    }
    return atlasMapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping)

Example 9 with BaseMapping

use of io.atlasmap.v2.BaseMapping in project atlasmap by atlasmap.

the class JsonJsonFlatMappingTest method generateJsonJsonFlatMapping.

protected AtlasMapping generateJsonJsonFlatMapping() {
    AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
    atlasMapping.setName("JsonJsonFlatMapping");
    atlasMapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.SOURCE));
    atlasMapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.TARGET));
    List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
    // Add fieldMappings
    for (String fieldName : FLAT_FIELDS) {
        Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
        mfm.getInputField().add(generateJsonField(fieldName));
        mfm.getOutputField().add(generateJavaField(fieldName));
        mappings.add(mfm);
    }
    return atlasMapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping)

Example 10 with BaseMapping

use of io.atlasmap.v2.BaseMapping in project atlasmap by atlasmap.

the class XmlJsonFlatMappingTest method generateXmlJsonFlatMapping.

protected AtlasMapping generateXmlJsonFlatMapping() {
    AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
    atlasMapping.setName("XmlJsonFlatMapping");
    atlasMapping.getDataSource().add(generateDataSource("atlas:xml?complexType=XmlFlatPrimitiveAttribute", DataSourceType.SOURCE));
    atlasMapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.TARGET));
    List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
    // Add fieldMappings
    for (String fieldName : FLAT_FIELDS) {
        Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
        mfm.getInputField().add(generateXmlField("/XmlFPA/", fieldName));
        mfm.getOutputField().add(generateJsonField(fieldName));
        mappings.add(mfm);
    }
    return atlasMapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping)

Aggregations

BaseMapping (io.atlasmap.v2.BaseMapping)16 Mapping (io.atlasmap.v2.Mapping)14 AtlasMapping (io.atlasmap.v2.AtlasMapping)13 Field (io.atlasmap.v2.Field)6 Mappings (io.atlasmap.v2.Mappings)4 Test (org.junit.Test)4 Collection (io.atlasmap.v2.Collection)3 AtlasException (io.atlasmap.api.AtlasException)2 JavaField (io.atlasmap.java.v2.JavaField)2 AtlasModule (io.atlasmap.spi.AtlasModule)2 ConstantField (io.atlasmap.v2.ConstantField)2 AtlasContext (io.atlasmap.api.AtlasContext)1 AtlasSession (io.atlasmap.api.AtlasSession)1 AtlasValidationException (io.atlasmap.api.AtlasValidationException)1 DefaultAtlasContextFactory (io.atlasmap.core.DefaultAtlasContextFactory)1 DocumentJavaFieldWriter (io.atlasmap.java.core.DocumentJavaFieldWriter)1 ClassInspectionService (io.atlasmap.java.inspect.ClassInspectionService)1 DateTimeClass (io.atlasmap.java.test.DateTimeClass)1 JavaClass (io.atlasmap.java.v2.JavaClass)1 JavaEnumField (io.atlasmap.java.v2.JavaEnumField)1