Search in sources :

Example 1 with StartsWith

use of io.atlasmap.v2.StartsWith in project atlasmap by atlasmap.

the class DefaultAtlasFieldActionService method detectFieldActionParameters.

protected Properties detectFieldActionParameters(String actionClassName) throws ClassNotFoundException {
    Class<?> actionClazz = Class.forName(actionClassName);
    Properties props = null;
    for (Method method : actionClazz.getMethods()) {
        // Find setters to avoid the get / is confusion
        if (method.getParameterCount() == 1 && method.getName().startsWith("set")) {
            // We have a parameter
            if (props == null) {
                props = new Properties();
            }
            Property prop = null;
            for (Parameter param : method.getParameters()) {
                prop = new Property();
                prop.setName(camelize(method.getName().substring("set".length())));
                prop.setFieldType(getConversionService().fieldTypeFromClass(param.getType()));
                props.getProperty().add(prop);
            }
        }
    }
    return props;
}
Also used : Parameter(java.lang.reflect.Parameter) Method(java.lang.reflect.Method) Properties(io.atlasmap.v2.Properties) Property(io.atlasmap.v2.Property)

Example 2 with StartsWith

use of io.atlasmap.v2.StartsWith in project atlasmap by atlasmap.

the class StringComplexFieldActionsTest method testStartsWith.

@Test
public void testStartsWith() {
    StartsWith action = new StartsWith();
    action.setString("");
    assertFalse(StringComplexFieldActions.startsWith(action, null));
    assertTrue(StringComplexFieldActions.startsWith(action, ""));
    assertTrue(StringComplexFieldActions.startsWith(action, "foo"));
    action.setString("foo");
    assertFalse(StringComplexFieldActions.startsWith(action, null));
    assertFalse(StringComplexFieldActions.startsWith(action, ""));
    assertTrue(StringComplexFieldActions.startsWith(action, "foo"));
    assertTrue(StringComplexFieldActions.startsWith(action, "foobar"));
    assertFalse(StringComplexFieldActions.startsWith(action, "barfoo"));
}
Also used : StartsWith(io.atlasmap.v2.StartsWith) Test(org.junit.Test)

Example 3 with StartsWith

use of io.atlasmap.v2.StartsWith in project atlasmap by atlasmap.

the class BaseModuleValidationService method validateMapping.

@Override
public List<Validation> validateMapping(AtlasMapping mapping) {
    List<Validation> validations = new ArrayList<>();
    if (getMode() == AtlasModuleMode.UNSET) {
        Validation validation = new Validation();
        validation.setMessage(String.format("No mode specified for %s/%s, skipping module validations", this.getModuleDetail().name(), this.getClass().getSimpleName()));
    }
    if (mapping != null && mapping.getMappings() != null && mapping.getMappings().getMapping() != null && !mapping.getMappings().getMapping().isEmpty()) {
        validateMappingEntries(mapping.getMappings().getMapping(), validations);
    }
    boolean found = false;
    for (DataSource ds : mapping.getDataSource()) {
        if (ds.getUri() != null && ds.getUri().startsWith(getModuleDetail().uri())) {
            found = true;
            break;
        }
    }
    if (!found) {
        Validation validation = new Validation();
        validation.setScope(ValidationScope.DATA_SOURCE);
        validation.setMessage(String.format("No DataSource with '%s' uri specified", getModuleDetail().uri()));
        validation.setStatus(ValidationStatus.ERROR);
        validations.add(validation);
    }
    return validations;
}
Also used : Validation(io.atlasmap.v2.Validation) ArrayList(java.util.ArrayList) DataSource(io.atlasmap.v2.DataSource)

Aggregations

DataSource (io.atlasmap.v2.DataSource)1 Properties (io.atlasmap.v2.Properties)1 Property (io.atlasmap.v2.Property)1 StartsWith (io.atlasmap.v2.StartsWith)1 Validation (io.atlasmap.v2.Validation)1 Method (java.lang.reflect.Method)1 Parameter (java.lang.reflect.Parameter)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1