Search in sources :

Example 1 with DataSourceType

use of org.pentaho.metadata.model.SqlDataSource.DataSourceType in project pentaho-kettle by pentaho.

the class MetadataGenerator method createSqlDataSource.

private SqlDataSource createSqlDataSource(DatabaseMeta databaseMeta) {
    SqlDataSource dataSource = new SqlDataSource();
    dataSource.setDatabaseName(databaseMeta.getDatabaseName());
    dataSource.setHostname(databaseMeta.getHostname());
    dataSource.setUsername(databaseMeta.getUsername());
    dataSource.setPassword(databaseMeta.getPassword());
    dataSource.setPort(databaseMeta.getDatabasePortNumberString());
    dataSource.setAttributes(databaseMeta.getExtraOptions());
    DataSourceType dataSourceType;
    switch(databaseMeta.getAccessType()) {
        case DatabaseMeta.TYPE_ACCESS_NATIVE:
            dataSourceType = DataSourceType.NATIVE;
            break;
        case DatabaseMeta.TYPE_ACCESS_ODBC:
            dataSourceType = DataSourceType.ODBC;
            break;
        case DatabaseMeta.TYPE_ACCESS_JNDI:
            dataSourceType = DataSourceType.JNDI;
            break;
        case DatabaseMeta.TYPE_ACCESS_OCI:
            dataSourceType = DataSourceType.OCI;
            break;
        default:
            dataSourceType = DataSourceType.CUSTOM;
            break;
    }
    dataSource.setType(dataSourceType);
    return dataSource;
}
Also used : DataSourceType(org.pentaho.metadata.model.SqlDataSource.DataSourceType) SqlDataSource(org.pentaho.metadata.model.SqlDataSource)

Aggregations

SqlDataSource (org.pentaho.metadata.model.SqlDataSource)1 DataSourceType (org.pentaho.metadata.model.SqlDataSource.DataSourceType)1