use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class DefaultAtlasValidationService method validateSeparateMapping.
private void validateSeparateMapping(List<Mapping> fieldMappings, List<Validation> validations, Set<String> usedIds) {
for (Mapping fieldMapping : fieldMappings) {
String mappingId = fieldMapping.getId();
validateMappingId(mappingId, usedIds, validations);
Validators.SEPARATE_INPUT_NOT_NULL.get().validate(fieldMapping.getInputField(), validations, mappingId);
if (fieldMapping.getInputField() != null) {
Validators.SEPARATE_INPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getInputField(), validations, mappingId);
// source must be a String type
}
Validators.SEPARATE_OUTPUT_NOT_NULL.get().validate(fieldMapping.getOutputField(), validations, mappingId, ValidationStatus.WARN);
Validators.SEPARATE_OUTPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getOutputField(), validations, mappingId, ValidationStatus.WARN);
if (fieldMapping.getOutputField() != null) {
for (Field field : fieldMapping.getOutputField()) {
Validators.SEPARATE_OUTPUT_FIELD_NOT_NULL.get().validate(field, validations, mappingId);
if (field.getIndex() == null || field.getIndex() < 0) {
Validators.SEPARATE_OUTPUT_FIELD_FIELD_ACTION_INDEX_POSITIVE.get().validate(field.getIndex(), validations, mappingId);
}
}
}
}
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class DefaultAtlasValidationService method validateMapping.
@Override
public List<Validation> validateMapping(AtlasMapping mapping) {
List<Validation> validations = new ArrayList<Validation>();
Validators.MAPPING_NAME.get().validate(mapping.getName(), validations, null);
List<DataSource> dataSources = mapping.getDataSource();
for (DataSource ds : dataSources) {
switch(ds.getDataSourceType()) {
case SOURCE:
Validators.DATASOURCE_SOURCE_URI.get().validate(ds.getUri(), validations, ds.getId());
break;
case TARGET:
Validators.DATASOURCE_TARGET_URI.get().validate(ds.getUri(), validations, ds.getId());
break;
default:
throw new IllegalArgumentException(String.format("Unknown DataSource type '%s'", ds.getDataSourceType()));
}
}
validateFieldMappings(mapping.getMappings(), mapping.getLookupTables(), validations);
return validations;
}
use of io.atlasmap.v2.Validations 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);
}
}
use of io.atlasmap.v2.Validations 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);
}
}
}
use of io.atlasmap.v2.Validations 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);
}
}
}
Aggregations