Search in sources :

Example 16 with JDBCDatasetProperties

use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.

the class JDBCOutputProperties method getRuntimeSetting.

@Override
public AllSetting getRuntimeSetting() {
    // TODO only return the Driver paths is enough to get the getRuntimeInfo works, AllSetting should be removed
    // after refactor
    AllSetting setting = new AllSetting();
    JDBCDatasetProperties datasetProperties = this.getDatasetProperties();
    JDBCDatastoreProperties datastoreProperties = datasetProperties.getDatastoreProperties();
    setting.setDriverPaths(datastoreProperties.getCurrentDriverPaths());
    setting.setDriverClass(datastoreProperties.getCurrentDriverClass());
    setting.setJdbcUrl(datastoreProperties.jdbcUrl.getValue());
    setting.setUsername(datastoreProperties.userId.getValue());
    setting.setPassword(datastoreProperties.password.getValue());
    return setting;
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties)

Example 17 with JDBCDatasetProperties

use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.

the class JdbcDatasetRuntimeTest method createDatasetProperties.

/**
 * @return the properties for this dataset, fully initialized with the default values.
 */
public static JDBCDatasetProperties createDatasetProperties() {
    JDBCDatastoreProperties jdbcDatastoreProperties;
    jdbcDatastoreProperties = new JDBCDatastoreProperties("datastore");
    jdbcDatastoreProperties.init();
    jdbcDatastoreProperties.dbTypes.setValue("DERBY");
    jdbcDatastoreProperties.jdbcUrl.setValue(JDBC_URL);
    JDBCDatasetProperties inputDatasetProperties = new JDBCDatasetProperties("inputDataset");
    inputDatasetProperties.init();
    inputDatasetProperties.setDatastoreProperties(jdbcDatastoreProperties);
    inputDatasetProperties.sql.setValue("select * from " + TABLE_IN);
    return inputDatasetProperties;
}
Also used : JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties)

Example 18 with JDBCDatasetProperties

use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.

the class JdbcDatasetTestIT method createDatasetProperties.

private JDBCDatasetProperties createDatasetProperties(boolean updateSchema) {
    JDBCDatastoreDefinition def = new JDBCDatastoreDefinition();
    JDBCDatastoreProperties datastore = new JDBCDatastoreProperties("datastore");
    datastore.dbTypes.setValue("DERBY");
    datastore.afterDbTypes();
    datastore.jdbcUrl.setValue(allSetting.getJdbcUrl());
    datastore.userId.setValue(allSetting.getUsername());
    datastore.password.setValue(allSetting.getPassword());
    JDBCDatasetProperties dataset = (JDBCDatasetProperties) def.createDatasetProperties(datastore);
    dataset.sql.setValue(DBTestUtils.getSQL(tablename));
    if (updateSchema) {
        dataset.updateSchema();
    }
    return dataset;
}
Also used : JDBCDatastoreDefinition(org.talend.components.jdbc.datastore.JDBCDatastoreDefinition) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties)

Example 19 with JDBCDatasetProperties

use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.

the class JdbcDatasetTestIT method testUpdateSchema.

@Test
public void testUpdateSchema() {
    JDBCDatasetProperties dataset = createDatasetProperties(true);
    Schema schema = dataset.main.schema.getValue();
    Assert.assertNotNull(schema);
    DBTestUtils.testMetadata(schema.getFields(), true);
}
Also used : Schema(org.apache.avro.Schema) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) Test(org.junit.Test)

Example 20 with JDBCDatasetProperties

use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.

the class JDBCOutputPropertiesTest method testGetDatasetProperties.

@Test
public void testGetDatasetProperties() {
    JDBCOutputProperties fixture = new JDBCOutputProperties("output");
    fixture.setDatasetProperties(new JDBCDatasetProperties("dataset"));
    Assert.assertNotNull(fixture.getDatasetProperties());
}
Also used : JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) Test(org.junit.Test)

Aggregations

JDBCDatasetProperties (org.talend.components.jdbc.dataset.JDBCDatasetProperties)28 Test (org.junit.Test)19 JDBCDatastoreProperties (org.talend.components.jdbc.datastore.JDBCDatastoreProperties)12 Schema (org.apache.avro.Schema)8 JDBCDatastoreDefinition (org.talend.components.jdbc.datastore.JDBCDatastoreDefinition)5 JDBCDatasetRuntime (org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime)4 AllSetting (org.talend.components.jdbc.runtime.setting.AllSetting)4 Ignore (org.junit.Ignore)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Response (com.jayway.restassured.response.Response)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 PipelineResult (org.apache.beam.sdk.PipelineResult)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 DatasetRuntime (org.talend.components.common.dataset.runtime.DatasetRuntime)1