Search in sources :

Example 1 with LookupTables

use of io.atlasmap.v2.LookupTables in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method getAtlasMappingStep.

public Step getAtlasMappingStep(StepDefinition mapping, List<StepDefinition> precedingSteps, StepDefinition followingStep) {
    processPrecedingSteps(precedingSteps);
    processFolowingStep(followingStep);
    List<DataMapperStepDefinition> mappings = mapping.getDataMapperDefinition().get().getDataMapperStepDefinition();
    AtlasMapping atlasMapping = new AtlasMapping();
    atlasMapping.setMappings(new Mappings());
    for (DataSource s : processSources(precedingSteps)) {
        atlasMapping.getDataSource().add(s);
    }
    atlasMapping.setName("REST." + UUID.randomUUID().toString());
    atlasMapping.setLookupTables(new LookupTables());
    atlasMapping.setProperties(new Properties());
    atlasMapping.getDataSource().add(processTarget(followingStep));
    atlasMapping.getMappings().getMapping().addAll(generateBaseMappings(mappings, precedingSteps, followingStep));
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
    String mapperString = null;
    try {
        mapperString = mapper.writeValueAsString(atlasMapping);
        log.debug(mapperString);
    } catch (JsonProcessingException e) {
        log.error("error: {}" + e);
    }
    final Step mapperStep = new Step.Builder().stepKind(StepKind.mapper).configuredProperties(TestUtils.map("atlasmapping", mapperString)).action(getMapperStepAction(followingStep.getConnectorDescriptor().get())).id(UUID.randomUUID().toString()).build();
    return mapperStep;
}
Also used : DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) AtlasMapping(io.atlasmap.v2.AtlasMapping) Mappings(io.atlasmap.v2.Mappings) LookupTables(io.atlasmap.v2.LookupTables) Step(io.syndesis.common.model.integration.Step) Properties(io.atlasmap.v2.Properties) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DataSource(io.atlasmap.v2.DataSource) JsonDataSource(io.atlasmap.json.v2.JsonDataSource) XmlDataSource(io.atlasmap.xml.v2.XmlDataSource)

Example 2 with LookupTables

use of io.atlasmap.v2.LookupTables 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 3 with LookupTables

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

the class BaseValidatorTest method getAtlasMappingWithLookupTables.

protected AtlasMapping getAtlasMappingWithLookupTables(String... names) {
    AtlasMapping mapping = this.getAtlasMappingFullValid();
    LookupTables lookupTables = new LookupTables();
    mapping.setLookupTables(lookupTables);
    for (String name : names) {
        LookupTable lookupTable = new LookupTable();
        lookupTable.setName(name);
        lookupTable.setDescription("desc_".concat(name));
        lookupTables.getLookupTable().add(lookupTable);
        Mapping lookupFieldMapping = AtlasModelFactory.createMapping(MappingType.LOOKUP);
        lookupFieldMapping.setDescription("field_desc_".concat(name));
        lookupFieldMapping.setLookupTableName(name);
        Field inputField = createInputJavaField("inputName");
        Field outputField = createInputJavaField("outputName");
        lookupFieldMapping.getInputField().add(inputField);
        lookupFieldMapping.getOutputField().add(outputField);
        mapping.getMappings().getMapping().add(lookupFieldMapping);
    }
    return mapping;
}
Also used : MockField(io.atlasmap.v2.MockField) Field(io.atlasmap.v2.Field) AtlasMapping(io.atlasmap.v2.AtlasMapping) LookupTables(io.atlasmap.v2.LookupTables) LookupTable(io.atlasmap.v2.LookupTable) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Example 4 with LookupTables

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

the class LookupTableNameValidatorTest method testValidateNoDuplicateNames.

@Test
public void testValidateNoDuplicateNames() {
    LookupTables lookupTables = makeLookupTables();
    lookupTables.getLookupTable().remove(2);
    validator.validate(lookupTables, validations, null);
    assertFalse(validationHelper.hasErrors());
}
Also used : LookupTables(io.atlasmap.v2.LookupTables) Test(org.junit.Test)

Example 5 with LookupTables

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

the class LookupTableNameValidatorTest method testSupportsLookupTables.

@Test
public void testSupportsLookupTables() {
    LookupTables lookupTables = makeLookupTables();
    assertTrue(validator.supports(lookupTables.getClass()));
}
Also used : LookupTables(io.atlasmap.v2.LookupTables) Test(org.junit.Test)

Aggregations

LookupTables (io.atlasmap.v2.LookupTables)10 AtlasMapping (io.atlasmap.v2.AtlasMapping)6 LookupTable (io.atlasmap.v2.LookupTable)6 Test (org.junit.Test)5 Mapping (io.atlasmap.v2.Mapping)4 Field (io.atlasmap.v2.Field)3 Validation (io.atlasmap.v2.Validation)3 MockField (io.atlasmap.v2.MockField)2 BaseValidatorTest (io.atlasmap.validators.BaseValidatorTest)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JsonDataSource (io.atlasmap.json.v2.JsonDataSource)1 BaseMapping (io.atlasmap.v2.BaseMapping)1 DataSource (io.atlasmap.v2.DataSource)1 Mappings (io.atlasmap.v2.Mappings)1 Properties (io.atlasmap.v2.Properties)1 XmlDataSource (io.atlasmap.xml.v2.XmlDataSource)1 Step (io.syndesis.common.model.integration.Step)1 DataMapperStepDefinition (io.syndesis.qe.bdd.entities.DataMapperStepDefinition)1