Search in sources :

Example 1 with Actions

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;
}
Also used : Field(io.atlasmap.v2.Field) SimpleField(io.atlasmap.v2.SimpleField) AtlasFieldAction(io.atlasmap.api.AtlasFieldAction) Action(io.atlasmap.v2.Action) ActionDetail(io.atlasmap.v2.ActionDetail) SimpleField(io.atlasmap.v2.SimpleField) FieldType(io.atlasmap.v2.FieldType)

Example 2 with Actions

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());
}
Also used : Field(io.atlasmap.v2.Field) SimpleField(io.atlasmap.v2.SimpleField)

Example 3 with Actions

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;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Actions(io.atlasmap.v2.Actions) StringList(io.atlasmap.v2.StringList) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Example 4 with 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;
}
Also used : Camelize(io.atlasmap.v2.Camelize) TrimLeft(io.atlasmap.v2.TrimLeft) SeparateByUnderscore(io.atlasmap.v2.SeparateByUnderscore) Actions(io.atlasmap.v2.Actions) Length(io.atlasmap.v2.Length) Trim(io.atlasmap.v2.Trim) Lowercase(io.atlasmap.v2.Lowercase) Uppercase(io.atlasmap.v2.Uppercase) TrimRight(io.atlasmap.v2.TrimRight) Capitalize(io.atlasmap.v2.Capitalize) SeparateByDash(io.atlasmap.v2.SeparateByDash)

Example 5 with 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;
}
Also used : Camelize(io.atlasmap.v2.Camelize) TrimLeft(io.atlasmap.v2.TrimLeft) SeparateByUnderscore(io.atlasmap.v2.SeparateByUnderscore) Actions(io.atlasmap.v2.Actions) Length(io.atlasmap.v2.Length) Trim(io.atlasmap.v2.Trim) Lowercase(io.atlasmap.v2.Lowercase) Uppercase(io.atlasmap.v2.Uppercase) TrimRight(io.atlasmap.v2.TrimRight) Capitalize(io.atlasmap.v2.Capitalize) SeparateByDash(io.atlasmap.v2.SeparateByDash)

Aggregations

Actions (io.atlasmap.v2.Actions)15 AtlasMapping (io.atlasmap.v2.AtlasMapping)10 Mapping (io.atlasmap.v2.Mapping)9 Test (org.junit.Test)8 Trim (io.atlasmap.v2.Trim)7 SimpleField (io.atlasmap.v2.SimpleField)5 ActionDetail (io.atlasmap.v2.ActionDetail)4 Capitalize (io.atlasmap.v2.Capitalize)4 Lowercase (io.atlasmap.v2.Lowercase)4 SeparateByDash (io.atlasmap.v2.SeparateByDash)4 SeparateByUnderscore (io.atlasmap.v2.SeparateByUnderscore)4 StringList (io.atlasmap.v2.StringList)4 TrimLeft (io.atlasmap.v2.TrimLeft)4 TrimRight (io.atlasmap.v2.TrimRight)4 Uppercase (io.atlasmap.v2.Uppercase)4 Camelize (io.atlasmap.v2.Camelize)3 Field (io.atlasmap.v2.Field)3 Length (io.atlasmap.v2.Length)3 Mappings (io.atlasmap.v2.Mappings)3 File (java.io.File)3