use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionService method processActions.
@Override
public void processActions(Actions actions, Field field) throws AtlasException {
Field tmpField = internalProcessActions(actions, field.getValue(), field.getFieldType());
field.setValue(tmpField.getValue());
field.setFieldType(tmpField.getFieldType());
}
use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class DefaultAtlasContext method processCombineField.
private Field processCombineField(DefaultAtlasSession session, Mapping mapping, List<Field> sourceFields, Field targetField) throws AtlasException {
Map<Integer, String> combineValues = null;
for (Field sourceField : sourceFields) {
if (sourceField.getIndex() == null || sourceField.getIndex() < 0) {
AtlasUtil.addAudit(session, targetField.getDocId(), String.format("Combine requires zero or positive Index value to be set on all sourceFields sourceField.path=%s", sourceField.getPath()), targetField.getPath(), AuditStatus.WARN, null);
continue;
}
if (combineValues == null) {
// We need to support a sorted map w/ null values
combineValues = new HashMap<>();
}
if ((sourceField.getFieldType() != null) || (sourceField.getValue() != null)) {
String sourceValue;
try {
sourceValue = (String) factory.getConversionService().convertType(sourceField.getValue(), sourceField.getFormat(), FieldType.STRING, null);
} catch (AtlasConversionException e) {
AtlasUtil.addAudit(session, targetField.getDocId(), String.format("Suitable converter for sourceField.path=%s hasn't been found", sourceField.getPath()), targetField.getPath(), AuditStatus.WARN, null);
sourceValue = sourceField.getValue() != null ? sourceField.getValue().toString() : null;
}
combineValues.put(sourceField.getIndex(), sourceValue);
continue;
}
}
String combinedValue = null;
StringDelimiter delimiter = StringDelimiter.fromName(mapping.getDelimiter());
if (delimiter != null) {
combinedValue = session.getAtlasContext().getContextFactory().getCombineStrategy().combineValues(combineValues, delimiter);
} else {
combinedValue = session.getAtlasContext().getContextFactory().getCombineStrategy().combineValues(combineValues);
}
Field answer = AtlasModelFactory.cloneFieldToSimpleField(sourceFields.get(0));
if (combinedValue == null || combinedValue.trim().isEmpty()) {
LOG.debug(String.format("Empty combined string for Combine mapping targetField.path=%s", targetField.getPath()));
} else {
answer.setValue(combinedValue);
}
return answer;
}
use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class DefaultAtlasContext method processSeparateField.
private List<Field> processSeparateField(DefaultAtlasSession session, Mapping mapping, Field sourceField) throws AtlasException {
List<Field> answer = new ArrayList<>();
String sourceValue;
try {
sourceValue = (String) factory.getConversionService().convertType(sourceField.getValue(), sourceField.getFormat(), FieldType.STRING, null);
} catch (AtlasConversionException e) {
AtlasUtil.addAudit(session, sourceField.getDocId(), String.format("Suitable converter for sourceField.path=%s hasn't been found", sourceField.getPath()), sourceField.getPath(), AuditStatus.WARN, null);
sourceValue = sourceField.getValue().toString();
}
List<String> separatedValues = null;
StringDelimiter delimiter = StringDelimiter.fromName(mapping.getDelimiter());
if (mapping.getDelimiter() != null) {
separatedValues = session.getAtlasContext().getContextFactory().getSeparateStrategy().separateValue(sourceValue, delimiter);
} else {
separatedValues = session.getAtlasContext().getContextFactory().getSeparateStrategy().separateValue(sourceValue);
}
if (separatedValues == null || separatedValues.isEmpty()) {
LOG.debug(String.format("Empty string for Separate mapping sourceField.path=%s", sourceField.getPath()));
} else {
for (String separatedValue : separatedValues) {
SimpleField simpleField = AtlasModelFactory.cloneFieldToSimpleField(sourceField);
simpleField.setValue(separatedValue);
simpleField.setFieldType(FieldType.STRING);
answer.add(simpleField);
}
}
return answer;
}
use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class DefaultAtlasValidationService method validateCombineMapping.
private void validateCombineMapping(List<Mapping> fieldMappings, List<Validation> validations, Set<String> usedIds) {
for (Mapping fieldMapping : fieldMappings) {
String mappingId = fieldMapping.getId();
validateMappingId(mappingId, usedIds, validations);
Validators.COMBINE_OUTPUT_NOT_NULL.get().validate(fieldMapping.getOutputField(), validations, mappingId);
if (fieldMapping.getOutputField() != null) {
Validators.COMBINE_OUTPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getOutputField(), validations, mappingId);
// source must be a String type
}
Validators.COMBINE_INPUT_NOT_NULL.get().validate(fieldMapping.getInputField(), validations, mappingId, ValidationStatus.WARN);
Validators.COMBINE_INPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getInputField(), validations, mappingId, ValidationStatus.WARN);
if (fieldMapping.getInputField() != null) {
for (Field field : fieldMapping.getInputField()) {
Validators.COMBINE_INPUT_FIELD_NOT_NULL.get().validate(field, validations, mappingId);
if (field.getIndex() == null || field.getIndex() < 0) {
Validators.COMBINE_INPUT_FIELD_FIELD_ACTION_INDEX_POSITIVE.get().validate(field.getIndex(), validations, mappingId);
}
}
}
}
}
use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class DefaultAtlasValidationService method validateSeparateMapping.
private void validateSeparateMapping(List<Mapping> fieldMappings, List<Validation> validations, Set<String> usedIds) {
for (Mapping fieldMapping : fieldMappings) {
String mappingId = fieldMapping.getId();
validateMappingId(mappingId, usedIds, validations);
Validators.SEPARATE_INPUT_NOT_NULL.get().validate(fieldMapping.getInputField(), validations, mappingId);
if (fieldMapping.getInputField() != null) {
Validators.SEPARATE_INPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getInputField(), validations, mappingId);
// source must be a String type
}
Validators.SEPARATE_OUTPUT_NOT_NULL.get().validate(fieldMapping.getOutputField(), validations, mappingId, ValidationStatus.WARN);
Validators.SEPARATE_OUTPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getOutputField(), validations, mappingId, ValidationStatus.WARN);
if (fieldMapping.getOutputField() != null) {
for (Field field : fieldMapping.getOutputField()) {
Validators.SEPARATE_OUTPUT_FIELD_NOT_NULL.get().validate(field, validations, mappingId);
if (field.getIndex() == null || field.getIndex() < 0) {
Validators.SEPARATE_OUTPUT_FIELD_FIELD_ACTION_INDEX_POSITIVE.get().validate(field.getIndex(), validations, mappingId);
}
}
}
}
}
Aggregations