use of io.atlasmap.v2.LookupEntry in project atlasmap by atlasmap.
the class DefaultAtlasContextTest method testLookupTable.
@Test
public void testLookupTable() throws Exception {
LookupTable table = new LookupTable();
table.setName("table");
LookupEntry e = new LookupEntry();
e.setSourceValue("foo");
e.setTargetValue("bar");
table.getLookupEntry().add(e);
context.getLookupTables().put(table.getName(), table);
Mapping m = (Mapping) AtlasModelFactory.createMapping(MappingType.LOOKUP);
mapping.getMappings().getMapping().add(m);
m.setLookupTableName("table");
populateSourceField(m, FieldType.STRING, "foo");
prepareTargetField(m, "/target");
context.process(session);
Assert.assertFalse(printAudit(session), session.hasErrors());
Assert.assertEquals("bar", writer.targets.get("/target"));
}
use of io.atlasmap.v2.LookupEntry in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateLookupTables.
private void generateLookupTables(AtlasMapping atlasMapping) {
LookupTable table = new LookupTable();
table.setName("lookupTable");
table.setDescription("lookupTableDescription");
LookupEntry l1 = new LookupEntry();
l1.setSourceType(FieldType.STRING);
l1.setSourceValue("Foo");
l1.setTargetType(FieldType.STRING);
l1.setTargetValue("Bar");
table.getLookupEntry().add(l1);
atlasMapping.getLookupTables().getLookupTable().add(table);
}
use of io.atlasmap.v2.LookupEntry in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateLookupTables.
private void generateLookupTables(AtlasMapping atlasMapping) {
LookupTable table = new LookupTable();
table.setName("lookupTable");
table.setDescription("lookupTableDescription");
LookupEntry l1 = new LookupEntry();
l1.setSourceType(FieldType.STRING);
l1.setSourceValue("Foo");
l1.setTargetType(FieldType.STRING);
l1.setTargetValue("Bar");
table.getLookupEntry().add(l1);
atlasMapping.getLookupTables().getLookupTable().add(table);
}
use of io.atlasmap.v2.LookupEntry in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateLookupTables.
private void generateLookupTables(AtlasMapping atlasMapping) {
LookupTable table = new LookupTable();
table.setName("lookupTable");
table.setDescription("lookupTableDescription");
LookupEntry l1 = new LookupEntry();
l1.setSourceType(FieldType.STRING);
l1.setSourceValue("Foo");
l1.setTargetType(FieldType.STRING);
l1.setTargetValue("Bar");
table.getLookupEntry().add(l1);
atlasMapping.getLookupTables().getLookupTable().add(table);
}
use of io.atlasmap.v2.LookupEntry in project atlasmap by atlasmap.
the class BaseAtlasModule method processLookupField.
protected void processLookupField(AtlasInternalSession session, LookupTable lookupTable, Object sourceValue, Field targetField) throws AtlasException {
String lookupValue = null;
FieldType lookupType = null;
for (LookupEntry lkp : lookupTable.getLookupEntry()) {
if (lkp.getSourceValue().equals(sourceValue)) {
lookupValue = lkp.getTargetValue();
lookupType = lkp.getTargetType();
break;
}
}
Object targetValue = null;
if (lookupType == null || FieldType.STRING.equals(lookupType)) {
targetValue = lookupValue;
} else {
targetValue = atlasConversionService.convertType(lookupValue, FieldType.STRING, lookupType);
}
if (targetField.getFieldType() != null && !targetField.getFieldType().equals(lookupType)) {
targetValue = atlasConversionService.convertType(targetValue, lookupType, targetField.getFieldType());
}
targetField.setValue(targetValue);
}
Aggregations