Search in sources :

Example 6 with DataSource

use of io.atlasmap.v2.DataSource in project java-docs-samples by GoogleCloudPlatform.

the class QuickstartSample method main.

/**
 * List available data sources for the BigQuery Data Transfer service.
 */
public static void main(String... args) throws Exception {
    // Sets your Google Cloud Platform project ID.
    // String projectId = "YOUR_PROJECT_ID";
    String projectId = args[0];
    // GOOGLE_APPLICATION_CREDENTIALS environment variable.
    try (DataTransferServiceClient client = DataTransferServiceClient.create()) {
        // Request the list of available data sources.
        String parent = String.format("projects/%s", projectId);
        ListDataSourcesRequest request = ListDataSourcesRequest.newBuilder().setParent(parent).build();
        ListDataSourcesPagedResponse response = client.listDataSources(request);
        // Print the results.
        System.out.println("Supported Data Sources:");
        for (DataSource dataSource : response.iterateAll()) {
            System.out.println(dataSource.getDisplayName());
            System.out.printf("\tID: %s%n", dataSource.getDataSourceId());
            System.out.printf("\tFull path: %s%n", dataSource.getName());
            System.out.printf("\tDescription: %s%n", dataSource.getDescription());
        }
    }
}
Also used : DataTransferServiceClient(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient) ListDataSourcesPagedResponse(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient.ListDataSourcesPagedResponse) ListDataSourcesRequest(com.google.cloud.bigquery.datatransfer.v1.ListDataSourcesRequest) DataSource(com.google.cloud.bigquery.datatransfer.v1.DataSource)

Example 7 with DataSource

use of io.atlasmap.v2.DataSource in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method processSources.

/**
 * Gets list of output data shapes for preceding steps.
 *
 * @return list of datasources from preceding steps
 */
private List<DataSource> processSources() {
    List<DataSource> sources = new ArrayList<>();
    precedingSteps.stream().filter(s -> s.getStep().getAction().isPresent()).forEach(s -> {
        DataShape outDataShape = s.getStep().getAction().get().getOutputDataShape().get();
        // Steps with "ANY" or "NONE" are ignored for sources and only those that have proper datashape are used
        if (outDataShape.getKind() != DataShapeKinds.ANY && outDataShape.getKind() != DataShapeKinds.NONE) {
            sources.add(createDataSource(outDataShape, s, DataSourceType.SOURCE));
        }
    });
    return sources;
}
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) ArrayList(java.util.ArrayList) DataShape(io.syndesis.common.model.DataShape) DataSource(io.atlasmap.v2.DataSource) JsonDataSource(io.atlasmap.json.v2.JsonDataSource) XmlDataSource(io.atlasmap.xml.v2.XmlDataSource)

Example 8 with DataSource

use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.

the class XmlFieldReaderTest method mockDataSources.

private void mockDataSources(String docId, AtlasInternalSession session) {
    AtlasMapping atlasMapping = mock(AtlasMapping.class);
    List<DataSource> dataSources = new ArrayList<>();
    XmlDataSource xmlDataSource = new XmlDataSource();
    xmlDataSource.setId(docId);
    xmlDataSource.setDataSourceType(DataSourceType.SOURCE);
    XmlNamespaces atlasNamespaces = new XmlNamespaces();
    XmlNamespace xmlNamespaceQ = new XmlNamespace();
    xmlNamespaceQ.setAlias("q");
    xmlNamespaceQ.setUri("http://www.example.com/q/");
    XmlNamespace xmlNamespaceX = new XmlNamespace();
    xmlNamespaceX.setAlias("");
    xmlNamespaceX.setUri("http://www.example.com/x/");
    XmlNamespace xmlNamespaceY = new XmlNamespace();
    xmlNamespaceY.setAlias("y");
    xmlNamespaceY.setUri("http://www.example.com/y/");
    atlasNamespaces.getXmlNamespace().add(xmlNamespaceQ);
    atlasNamespaces.getXmlNamespace().add(xmlNamespaceX);
    atlasNamespaces.getXmlNamespace().add(xmlNamespaceY);
    xmlDataSource.setXmlNamespaces(atlasNamespaces);
    dataSources.add(xmlDataSource);
    when(atlasMapping.getDataSource()).thenReturn(dataSources);
    when(session.getMapping()).thenReturn(atlasMapping);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) XmlNamespace(io.atlasmap.xml.v2.XmlNamespace) ArrayList(java.util.ArrayList) XmlNamespaces(io.atlasmap.xml.v2.XmlNamespaces) DataSource(io.atlasmap.v2.DataSource) XmlDataSource(io.atlasmap.xml.v2.XmlDataSource) XmlDataSource(io.atlasmap.xml.v2.XmlDataSource)

Example 9 with DataSource

use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.

the class AtlasEndpointTest method testDocId.

@Test
public void testDocId() throws Exception {
    List<DataSource> ds = new ArrayList<>();
    DataSource source = new DataSource();
    source.setDataSourceType(DataSourceType.SOURCE);
    source.setId("my-source-doc");
    ds.add(source);
    DataSource target = new DataSource();
    target.setDataSourceType(DataSourceType.TARGET);
    target.setId("my-target-doc");
    ds.add(target);
    perform(ds, "my-source-doc", "my-target-doc", false);
}
Also used : ArrayList(java.util.ArrayList) DataSource(io.atlasmap.v2.DataSource) Test(org.junit.Test)

Example 10 with DataSource

use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.

the class AtlasEndpointTest method noConversionIfJavaDataSource.

@Test(expected = ComparisonFailure.class)
public void noConversionIfJavaDataSource() throws Exception {
    final List<DataSource> dataSources = new ArrayList<>();
    final DataSource dataSource = new DataSource();
    dataSource.setDataSourceType(DataSourceType.SOURCE);
    dataSource.setUri("atlas:java:some.Type");
    dataSources.add(dataSource);
    perform(dataSources, null, null, true);
}
Also used : ArrayList(java.util.ArrayList) DataSource(io.atlasmap.v2.DataSource) Test(org.junit.Test)

Aggregations

DataSource (io.atlasmap.v2.DataSource)54 AtlasMapping (io.atlasmap.v2.AtlasMapping)16 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 AtlasContext (io.atlasmap.api.AtlasContext)5 AtlasSession (io.atlasmap.api.AtlasSession)5 JavaField (io.atlasmap.java.v2.JavaField)5 AtlasException (io.atlasmap.api.AtlasException)4 XmlNamespaces (io.atlasmap.xml.v2.XmlNamespaces)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 AtlasModule (io.atlasmap.spi.AtlasModule)3 HashMap (java.util.HashMap)3 Exchange (org.apache.camel.Exchange)3