use of io.atlasmap.v2.ActionDetail 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.ActionDetail in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testProcessActionWithActionActionDetailObject.
@Test
public void testProcessActionWithActionActionDetailObject() throws AtlasException {
ActionDetail actionDetail = null;
Object sourceObject = "String";
Action action = new Trim();
assertEquals(sourceObject, fieldActionsService.processAction(action, actionDetail, sourceObject));
action = new GenerateUUID();
actionDetail = new ActionDetail();
actionDetail.setClassName("io.atlasmap.actions.StringComplexFieldActions");
actionDetail.setSourceType(FieldType.ANY);
actionDetail.setMethod("genareteUUID");
assertNotNull(fieldActionsService.processAction(action, actionDetail, sourceObject));
}
use of io.atlasmap.v2.ActionDetail in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testListActionDetails.
@Test
public void testListActionDetails() {
assertNotNull(fieldActionsService);
List<ActionDetail> actionDetails = fieldActionsService.listActionDetails();
for (ActionDetail d : actionDetails) {
if (d.getParameters() != null) {
System.out.println("Action: " + d.getName());
for (Property prop : d.getParameters().getProperty()) {
System.out.println("\t param: " + prop.getName());
System.out.println("\t type: " + prop.getFieldType().value());
}
}
}
}
use of io.atlasmap.v2.ActionDetail in project atlasmap by atlasmap.
the class OverloadedFieldActionsTest method testListActions.
@Test
public void testListActions() throws Exception {
List<ActionDetail> actions = DefaultAtlasContextFactory.getInstance().getFieldActionService().listActionDetails();
Integer found = 0;
for (ActionDetail d : actions) {
if (d.getName().equals("DayOfWeek")) {
found++;
}
}
assertEquals(Integer.valueOf(2), found);
}
use of io.atlasmap.v2.ActionDetail in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testProcessActionWithActionActionDetailObjectAtlasExceptionNoMethod.
@Test(expected = AtlasException.class)
public void testProcessActionWithActionActionDetailObjectAtlasExceptionNoMethod() throws AtlasException {
Action action = new AbsoluteValue();
Object sourceObject = new Integer("1");
ActionDetail actionDetail = new ActionDetail();
actionDetail.setClassName("io.atlasmap.actions.NumberFieldActions");
actionDetail.setSourceType(FieldType.NUMBER);
// actionDetail.setMethod("absolute");
fieldActionsService.processAction(action, actionDetail, sourceObject);
}
Aggregations