use of io.atlasmap.v2.Mapping in project syndesis-qe by syndesisio.
the class UiComplexSteps method processMapperSteps.
private void processMapperSteps() {
List<StepDefinition> mappers = steps.getStepDefinitions().stream().filter(s -> s.getStep().getStepKind().equals(StepKind.mapper)).collect(Collectors.toList());
if (mappers.isEmpty()) {
log.debug("There are no mappers in this integration, proceeding...");
} else {
// mapping can be done on steps that preceed mapper step and the single step, which follows the mapper step.
log.info("Found mapper step, creating new atlas mapping.");
for (int i = 0; i < mappers.size(); i++) {
List<StepDefinition> precedingSteps = steps.getStepDefinitions().subList(0, steps.getStepDefinitions().indexOf(mappers.get(i))).stream().filter(s -> s.getConnectorDescriptor().isPresent()).collect(Collectors.toList());
StepDefinition followingStep = steps.getStepDefinitions().get(steps.getStepDefinitions().indexOf(mappers.get(i)) + 1);
if (mappers.get(i).getStep().getConfiguredProperties().containsKey("atlasmapping")) {
// TODO(tplevko): think of some way to substitute placeholders for the step ID's
reflectStepIdsInAtlasMapping(mappers.get(i), precedingSteps, followingStep);
} else {
// TODO(tplevko): fix for more than one preceding step.
mappers.get(i).setStep(atlasGenerator.getAtlasMappingStep(mappers.get(i), precedingSteps, followingStep));
}
}
}
}
use of io.atlasmap.v2.Mapping 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;
}
use of io.atlasmap.v2.Mapping in project syndesis-qe by syndesisio.
the class AtlasMapperGenerator method processTarget.
/**
* Gets input data shape for specified step, which should follow after the mapping.
*
* @param followingStep
* @return
*/
private DataSource processTarget(StepDefinition followingStep) {
DataSource target = null;
DataShape inDataShape = followingStep.getConnectorDescriptor().get().getInputDataShape().get();
target = createDataSource(inDataShape, followingStep, DataSourceType.TARGET);
return target;
}
use of io.atlasmap.v2.Mapping 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;
}
use of io.atlasmap.v2.Mapping 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;
}
Aggregations