Search in sources :

Example 6 with Validation

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

the class DefaultAtlasValidationService method validateMappingId.

private void validateMappingId(String id, Set<String> usedIds, List<Validation> validations) {
    if (id == null) {
        return;
    }
    if (usedIds.contains(id)) {
        Validation validation = new Validation();
        validation.setScope(ValidationScope.MAPPING);
        validation.setMessage(String.format("Duplicated mapping ID '%s' is found", id));
        validation.setStatus(ValidationStatus.WARN);
        validations.add(validation);
    } else {
        usedIds.add(id);
    }
}
Also used : Validation(io.atlasmap.v2.Validation)

Example 7 with Validation

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

the class DefaultAtlasValidationService method validateLookupTables.

private void validateLookupTables(List<Mapping> lookupFieldMappings, LookupTables lookupTables, List<Validation> validations, Set<String> usedIds) {
    if (lookupTables != null && lookupTables.getLookupTable() != null && !lookupTables.getLookupTable().isEmpty()) {
        // check for duplicate names
        Validators.LOOKUPTABLE_NAME_CHECK_FOR_DUPLICATE.get().validate(lookupTables, validations, null);
        if (lookupFieldMappings.isEmpty()) {
            Validation validation = new Validation();
            validation.setScope(ValidationScope.LOOKUP_TABLE);
            validation.setMessage("LookupTables are defined but no LookupFields are utilized.");
            validation.setStatus(ValidationStatus.WARN);
            validations.add(validation);
        } else {
            validateLookupFieldMapping(lookupFieldMappings, lookupTables, validations, usedIds);
        }
    }
}
Also used : Validation(io.atlasmap.v2.Validation)

Example 8 with Validation

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

the class AtlasUtil method addAudit.

public static void addAudit(AtlasSession session, Validation validation) {
    Audit audit = new Audit();
    audit.setDocId(validation.getId());
    audit.setMessage(validation.getMessage());
    audit.setStatus(AtlasUtil.toAuditStatus(validation.getStatus()));
}
Also used : Audit(io.atlasmap.v2.Audit)

Example 9 with Validation

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

the class BaseModuleValidationService method populateConversionConcerns.

protected void populateConversionConcerns(String mappingId, AtlasConversionInfo converterAnno, String inputFieldName, String outFieldName, List<Validation> validations) {
    if (converterAnno == null || converterAnno.concerns() == null) {
        return;
    }
    for (AtlasConversionConcern atlasConversionConcern : converterAnno.concerns()) {
        String message = atlasConversionConcern.getMessage(converterAnno);
        if (AtlasConversionConcern.NONE.equals(atlasConversionConcern)) {
            Validation validation = new Validation();
            validation.setScope(ValidationScope.MAPPING);
            validation.setId(mappingId);
            validation.setMessage(message);
            validation.setStatus(ValidationStatus.INFO);
            validations.add(validation);
        } else if (atlasConversionConcern.equals(AtlasConversionConcern.RANGE) || atlasConversionConcern.equals(AtlasConversionConcern.FORMAT) || atlasConversionConcern.equals(AtlasConversionConcern.FRACTIONAL_PART) || atlasConversionConcern.equals(AtlasConversionConcern.TIMEZONE)) {
            Validation validation = new Validation();
            validation.setScope(ValidationScope.MAPPING);
            validation.setId(mappingId);
            validation.setMessage(message);
            validation.setStatus(ValidationStatus.WARN);
            validations.add(validation);
        } else if (atlasConversionConcern.equals(AtlasConversionConcern.UNSUPPORTED)) {
            Validation validation = new Validation();
            validation.setScope(ValidationScope.MAPPING);
            validation.setId(mappingId);
            validation.setMessage(message);
            validation.setStatus(ValidationStatus.ERROR);
            validations.add(validation);
        }
    }
}
Also used : Validation(io.atlasmap.v2.Validation) AtlasConversionConcern(io.atlasmap.spi.AtlasConversionConcern)

Example 10 with Validation

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

the class BaseModuleValidationService method validateField.

@SuppressWarnings("unchecked")
protected void validateField(String mappingId, Field field, FieldDirection direction, List<Validation> validations) {
    if (field == null) {
        Validation validation = new Validation();
        validation.setScope(ValidationScope.MAPPING);
        validation.setId(mappingId);
        validation.setMessage(String.format("%s field %s is null", direction.value(), getFieldName(field)));
        validation.setStatus(ValidationStatus.ERROR);
        validations.add(validation);
    } else if (getFieldType().isAssignableFrom(field.getClass())) {
        validateModuleField(mappingId, (T) field, direction, validations);
    }
}
Also used : Validation(io.atlasmap.v2.Validation)

Aggregations

Validation (io.atlasmap.v2.Validation)39 AtlasMapping (io.atlasmap.v2.AtlasMapping)17 Test (org.junit.Test)17 Mapping (io.atlasmap.v2.Mapping)14 Field (io.atlasmap.v2.Field)7 BaseMapping (io.atlasmap.v2.BaseMapping)6 JavaField (io.atlasmap.java.v2.JavaField)5 Validations (io.atlasmap.v2.Validations)5 DataSource (io.atlasmap.v2.DataSource)3 ArrayList (java.util.ArrayList)3 AtlasConversionService (io.atlasmap.api.AtlasConversionService)2 AtlasConverter (io.atlasmap.api.AtlasConverter)2 AtlasException (io.atlasmap.api.AtlasException)2 JsonField (io.atlasmap.json.v2.JsonField)2 AtlasConversionConcern (io.atlasmap.spi.AtlasConversionConcern)2 AtlasConversionInfo (io.atlasmap.spi.AtlasConversionInfo)2 AtlasModule (io.atlasmap.spi.AtlasModule)2 AtlasModuleDetail (io.atlasmap.spi.AtlasModuleDetail)2 FieldDirection (io.atlasmap.spi.FieldDirection)2 FieldType (io.atlasmap.v2.FieldType)2