use of io.atlasmap.v2.Multiplicity in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionService method processAction.
private Field processAction(Action action, ActionProcessor processor, FieldType sourceType, Field field) throws AtlasException {
ActionDetail detail = processor.getActionDetail();
Multiplicity multiplicity = detail.getMultiplicity() != null ? detail.getMultiplicity() : Multiplicity.ONE_TO_ONE;
if (multiplicity == Multiplicity.MANY_TO_ONE) {
return processManyToOne(action, processor, sourceType, field);
}
if (multiplicity == Multiplicity.ONE_TO_MANY) {
if (field instanceof FieldGroup) {
while (field instanceof FieldGroup) {
field = ((FieldGroup) field).getField().get(0);
}
}
return processOneToMany(action, processor, sourceType, field);
}
if (field instanceof FieldGroup) {
return processActionForEachCollectionItem(action, processor, sourceType, (FieldGroup) field);
}
Object value = field.getValue();
if (value != null && !isAssignableFieldType(detail.getSourceType(), sourceType)) {
value = getConversionService().convertType(value, sourceType, detail.getSourceType());
}
value = processor.process(action, value);
field.setFieldType(processor.getActionDetail().getTargetType());
field.setValue(value);
return field;
}
use of io.atlasmap.v2.Multiplicity in project atlasmap by atlasmap.
the class JsonValidationServiceMultiplicityTest method testHappyPath.
@Test
public void testHappyPath() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/atlasmapping-multiplicity-transformation-concatenate-split.json");
assertNotNull(mapping);
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasWarnings(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasInfos(), validationHelper.allValidationsToString());
}
use of io.atlasmap.v2.Multiplicity in project atlasmap by atlasmap.
the class JsonValidationServiceMultiplicityTest method testCollectionInFieldGroup.
@Test
public void testCollectionInFieldGroup() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/atlasmapping-multiplicity-transformation-concatenate-split.json");
for (BaseMapping m : mapping.getMappings().getMapping()) {
Mapping entry = (Mapping) m;
if ("concatenate-from-field-group".equals(entry.getId())) {
JsonField f = new JsonField();
f.setCollectionType(CollectionType.LIST);
f.setFieldType(FieldType.STRING);
f.setPath("/sourceStringList<>");
entry.getInputFieldGroup().getField().add(f);
break;
}
}
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasWarnings(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasInfos(), validationHelper.allValidationsToString());
assertEquals(0, validationHelper.getCount());
}
use of io.atlasmap.v2.Multiplicity in project atlasmap by atlasmap.
the class JsonValidationServiceMultiplicityTest method testCollectionInTargetFields.
@Test
public void testCollectionInTargetFields() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/atlasmapping-multiplicity-transformation-concatenate-split.json");
for (BaseMapping m : mapping.getMappings().getMapping()) {
Mapping entry = (Mapping) m;
if ("split-into-multiple-fields".equals(entry.getId())) {
JsonField f = new JsonField();
f.setCollectionType(CollectionType.LIST);
f.setFieldType(FieldType.STRING);
f.setPath("/targetStringList<>");
entry.getOutputField().add(f);
break;
}
}
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasWarnings(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasInfos(), validationHelper.allValidationsToString());
assertEquals(0, validationHelper.getCount());
}
Aggregations