use of io.syndesis.qe.entities.StepDefinition in project syndesis-qe by syndesisio.
the class AtlasMapperGenerator method processPrecedingSteps.
/**
* Using output datashape, generates jsonInspectionResponse for steps preceding atlasMapping we want to generate. In
* case, the specification is of JavaClass-type, is only transforms this scpecification into required Field listing.
* The jsonInspectionResponse is stored in StepDefinition.
*/
private void processPrecedingSteps() {
precedingSteps.stream().filter(s -> s.getStep().getAction().isPresent()).forEach(s -> {
String stepSpecification = s.getStep().getAction().get().getOutputDataShape().get().getSpecification();
DataShapeKinds dsKind = s.getStep().getAction().get().getOutputDataShape().get().getKind();
s.setInspectionResponseFields(processDataShapeIntoFields(stepSpecification, dsKind));
});
}
use of io.syndesis.qe.entities.StepDefinition in project syndesis-qe by syndesisio.
the class IntegrationHandler method processAggregateSteps.
/**
* When there is a datamapper before the aggregate, it is needed to adopt the datashape of the step following the aggregate step.
*/
private void processAggregateSteps() {
for (int i = 0; i < steps.getStepDefinitions().size(); i++) {
if (StepKind.aggregate == steps.getStepDefinitions().get(i).getStep().getStepKind()) {
if (StepKind.mapper == steps.getStepDefinitions().get(i - 1).getStep().getStepKind()) {
StepDefinition stepDef = steps.getStepDefinitions().subList(i + 1, steps.getStepDefinitions().size()).stream().filter(sd -> sd.getStep().getAction().isPresent()).findFirst().orElseThrow(() -> new IllegalArgumentException("Unable to find next step with an action defined"));
steps.getStepDefinitions().get(i).setStep(steps.getStepDefinitions().get(i).getStep().updateInputDataShape(stepDef.getStep().getAction().get().getInputDataShape()));
steps.getStepDefinitions().get(i).setStep(steps.getStepDefinitions().get(i).getStep().updateOutputDataShape(stepDef.getStep().getAction().get().getOutputDataShape()));
}
}
}
}
use of io.syndesis.qe.entities.StepDefinition in project syndesis-qe by syndesisio.
the class AbstractStep method createStep.
public void createStep() {
// Some steps do not have connector / connection
Connector connector = properties.get(StepProperty.CONNECTOR_ID) == null ? null : connectorsEndpoint.get((String) properties.get(StepProperty.CONNECTOR_ID));
Connection connection = properties.get(StepProperty.CONNECTION_ID) == null ? null : connectionsEndpoint.get((String) properties.get(StepProperty.CONNECTION_ID));
Action action;
// If the action is not String, then we already have action object, so just use it
if (properties.get(StepProperty.ACTION) != null && !(properties.get(StepProperty.ACTION) instanceof String)) {
action = (Action) properties.get(StepProperty.ACTION);
} else {
// It may not have an action
action = properties.get(StepProperty.ACTION) == null ? null : findConnectorAction(connector, (String) properties.get(StepProperty.ACTION));
if (action != null) {
// Get the action with datashapes configured
action = generateStepAction(action, getConnectorDescriptor(action, (Map) properties.get(StepProperty.PROPERTIES), (String) properties.get(StepProperty.CONNECTION_ID)));
}
}
final Step.Builder stepBuilder = new Step.Builder();
stepBuilder.stepKind(properties.get(StepProperty.KIND) == null ? StepKind.endpoint : (StepKind) properties.get(StepProperty.KIND));
stepBuilder.id(properties.get(StepProperty.STEP_ID) == null ? UUID.randomUUID().toString() : (String) properties.get(StepProperty.STEP_ID));
stepBuilder.name(properties.get(StepProperty.STEP_NAME) == null ? UUID.randomUUID().toString() : (String) properties.get(StepProperty.STEP_NAME));
if (connection != null) {
stepBuilder.connection(connection);
}
if (action != null) {
stepBuilder.action(action);
}
if (properties.get(StepProperty.PROPERTIES) != null) {
stepBuilder.configuredProperties((Map) properties.get(StepProperty.PROPERTIES));
}
if (properties.get(StepProperty.EXTENSION) != null) {
stepBuilder.extension((Extension) properties.get(StepProperty.EXTENSION));
}
if (properties.get(StepProperty.KIND) == StepKind.mapper) {
steps.getStepDefinitions().add(new StepDefinition(stepBuilder.build(), new DataMapperDefinition()));
} else {
steps.getStepDefinitions().add(new StepDefinition(stepBuilder.build()));
}
properties.clear();
}
use of io.syndesis.qe.entities.StepDefinition in project syndesis-qe by syndesisio.
the class UtilitySteps method changeDatashapeTo.
@Given("change {string} datashape of previous step to {string} type with specification {string}")
public void changeDatashapeTo(String direction, String type, String specification) {
Step lastStep = super.getSteps().getLastStepDefinition().getStep();
Step withDatashape = new Step.Builder().createFrom(lastStep).action(super.withCustomDatashape(lastStep.getAction().get(), super.getConnectorDescriptor(lastStep.getAction().get(), lastStep.getConfiguredProperties(), lastStep.getConnection().get().getId().get()), direction, DataShapeKinds.valueOf(type), specification)).build();
StepsStorage steps = super.getSteps();
steps.getStepDefinitions().remove(steps.getStepDefinitions().size() - 1);
steps.getStepDefinitions().add(new StepDefinition(withDatashape));
}
use of io.syndesis.qe.entities.StepDefinition in project syndesis-qe by syndesisio.
the class IntegrationHandler method processMapperSteps.
/**
* This should be updated for more than two steps, when it will work correctly in near future.
*/
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 (StepDefinition mapper : mappers) {
List<StepDefinition> precedingSteps = steps.getStepDefinitions().subList(0, steps.getStepDefinitions().indexOf(mapper));
StepDefinition followingStep = steps.getStepDefinitions().get(steps.getStepDefinitions().indexOf(mapper) + 1);
if (!mapper.getStep().getConfiguredProperties().containsKey("atlasmapping")) {
// TODO(tplevko): fix for more than one preceding step.
amg.setSteps(mapper, precedingSteps, followingStep);
mapper.setStep(amg.getAtlasMappingStep());
}
}
}
}
Aggregations