Search in sources :

Example 6 with DataShapeKinds

use of io.syndesis.common.model.DataShapeKinds in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method createDataSource.

/**
 * Used to generate data source elements for atlasMapping. There are three types of them: Java, Json, XML.
 *
 * @param dataShape datashape of the processed step
 * @param step step definition
 * @param dataSourceType datasource type
 * @return datasource
 */
private DataSource createDataSource(DataShape dataShape, StepDefinition step, DataSourceType dataSourceType) {
    DataShapeKinds dataShapeKind = dataShape.getKind();
    DataSource source = null;
    if (dataShapeKind.toString().contains("json")) {
        source = new JsonDataSource();
        source.setUri("atlas:" + "json:" + step.getStep().getId().get());
    } else if (dataShapeKind.toString().contains("java")) {
        source = new DataSource();
        source.setUri("atlas:" + "java:" + step.getStep().getId().get() + "?className=" + dataShape.getType());
    } else if (dataShapeKind.toString().contains("xml")) {
        source = new XmlDataSource();
        source.setUri("atlas:xml:" + step.getStep().getId().get());
        XmlNamespaces xmlNamespaces = new XmlNamespaces();
        // Init the array, so that we don't have the null value
        xmlNamespaces.getXmlNamespace();
        ((XmlDataSource) source).setXmlNamespaces(xmlNamespaces);
    } else {
        fail("Unknown datashape kind " + dataShapeKind.toString());
    }
    source.setId(step.getStep().getId().get());
    source.setDataSourceType(dataSourceType);
    return source;
}
Also used : JsonDataSource(io.atlasmap.json.v2.JsonDataSource) DataShapeKinds(io.syndesis.common.model.DataShapeKinds) XmlNamespaces(io.atlasmap.xml.v2.XmlNamespaces) DataSource(io.atlasmap.v2.DataSource) JsonDataSource(io.atlasmap.json.v2.JsonDataSource) XmlDataSource(io.atlasmap.xml.v2.XmlDataSource) XmlDataSource(io.atlasmap.xml.v2.XmlDataSource)

Aggregations

DataShapeKinds (io.syndesis.common.model.DataShapeKinds)6 JsonDataSource (io.atlasmap.json.v2.JsonDataSource)3 DataSource (io.atlasmap.v2.DataSource)3 XmlDataSource (io.atlasmap.xml.v2.XmlDataSource)3 XmlNamespaces (io.atlasmap.xml.v2.XmlNamespaces)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)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 JsonInspectionResponse (io.atlasmap.json.v2.JsonInspectionResponse)1 AtlasMapping (io.atlasmap.v2.AtlasMapping)1 BaseMapping (io.atlasmap.v2.BaseMapping)1 DataSourceType (io.atlasmap.v2.DataSourceType)1 Field (io.atlasmap.v2.Field)1 LookupTables (io.atlasmap.v2.LookupTables)1 Mapping (io.atlasmap.v2.Mapping)1