use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method prepareTargetField.
protected Field prepareTargetField(Mapping mapping, FieldType type, String path, int index) {
Field field = prepareTargetField(mapping, path);
field.setFieldType(type);
field.setPath(path);
field.setIndex(index);
return field;
}
use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class DefaultAtlasValidationServiceTest method testValidateAtlasMappingFileLookupFieldMappingRefNonExistentNames.
@Test
public void testValidateAtlasMappingFileLookupFieldMappingRefNonExistentNames() {
AtlasMapping mapping = getAtlasMappingWithLookupTables("table1", "table2");
// add one that does not exists
Mapping lookupFieldMapping = AtlasModelFactory.createMapping(MappingType.LOOKUP);
lookupFieldMapping.setLookupTableName("table3");
Field inputField = createInputJavaField("inputName");
Field outputField = createInputJavaField("outputName");
lookupFieldMapping.getInputField().add(inputField);
lookupFieldMapping.getOutputField().add(outputField);
mapping.getMappings().getMapping().add(lookupFieldMapping);
validations.addAll(validationService.validateMapping(mapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class DefaultAtlasValidationServiceTest method testValidateAtlasMappingFileLookupFieldMappingUnusedLookupTable.
@Test
public void testValidateAtlasMappingFileLookupFieldMappingUnusedLookupTable() {
AtlasMapping mapping = getAtlasMappingFullValid();
LookupTables lookupTables = new LookupTables();
mapping.setLookupTables(lookupTables);
LookupTable lookupTable = new LookupTable();
lookupTable.setName("table1");
lookupTable.setDescription("desc_table1");
LookupTable lookupTable2 = new LookupTable();
lookupTable2.setName("table2");
lookupTable2.setDescription("desc_table2");
lookupTables.getLookupTable().add(lookupTable);
lookupTables.getLookupTable().add(lookupTable2);
Mapping lookupFieldMapping = AtlasModelFactory.createMapping(MappingType.LOOKUP);
lookupFieldMapping.setLookupTableName("table1");
Field inputField = createInputJavaField("inputName");
Field outputField = createInputJavaField("outputName");
lookupFieldMapping.getInputField().add(inputField);
lookupFieldMapping.getOutputField().add(outputField);
mapping.getMappings().getMapping().add(lookupFieldMapping);
validations.addAll(validationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors());
assertTrue(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class XmlModule method processTargetFieldMapping.
@Override
public void processTargetFieldMapping(AtlasInternalSession session) throws AtlasException {
Field sourceField = session.head().getSourceField();
Field targetField = session.head().getTargetField();
// Attempt to Auto-detect field type based on input value
if (targetField.getFieldType() == null && sourceField.getValue() != null) {
targetField.setFieldType(getConversionService().fieldTypeFromClass(sourceField.getValue().getClass()));
}
Object outputValue = null;
// Do auto-conversion
if (sourceField.getFieldType() != null && sourceField.getFieldType().equals(targetField.getFieldType())) {
outputValue = sourceField.getValue();
} else if (sourceField.getValue() != null) {
try {
outputValue = getConversionService().convertType(sourceField.getValue(), sourceField.getFormat(), targetField.getFieldType(), targetField.getFormat());
} catch (AtlasConversionException e) {
AtlasUtil.addAudit(session, targetField.getDocId(), String.format("Unable to auto-convert for sT=%s tT=%s tF=%s msg=%s", sourceField.getFieldType(), targetField.getFieldType(), targetField.getPath(), e.getMessage()), targetField.getPath(), AuditStatus.ERROR, null);
return;
}
}
targetField.setValue(outputValue);
LookupTable lookupTable = session.head().getLookupTable();
if (lookupTable != null) {
processLookupField(session, lookupTable, targetField.getValue(), targetField);
}
if (isAutomaticallyProcessOutputFieldActions() && targetField.getActions() != null && targetField.getActions().getActions() != null) {
getFieldActionService().processActions(targetField.getActions(), targetField);
}
XmlFieldWriter writer = session.getFieldWriter(getDocId(), XmlFieldWriter.class);
writer.write(session);
if (LOG.isDebugEnabled()) {
LOG.debug("{}: processTargetFieldMapping completed: SourceField:[docId={}, path={}, type={}, value={}], TargetField:[docId={}, path={}, type={}, value={}]", getDocId(), sourceField.getDocId(), sourceField.getPath(), sourceField.getFieldType(), sourceField.getValue(), targetField.getDocId(), targetField.getPath(), targetField.getFieldType(), targetField.getValue());
}
}
use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class AtlasServiceTest method testActionDeserialization.
@Test
public void testActionDeserialization() throws Exception {
File file = new File("src/test/resources/atlasmapping-actions.json");
AtlasMapping mapping = mapper.readValue(file, AtlasMapping.class);
Mappings mappings = mapping.getMappings();
for (BaseMapping baseMapping : mappings.getMapping()) {
if (MappingType.MAP.equals(baseMapping.getMappingType())) {
List<Field> fields = ((Mapping) baseMapping).getOutputField();
for (Field f : fields) {
if (f.getActions() != null && f.getActions().getActions() != null && !f.getActions().getActions().isEmpty()) {
System.out.println("Found actions: " + f.getActions().getActions().size());
}
}
}
}
}
Aggregations