Search in sources :

Example 1 with StepDefinition

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));
    });
}
Also used : JsonInspectionResponse(io.atlasmap.json.v2.JsonInspectionResponse) Action(io.syndesis.common.model.action.Action) Step(io.syndesis.common.model.integration.Step) XmlComplexType(io.atlasmap.xml.v2.XmlComplexType) DataSource(io.atlasmap.v2.DataSource) Autowired(org.springframework.beans.factory.annotation.Autowired) MappingType(io.atlasmap.v2.MappingType) DataMapperStepDefinition(io.syndesis.qe.entities.DataMapperStepDefinition) JsonDataSource(io.atlasmap.json.v2.JsonDataSource) StringUtils(org.apache.commons.lang3.StringUtils) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) ArrayList(java.util.ArrayList) JSONObject(org.json.JSONObject) StepDescriptor(io.syndesis.common.model.action.StepDescriptor) JsonUtils(io.syndesis.common.util.json.JsonUtils) Field(io.atlasmap.v2.Field) XmlInspectionResponse(io.atlasmap.xml.v2.XmlInspectionResponse) StepKind(io.syndesis.common.model.integration.StepKind) JavaClass(io.atlasmap.java.v2.JavaClass) StepDefinition(io.syndesis.qe.entities.StepDefinition) BaseMapping(io.atlasmap.v2.BaseMapping) LookupTables(io.atlasmap.v2.LookupTables) DataShape(io.syndesis.common.model.DataShape) StepAction(io.syndesis.common.model.action.StepAction) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AtlasmapEndpoint(io.syndesis.qe.endpoint.AtlasmapEndpoint) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) DataShapeKinds(io.syndesis.common.model.DataShapeKinds) Properties(io.atlasmap.v2.Properties) DataSourceType(io.atlasmap.v2.DataSourceType) Mapping(io.atlasmap.v2.Mapping) Component(org.springframework.stereotype.Component) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Assertions.fail(org.assertj.core.api.Assertions.fail) TestUtils(io.syndesis.qe.utils.TestUtils) XmlNamespaces(io.atlasmap.xml.v2.XmlNamespaces) AtlasMapping(io.atlasmap.v2.AtlasMapping) JavaField(io.atlasmap.java.v2.JavaField) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) Mappings(io.atlasmap.v2.Mappings) Collections(java.util.Collections) XmlDataSource(io.atlasmap.xml.v2.XmlDataSource) JsonComplexType(io.atlasmap.json.v2.JsonComplexType) DataShapeKinds(io.syndesis.common.model.DataShapeKinds)

Example 2 with StepDefinition

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()));
            }
        }
    }
}
Also used : StepDefinition(io.syndesis.qe.entities.StepDefinition) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint)

Example 3 with StepDefinition

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();
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectorAction(io.syndesis.common.model.action.ConnectorAction) Action(io.syndesis.common.model.action.Action) DataMapperDefinition(io.syndesis.qe.entities.DataMapperDefinition) Connection(io.syndesis.common.model.connection.Connection) StepDefinition(io.syndesis.qe.entities.StepDefinition) Step(io.syndesis.common.model.integration.Step) StepKind(io.syndesis.common.model.integration.StepKind)

Example 4 with StepDefinition

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));
}
Also used : StepsStorage(io.syndesis.qe.storage.StepsStorage) StepDefinition(io.syndesis.qe.entities.StepDefinition) Step(io.syndesis.common.model.integration.Step) Given(io.cucumber.java.en.Given)

Example 5 with StepDefinition

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());
            }
        }
    }
}
Also used : Step(io.syndesis.common.model.integration.Step) Then(io.cucumber.java.en.Then) Autowired(org.springframework.beans.factory.annotation.Autowired) HashSet(java.util.HashSet) MediaType(javax.ws.rs.core.MediaType) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) Verifier(io.syndesis.qe.endpoint.Verifier) Assertions(org.assertj.core.api.Assertions) StepKind(io.syndesis.common.model.integration.StepKind) JsonNode(com.fasterxml.jackson.databind.JsonNode) BadRequestException(javax.ws.rs.BadRequestException) Integration(io.syndesis.common.model.integration.Integration) StepDefinition(io.syndesis.qe.entities.StepDefinition) AtlasMapperGenerator(io.syndesis.qe.datamapper.AtlasMapperGenerator) EndpointClient(io.syndesis.qe.endpoint.client.EndpointClient) When(io.cucumber.java.en.When) StepsStorage(io.syndesis.qe.storage.StepsStorage) Set(java.util.Set) UUID(java.util.UUID) Flow(io.syndesis.common.model.integration.Flow) Entity(javax.ws.rs.client.Entity) Collectors(java.util.stream.Collectors) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) TestUtils(io.syndesis.qe.utils.TestUtils) Exposure(io.syndesis.server.openshift.Exposure) RestTestsUtils(io.syndesis.qe.util.RestTestsUtils) StepDefinition(io.syndesis.qe.entities.StepDefinition)

Aggregations

StepDefinition (io.syndesis.qe.entities.StepDefinition)5 Step (io.syndesis.common.model.integration.Step)4 StepKind (io.syndesis.common.model.integration.StepKind)3 Action (io.syndesis.common.model.action.Action)2 IntegrationsEndpoint (io.syndesis.qe.endpoint.IntegrationsEndpoint)2 StepsStorage (io.syndesis.qe.storage.StepsStorage)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)1 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)1 JavaClass (io.atlasmap.java.v2.JavaClass)1 JavaField (io.atlasmap.java.v2.JavaField)1 JsonComplexType (io.atlasmap.json.v2.JsonComplexType)1 JsonDataSource (io.atlasmap.json.v2.JsonDataSource)1 JsonInspectionResponse (io.atlasmap.json.v2.JsonInspectionResponse)1 AtlasMapping (io.atlasmap.v2.AtlasMapping)1 BaseMapping (io.atlasmap.v2.BaseMapping)1 DataSource (io.atlasmap.v2.DataSource)1