Search in sources :

Example 31 with DataSource

use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.

the class JavaJavaDateTimeMappingTest method addDataSource.

private void addDataSource(AtlasMapping mapping, String uri, DataSourceType type) {
    DataSource ds = new DataSource();
    ds.setUri(uri);
    ds.setDataSourceType(type);
    mapping.getDataSource().add(ds);
}
Also used : DataSource(io.atlasmap.v2.DataSource)

Example 32 with DataSource

use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.

the class JavaJavaFlatMappingTest method generateDataSource.

protected DataSource generateDataSource(String uri, DataSourceType type) {
    DataSource ds = new DataSource();
    ds.setUri(uri);
    ds.setDataSourceType(type);
    return ds;
}
Also used : DataSource(io.atlasmap.v2.DataSource)

Example 33 with DataSource

use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project atlasmap by atlasmap.

the class JsonJavaFlatMappingTest method generateDataSource.

protected DataSource generateDataSource(String uri, DataSourceType type) {
    DataSource ds = new DataSource();
    ds.setUri(uri);
    ds.setDataSourceType(type);
    return ds;
}
Also used : DataSource(io.atlasmap.v2.DataSource)

Example 34 with DataSource

use of com.google.cloud.bigquery.datatransfer.v1.DataSource in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method getAtlasMappingStep.

/**
 * This method is used to generate the "AtlasMapping" - the atlasMapping contains list of specifications of
 * dataSources and a list of specifications of dataMappings. Both these a must have for a complete and working
 * AtlasMapping.
 *
 * @return step with the mapping defined
 */
public Step getAtlasMappingStep() {
    processPrecedingSteps();
    processFollowingStep();
    AtlasMapping atlasMapping = new AtlasMapping();
    atlasMapping.setMappings(new Mappings());
    for (DataSource s : processSources()) {
        atlasMapping.getDataSource().add(s);
    }
    atlasMapping.setName("REST." + UUID.randomUUID().toString().replaceAll("-", ""));
    atlasMapping.setLookupTables(new LookupTables());
    atlasMapping.setProperties(new Properties());
    atlasMapping.getDataSource().add(processTarget());
    atlasMapping.getMappings().getMapping().addAll(generateBaseMappings());
    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("Unable to write mapper json as string", e);
    }
    return new Step.Builder().stepKind(StepKind.mapper).name(mapping.getStep().getName()).configuredProperties(TestUtils.map("atlasmapping", mapperString)).action(getMapperStepAction(followingStep.getStep().getAction().get().getInputDataShape().get())).id(UUID.randomUUID().toString()).build();
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Mappings(io.atlasmap.v2.Mappings) LookupTables(io.atlasmap.v2.LookupTables) 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 35 with DataSource

use of com.google.cloud.bigquery.datatransfer.v1.DataSource 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

DataSource (io.atlasmap.v2.DataSource)54 AtlasMapping (io.atlasmap.v2.AtlasMapping)15 ArrayList (java.util.ArrayList)14 Mapping (io.atlasmap.v2.Mapping)11 XmlDataSource (io.atlasmap.xml.v2.XmlDataSource)10 Mappings (io.atlasmap.v2.Mappings)8 JsonDataSource (io.atlasmap.json.v2.JsonDataSource)7 Test (org.junit.Test)7 File (java.io.File)6 JavaField (io.atlasmap.java.v2.JavaField)5 AtlasContext (io.atlasmap.api.AtlasContext)4 AtlasSession (io.atlasmap.api.AtlasSession)4 XmlNamespaces (io.atlasmap.xml.v2.XmlNamespaces)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 AtlasException (io.atlasmap.api.AtlasException)3 DataSourceType (io.atlasmap.v2.DataSourceType)3 HashMap (java.util.HashMap)3 AtlasContextFactory (io.atlasmap.api.AtlasContextFactory)2 ADM (io.atlasmap.api.AtlasContextFactory.Format.ADM)2