use of io.atlasmap.core.DefaultAtlasContextFactory 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);
}
use of io.atlasmap.core.DefaultAtlasContextFactory in project atlasmap by atlasmap.
the class AtlasEndpoint method getOrCreateAtlasContextFactory.
private synchronized AtlasContextFactory getOrCreateAtlasContextFactory() throws Exception {
if (atlasContextFactory == null) {
Properties properties = new Properties();
// load the properties from property file which may overrides the default ones
if (ObjectHelper.isNotEmpty(getPropertiesFile())) {
InputStream reader = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(), getPropertiesFile());
try {
properties.load(reader);
log.info("Loaded the Atlas properties file " + getPropertiesFile());
} finally {
IOHelper.close(reader, getPropertiesFile(), log);
}
log.debug("Initializing AtlasContextFactory with properties {}", properties);
atlasContextFactory = new DefaultAtlasContextFactory(properties);
} else {
atlasContextFactory = DefaultAtlasContextFactory.getInstance();
}
}
return atlasContextFactory;
}
use of io.atlasmap.core.DefaultAtlasContextFactory 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);
}
use of io.atlasmap.core.DefaultAtlasContextFactory in project atlasmap by atlasmap.
the class DefaultAtlasContextTest method testModuleInit.
@Test
public void testModuleInit() {
DefaultAtlasContextFactory factory = DefaultAtlasContextFactory.getInstance();
assertNotNull(factory.getModuleInfoRegistry());
assertEquals(Integer.valueOf(5), Integer.valueOf(factory.getModuleInfoRegistry().size()));
}
Aggregations