Search in sources :

Example 6 with DataSource

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

the class DefaultAtlasContextTest method testInit.

// (expected = AtlasException.class)
@Test
public void testInit() throws AtlasException {
    File file = Paths.get("src" + File.separator + "test" + File.separator + "resources" + File.separator + "atlasmapping.json").toFile();
    DefaultAtlasContext ctx = new DefaultAtlasContext(DefaultAtlasContextFactory.getInstance(), file.toURI());
    ctx.init();
    DataSource dataSource = new DataSource();
    dataSource.setUri("URI");
    mapping.getDataSource().add(dataSource);
    dataSource = new DataSource();
    dataSource.setUri(null);
    mapping.getDataSource().add(dataSource);
    dataSource = new DataSource();
    dataSource.setUri("java:source");
    dataSource.setDataSourceType(DataSourceType.SOURCE);
    dataSource.setId("io.atlasmap.core.DefaultAtlasContext.constants.docId");
    mapping.getDataSource().add(dataSource);
    dataSource = new DataSource();
    dataSource.setUri("java:target");
    dataSource.setDataSourceType(DataSourceType.TARGET);
    dataSource.setId("io.atlasmap.core.DefaultAtlasContext.constants.docId");
    mapping.getDataSource().add(dataSource);
    dataSource = new DataSource();
    dataSource.setUri("java:target");
    dataSource.setDataSourceType(DataSourceType.TARGET);
    dataSource.setId("io.atlasmap.core.DefaultAtlasContext.constants.docId");
    mapping.getDataSource().add(dataSource);
    ctx = new DefaultAtlasContext(DefaultAtlasContextFactory.getInstance(), mapping);
    ctx.getTargetModules().put("io.atlasmap.core.DefaultAtlasContext.constants.docId", new ConstantModule());
    ctx.init();
    @SuppressWarnings("unchecked") Map<String, AtlasModule> targetModules = spy(Map.class);
    when(targetModules.put(any(String.class), any(AtlasModule.class))).thenThrow(new RuntimeException("mockException"));
    ctx.setTargetModules(targetModules);
    ctx.init();
}
Also used : AtlasModule(io.atlasmap.spi.AtlasModule) File(java.io.File) DataSource(io.atlasmap.v2.DataSource) Test(org.junit.jupiter.api.Test)

Example 9 with DataSource

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

the class BaseDefaultAtlasContextTest method init.

@BeforeEach
public void init() throws AtlasException {
    mapping = AtlasTestData.generateAtlasMapping();
    context = new DefaultAtlasContext(DefaultAtlasContextFactory.getInstance(), mapping) {

        protected void init() {
        // hijack initialization
        }
    };
    previewContext = new DefaultAtlasPreviewContext(DefaultAtlasContextFactory.getInstance());
    sourceModule = mockAtlasModule();
    DataSource sds = new DataSource();
    sds.setDataSourceType(DataSourceType.SOURCE);
    sourceModule.setDataSource(sds);
    targetModule = mockAtlasModule();
    DataSource tds = new DataSource();
    tds.setDataSourceType(DataSourceType.TARGET);
    targetModule.setDataSource(tds);
    context.getSourceModules().put(AtlasConstants.DEFAULT_SOURCE_DOCUMENT_ID, sourceModule);
    context.getTargetModules().put(AtlasConstants.DEFAULT_TARGET_DOCUMENT_ID, targetModule);
    ConstantModule constantModule = new ConstantModule();
    constantModule.setConversionService(DefaultAtlasConversionService.getInstance());
    context.getSourceModules().put(AtlasConstants.CONSTANTS_DOCUMENT_ID, constantModule);
    PropertyModule sourcePropertyModule = new PropertyModule(new DefaultAtlasPropertyStrategy());
    sourcePropertyModule.setConversionService(DefaultAtlasConversionService.getInstance());
    context.getSourceModules().put(AtlasConstants.PROPERTIES_SOURCE_DOCUMENT_ID, sourcePropertyModule);
    PropertyModule targetPropertyModule = new PropertyModule(new DefaultAtlasPropertyStrategy());
    targetPropertyModule.setConversionService(DefaultAtlasConversionService.getInstance());
    context.getTargetModules().put(AtlasConstants.PROPERTIES_TARGET_DOCUMENT_ID, targetPropertyModule);
    recreateSession();
}
Also used : DataSource(io.atlasmap.v2.DataSource) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with DataSource

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

the class BaseMarshallerTest method generateMultiSourceMapping.

protected AtlasMapping generateMultiSourceMapping() {
    AtlasMapping mapping = generateSeparateAtlasMapping();
    DataSource source1 = new DataSource();
    source1.setUri("xml:foo1");
    source1.setDataSourceType(DataSourceType.SOURCE);
    source1.setId("xml1");
    DataSource source2 = new DataSource();
    source2.setUri("xml:foo2");
    source2.setDataSourceType(DataSourceType.SOURCE);
    source2.setId("xml2");
    DataSource target = new DataSource();
    target.setUri("xml:bar");
    target.setDataSourceType(DataSourceType.TARGET);
    target.setId("target1");
    mapping.getDataSource().add(source1);
    mapping.getDataSource().add(source2);
    mapping.getDataSource().add(target);
    Mapping fm = (Mapping) mapping.getMappings().getMapping().get(0);
    fm.getInputField().get(0).setDocId("xml1");
    fm.getOutputField().get(0).setDocId("target1");
    fm.getOutputField().get(1).setDocId("target1");
    return mapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) DataSource(io.atlasmap.v2.DataSource)

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