use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionService method internalProcessActions.
protected Field internalProcessActions(Actions actions, Object sourceObject, FieldType targetType) throws AtlasException {
Field processedField = new SimpleField();
processedField.setValue(sourceObject);
processedField.setFieldType(targetType);
if (FieldType.COMPLEX.equals(targetType)) {
return processedField;
}
Object tmpSourceObject = sourceObject;
FieldType sourceType = (sourceObject != null ? getConversionService().fieldTypeFromClass(sourceObject.getClass()) : FieldType.NONE);
if (actions == null || actions.getActions() == null || actions.getActions().isEmpty()) {
if (sourceObject == null) {
return processedField;
}
processedField.setValue(getConversionService().convertType(sourceObject, sourceType, targetType));
processedField.setFieldType(targetType);
return processedField;
}
FieldType currentType = sourceType;
for (Action action : actions.getActions()) {
ActionDetail detail = findActionDetail(action.getDisplayName(), currentType);
if (!detail.getSourceType().equals(currentType) && !FieldType.ANY.equals(detail.getSourceType())) {
tmpSourceObject = getConversionService().convertType(sourceObject, currentType, detail.getSourceType());
}
processedField.setValue(processAction(action, detail, tmpSourceObject));
processedField.setFieldType(detail.getTargetType());
currentType = detail.getTargetType();
}
return processedField;
}
use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class XmlFieldWriterTest method readFromFile.
private AtlasInternalSession readFromFile(String fieldPath, FieldType fieldType, Path path) throws Exception {
String input = new String(Files.readAllBytes(path));
reader.setDocument(input, false);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
xmlField.setPath(fieldPath);
xmlField.setPrimitive(Boolean.TRUE);
xmlField.setFieldType(fieldType);
assertNull(xmlField.getValue());
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(xmlField);
Audits audits = new Audits();
when(session.getAudits()).thenReturn(audits);
reader.read(session);
return session;
}
use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class DefaultAtlasConversionServiceTest method findMatchingConverterByFieldTypes.
@Test
public void findMatchingConverterByFieldTypes() {
assertNotNull(service);
Optional<AtlasConverter<?>> atlasConverter = service.findMatchingConverter(FieldType.STRING, FieldType.BOOLEAN);
assertTrue(atlasConverter.isPresent());
assertNotNull(atlasConverter);
assertEquals(StringConverter.class, atlasConverter.get().getClass());
StringConverter stringConverter = (StringConverter) atlasConverter.get();
assertNotNull(stringConverter);
assertThat("io.atlasmap.converters.StringConverter", is(atlasConverter.get().getClass().getCanonicalName()));
Boolean t = stringConverter.toBoolean("T", null, null);
assertNotNull(t);
assertTrue(t);
Boolean f = stringConverter.toBoolean("F", null, null);
assertNotNull(f);
assertFalse(f);
service.findMatchingConverter(null, FieldType.BOOLEAN);
service.findMatchingConverter(FieldType.STRING, null);
FieldType fieldType = null;
service.findMatchingConverter(fieldType, fieldType);
}
use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class XmlFieldReaderTest method readFromFile.
private AtlasInternalSession readFromFile(String fieldPath, FieldType fieldType, Path path) throws Exception {
String input = new String(Files.readAllBytes(path));
reader.setDocument(input, false);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
xmlField.setPath(fieldPath);
xmlField.setPrimitive(Boolean.TRUE);
xmlField.setFieldType(fieldType);
assertNull(xmlField.getValue());
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(xmlField);
Audits audits = new Audits();
when(session.getAudits()).thenReturn(audits);
reader.read(session);
return session;
}
use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method populateSourceField.
protected Field populateSourceField(Mapping mapping, FieldType type, Object value) {
Field field = new SimpleField();
field.setFieldType(type);
field.setPath("/testPath" + value);
mapping.getInputField().add(field);
reader.sources.put(field.getPath(), value);
return field;
}
Aggregations