use of io.atlasmap.v2.Actions 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.Actions 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 io.atlasmap.v2.Actions in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateAtlasMapping.
protected AtlasMapping generateAtlasMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("junit");
generateXmlDataSource(atlasMapping);
generateLookupTables(atlasMapping);
Actions actions = generateActions();
StringList stringList = new StringList();
stringList.getString().add("XmlAccessorType");
stringList.getString().add("XmlType");
Restrictions restrictions = new Restrictions();
Restriction restriction = new Restriction();
restriction.setType(RestrictionType.LENGTH);
restriction.setValue("100");
restrictions.getRestriction().add(restriction);
Mapping mapping = AtlasModelFactory.createMapping(MappingType.MAP);
XmlField inputField = generateXmlField(actions, stringList, restrictions);
mapping.getInputField().add(inputField);
XmlField outputField = generateXmlField(actions, stringList, restrictions);
mapping.getOutputField().add(outputField);
mapping.setMappingType(MappingType.MAP);
mapping.setDelimiterString(",");
mapping.setAlias("MapPropertyFieldAlias");
mapping.setDelimiter(",");
mapping.setDescription("description");
mapping.setId("id");
mapping.setLookupTableName("lookupTableName");
mapping.setStrategy("strategy");
mapping.setStrategyClassName("strategyClassName");
atlasMapping.getMappings().getMapping().add(mapping);
generateProperties(atlasMapping);
return atlasMapping;
}
use of io.atlasmap.v2.Actions in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateActions.
private Actions generateActions() {
Actions actions = new Actions();
actions.getActions().add(new Camelize());
actions.getActions().add(new Capitalize());
actions.getActions().add(new Length());
actions.getActions().add(new Lowercase());
actions.getActions().add(new SeparateByDash());
actions.getActions().add(new SeparateByUnderscore());
actions.getActions().add(new Trim());
actions.getActions().add(new TrimLeft());
actions.getActions().add(new TrimRight());
actions.getActions().add(new Uppercase());
return actions;
}
use of io.atlasmap.v2.Actions in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateActions.
private Actions generateActions() {
Actions actions = new Actions();
actions.getActions().add(new Camelize());
actions.getActions().add(new Capitalize());
actions.getActions().add(new Length());
actions.getActions().add(new Lowercase());
actions.getActions().add(new SeparateByDash());
actions.getActions().add(new SeparateByUnderscore());
actions.getActions().add(new Trim());
actions.getActions().add(new TrimLeft());
actions.getActions().add(new TrimRight());
actions.getActions().add(new Uppercase());
return actions;
}
Aggregations