Search in sources :

Example 1 with DataMapperStepDefinition

use of io.syndesis.qe.bdd.entities.DataMapperStepDefinition in project syndesis-qe by syndesisio.

the class DataMapperStep method combineDataMapperStep.

@Then("COMBINE using Step (\\d+) and strategy \"([^\"]*)\" into \"([^\"]*)\" and sources$")
public void combineDataMapperStep(int fromStep, String strategy, String targetField, DataTable sourceMappingData) {
    DataMapperStepDefinition newDmStep = new DataMapperStepDefinition();
    newDmStep.setFromStep(fromStep);
    newDmStep.setInputFields(sourceMappingData.asList(String.class));
    newDmStep.setOutputFields(Arrays.asList(targetField));
    newDmStep.setMappingType(MappingType.COMBINE);
    newDmStep.setStrategy(SeparatorType.valueOf(strategy));
    steps.getLastStepDefinition().getDataMapperDefinition().get().getDataMapperStepDefinition().add(newDmStep);
}
Also used : DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) Then(cucumber.api.java.en.Then)

Example 2 with DataMapperStepDefinition

use of io.syndesis.qe.bdd.entities.DataMapperStepDefinition in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method generateSeparateMapping.

private Mapping generateSeparateMapping(DataMapperStepDefinition mappingDef, List<StepDefinition> precedingSteps, StepDefinition followingStep) {
    StepDefinition fromStep = precedingSteps.get(mappingDef.getFromStep() - 1);
    Mapping generatedMapping = new Mapping();
    generatedMapping.setId(UUID.randomUUID().toString());
    generatedMapping.setMappingType(MappingType.SEPARATE);
    generatedMapping.setDelimiter(mappingDef.getStrategy().name());
    List<Field> out = new ArrayList<>();
    for (int i = 0; i < mappingDef.getOutputFields().size(); i++) {
        String def = mappingDef.getOutputFields().get(i);
        Field outField = followingStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(def)).findFirst().get();
        outField.setIndex(i);
        out.add(outField);
    }
    Field in = fromStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(mappingDef.getInputFields().get(0))).findFirst().get();
    out.forEach(f -> f.setDocId(followingStep.getStep().getId().get()));
    in.setDocId(fromStep.getStep().getId().get());
    generatedMapping.getOutputField().addAll(out);
    generatedMapping.getInputField().add(in);
    return generatedMapping;
}
Also used : Field(io.atlasmap.v2.Field) JavaField(io.atlasmap.java.v2.JavaField) ArrayList(java.util.ArrayList) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) AtlasmapEndpoint(io.syndesis.qe.endpoints.AtlasmapEndpoint)

Example 3 with DataMapperStepDefinition

use of io.syndesis.qe.bdd.entities.DataMapperStepDefinition in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method generateMapMapping.

private Mapping generateMapMapping(DataMapperStepDefinition mappingDef, List<StepDefinition> precedingSteps, StepDefinition followingStep) {
    StepDefinition fromStep = precedingSteps.get(mappingDef.getFromStep() - 1);
    Mapping generatedMapping = new Mapping();
    generatedMapping.setId(UUID.randomUUID().toString());
    generatedMapping.setMappingType(MappingType.MAP);
    Field in = fromStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(mappingDef.getInputFields().get(0))).findFirst().get();
    Field out = followingStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(mappingDef.getOutputFields().get(0))).findFirst().get();
    in.setDocId(fromStep.getStep().getId().get());
    out.setDocId(followingStep.getStep().getId().get());
    generatedMapping.getInputField().add(in);
    generatedMapping.getOutputField().add(out);
    return generatedMapping;
}
Also used : Field(io.atlasmap.v2.Field) JavaField(io.atlasmap.java.v2.JavaField) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Example 4 with DataMapperStepDefinition

use of io.syndesis.qe.bdd.entities.DataMapperStepDefinition 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 5 with DataMapperStepDefinition

use of io.syndesis.qe.bdd.entities.DataMapperStepDefinition in project syndesis-qe by syndesisio.

the class DataMapperStep method mapDataMapperStep.

@Then("MAP using Step (\\d+) and field \"([^\"]*)\" to \"([^\"]*)\"")
public void mapDataMapperStep(int fromStep, String fromField, String toField) {
    DataMapperStepDefinition newDmStep = new DataMapperStepDefinition();
    newDmStep.setFromStep(fromStep);
    newDmStep.setInputFields(Arrays.asList(fromField));
    newDmStep.setOutputFields(Arrays.asList(toField));
    newDmStep.setMappingType(MappingType.MAP);
    newDmStep.setStrategy(null);
    steps.getLastStepDefinition().getDataMapperDefinition().get().getDataMapperStepDefinition().add(newDmStep);
}
Also used : DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) Then(cucumber.api.java.en.Then)

Aggregations

DataMapperStepDefinition (io.syndesis.qe.bdd.entities.DataMapperStepDefinition)8 AtlasMapping (io.atlasmap.v2.AtlasMapping)4 StepDefinition (io.syndesis.qe.bdd.entities.StepDefinition)4 Then (cucumber.api.java.en.Then)3 JavaField (io.atlasmap.java.v2.JavaField)3 BaseMapping (io.atlasmap.v2.BaseMapping)3 Field (io.atlasmap.v2.Field)3 Mapping (io.atlasmap.v2.Mapping)3 Step (io.syndesis.common.model.integration.Step)2 AtlasmapEndpoint (io.syndesis.qe.endpoints.AtlasmapEndpoint)2 ArrayList (java.util.ArrayList)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Given (cucumber.api.java.en.Given)1 JsonDataSource (io.atlasmap.json.v2.JsonDataSource)1 DataSource (io.atlasmap.v2.DataSource)1 LookupTables (io.atlasmap.v2.LookupTables)1 MappingType (io.atlasmap.v2.MappingType)1 Mappings (io.atlasmap.v2.Mappings)1 Properties (io.atlasmap.v2.Properties)1