• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java SqlDataSource类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.pentaho.metadata.model.SqlDataSource的典型用法代码示例。如果您正苦于以下问题:Java SqlDataSource类的具体用法?Java SqlDataSource怎么用?Java SqlDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

SqlDataSource类属于org.pentaho.metadata.model包,在下文中一共展示了SqlDataSource类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createSqlDataSource

点赞 3

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
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;
}
 

开发者ID:jjeb,
项目名称:kettle-trunk,
代码行数:21,
代码来源:MetadataGenerator.java

示例2: testSqlPhysicalModel

点赞 3

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
@Test
public void testSqlPhysicalModel() {

  // this is the minimum physical sql model, it could
  // theoretically be used to execute sql directly.

  SqlPhysicalModel model = new SqlPhysicalModel();
  SqlDataSource dataSource = new SqlDataSource();
  dataSource.setDatabaseName( "SampleData" );
  model.setDatasource( dataSource );
  SqlPhysicalTable table = new SqlPhysicalTable( model );
  model.getPhysicalTables().add( table );
  table.setTargetTableType( TargetTableType.INLINE_SQL );
  table.setTargetTable( "select * from customers" );

  // basic tests

  Assert.assertEquals( "SampleData", model.getDatasource().getDatabaseName() );
  Assert.assertEquals( 1, model.getPhysicalTables().size() );
  Assert.assertEquals( TargetTableType.INLINE_SQL, model.getPhysicalTables().get( 0 ).getTargetTableType() );
  Assert.assertEquals( "select * from customers", model.getPhysicalTables().get( 0 ).getTargetTable() );
  Assert.assertEquals( 1, model.getPhysicalTables().size() );
}
 

开发者ID:pentaho,
项目名称:pentaho-metadata,
代码行数:24,
代码来源:ThinModelIT.java

示例3: createSqlDataSource

点赞 3

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
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;
}
 

开发者ID:pentaho,
项目名称:pentaho-kettle,
代码行数:21,
代码来源:MetadataGenerator.java

示例4: initialize

点赞 2

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
@Test
public void initialize() throws ModelerException {
  KettleModelerSource source = new KettleModelerSource();

  String tableName = "tableName";
  String schemaName = "schemaName";
  String fileName = "fileName";
  String repositoryName = "repositoryName";
  String metaId = "metaId";

  SqlPhysicalTable table = new SqlPhysicalTable();
  SqlDataSource dataSource = new SqlDataSource();
  dataSource.setHostname("hostname");

  SqlPhysicalModel model = new SqlPhysicalModel();
  model.setDatasource(dataSource);
  model.addPhysicalTable(table);

  LogicalModel lm = new LogicalModel();

  Domain domain = new Domain();
  domain.addPhysicalModel(model);
  domain.addLogicalModel(lm);

  // Set the properties KettleModelerSource will look for when extracting values
  lm.setProperty(source.getFilenamePropertyName(), fileName );
  lm.setProperty(source.getRepositoryNamePropertyName(), repositoryName );
  lm.setProperty(source.getMetaIdPropertyName(), metaId );
  table.setProperty("target_table", tableName );
  table.setProperty("target_schema", schemaName );

  source.initialize(domain);

  assertEquals(tableName, source.getTableName());
  assertEquals(schemaName, source.getSchemaName());
  assertEquals(repositoryName, source.getRepositoryName());
  assertEquals(metaId , source.getMetaId());
}
 

开发者ID:pentaho,
项目名称:pdi-agile-bi-plugin,
代码行数:39,
代码来源:KettleModelerSourceTest.java

示例5: convertToLegacy

点赞 2

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
public static DatabaseMeta convertToLegacy( String name, SqlDataSource datasource ) {
  // make sure that the Kettle environment is initialized before DatabaseMeta creation
  try {
    KettleEnvironment.init( false );
  } catch ( KettleException e ) {
    logger.error( "Error initializing the Kettle Environment", e );
    throw new RuntimeException( "Error initializing the Kettle Environment", e );
  }

  DatabaseMeta databaseMeta = new DatabaseMeta();

  databaseMeta.setName( name );

  databaseMeta.setHostname( datasource.getHostname() );
  if ( datasource.getDialectType() == null ) {
    // default to mysql if dialect is null
    databaseMeta.setDatabaseType( "GENERIC" ); //$NON-NLS-1$
  } else {
    databaseMeta.setDatabaseType( datasource.getDialectType() );
  }
  databaseMeta.setAccessType( DatabaseMeta.getAccessType( datasource.getType().toString() ) );
  databaseMeta.setDBName( datasource.getDatabaseName() );
  databaseMeta.setDBPort( datasource.getPort() );
  databaseMeta.setUsername( datasource.getUsername() );
  databaseMeta.setPassword( datasource.getPassword() );
  databaseMeta.setServername( datasource.getServername() );

  // And now load the attributes...
  for ( String key : datasource.getAttributes().keySet() ) {
    databaseMeta.getAttributes().put( key, datasource.getAttributes().get( key ) );
  }
  return databaseMeta;
}
 

开发者ID:pentaho,
项目名称:pentaho-metadata,
代码行数:34,
代码来源:ThinModelConverter.java

示例6: convertFromLegacy

点赞 2

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
public static SqlDataSource convertFromLegacy( DatabaseMeta database ) {
  SqlDataSource dataSource = new SqlDataSource();

  dataSource.setDialectType( database.getDatabaseTypeDesc() );
  dataSource.setDatabaseName( database.environmentSubstitute( database.getDatabaseName() ) );
  dataSource.setHostname( database.environmentSubstitute( database.getHostname() ) );
  dataSource.setPort( database.environmentSubstitute( database.getDatabasePortNumberString() ) );
  dataSource.setUsername( database.environmentSubstitute( database.getUsername() ) );
  dataSource.setPassword( database.environmentSubstitute( database.getPassword() ) );
  dataSource.setServername( database.environmentSubstitute( database.getServername() ) );

  if ( database.getAccessType() == DatabaseMeta.TYPE_ACCESS_JNDI ) {
    dataSource.setType( DataSourceType.values()[database.getAccessType()] );
  } else if ( database.getAccessType() == DatabaseMeta.TYPE_ACCESS_NATIVE ) {
    dataSource.setType( DataSourceType.NATIVE );
  }

  // And now load the attributes...
  if ( database.getAttributes() != null ) {
    for ( Object key : database.getAttributes().keySet() ) {
      dataSource.getAttributes().put( (String) key,
          database.environmentSubstitute( (String) database.getAttributes().get( key ) ) );
    }
  }

  return dataSource;
}
 

开发者ID:pentaho,
项目名称:pentaho-metadata,
代码行数:28,
代码来源:ThinModelConverter.java

示例7: setup

点赞 2

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
@Before
public void setup() {

  String locale = LocaleHelper.getLocale().toString();

  SqlPhysicalModel model = new SqlPhysicalModel();
  SqlDataSource dataSource = new SqlDataSource();
  dataSource.setDatabaseName( "SampleData" );
  model.setDatasource( dataSource );
  SqlPhysicalTable table = new SqlPhysicalTable( model );
  model.getPhysicalTables().add( table );
  table.setTargetTableType( TargetTableType.INLINE_SQL );
  table.setTargetTable( "select * from customers" );
  table.setId( "customers" );

  SqlPhysicalColumn column = new SqlPhysicalColumn( table );
  column.setTargetColumn( "customername" );
  column.setName( new LocalizedString( locale, "Customer Name" ) );
  column.setDescription( new LocalizedString( locale, "Customer Name Desc" ) );
  column.setDataType( DataType.STRING );
  column.setId( "cutomer_customername" );

  table.getPhysicalColumns().add( column );

  LogicalModel logicalModel = new LogicalModel();
  model.setId( "MODEL" );
  model.setName( new LocalizedString( locale, "My Model" ) );
  model.setDescription( new LocalizedString( locale, "A Description of the Model" ) );

  LogicalTable logicalTable = new LogicalTable();
  logicalTable.setId( "BT_CUSTOMERS" );
  logicalTable.setPhysicalTable( table );

  logicalModel.getLogicalTables().add( logicalTable );
  logicalModel.setName( new LocalizedString( locale, "My Model" ) );

  logicalColumn1 = new LogicalColumn();
  logicalColumn1.setId( "LC_CUSTOMERNAME" );
  logicalColumn1.setPhysicalColumn( column );
  logicalColumn1.setAggregationType( AggregationType.COUNT );
  logicalColumn1.setLogicalTable( logicalTable );
  logicalColumn1.setDataType( DataType.STRING );

  logicalColumn2 = new LogicalColumn();
  logicalColumn2.setId( "LC_CUSTOMERNUMBER" );
  logicalColumn2.setAggregationType( AggregationType.COUNT );
  logicalColumn2.setPhysicalColumn( column );
  logicalColumn2.setLogicalTable( logicalTable );
  logicalColumn2.setDataType( DataType.NUMERIC );


  logicalTable.addLogicalColumn( logicalColumn1 );
  logicalTable.addLogicalColumn( logicalColumn2 );


  domain = new Domain();
  domain.addPhysicalModel( model );
  domain.addLogicalModel( logicalModel );

  physicalColumn = column;

  SqlPhysicalColumn column2 = new SqlPhysicalColumn( table );
  column2.setTargetColumn( "customername" );
  column2.setName( new LocalizedString( locale, "Customer Number" ) );
  column2.setDescription( new LocalizedString( locale, "Customer Number" ) );
  column2.setDataType( DataType.NUMERIC );
  column2.setId( "customer_customernumber" );

  physicalColumn2 = column2;

  table.getPhysicalColumns().add( physicalColumn2 );
}
 

开发者ID:pentaho,
项目名称:pdi-agile-bi-plugin,
代码行数:73,
代码来源:WorkspaceTest.java

示例8: testSqlLogicalModel

点赞 2

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
@Test
public void testSqlLogicalModel() {

  String locale = LocaleHelper.getLocale().toString();

  // this sql model is the minimum required for
  // MQL execution

  SqlPhysicalModel model = new SqlPhysicalModel();
  SqlDataSource dataSource = new SqlDataSource();
  dataSource.setDatabaseName( "SampleData" );
  model.setDatasource( dataSource );
  SqlPhysicalTable table = new SqlPhysicalTable( model );
  table.setId( "PT1" );
  model.getPhysicalTables().add( table );
  table.setTargetTableType( TargetTableType.INLINE_SQL );
  table.setTargetTable( "select distinct customername from customers" );

  SqlPhysicalColumn column = new SqlPhysicalColumn( table );
  column.setId( "PC1" );
  column.setTargetColumn( "customername" );
  column.setName( new LocalizedString( locale, "Customer Name" ) );
  column.setDescription( new LocalizedString( locale, "Customer Description" ) );
  column.setDataType( DataType.STRING );

  // logical model

  LogicalModel logicalModel = new LogicalModel();
  model.setId( "MODEL" );
  model.setName( new LocalizedString( locale, "My Model" ) );
  model.setDescription( new LocalizedString( locale, "A Description of the Model" ) );

  LogicalTable logicalTable = new LogicalTable();
  logicalTable.setPhysicalTable( table );

  LogicalColumn logicalColumn = new LogicalColumn();
  logicalColumn.setId( "LC_CUSTOMERNAME" );
  logicalColumn.setPhysicalColumn( column );

  // test name inheritance
  Assert.assertEquals( column.getName().getString( Locale.getDefault().toString() ), logicalColumn.getName()
      .getString( Locale.getDefault().toString() ) );

  // test datatype inheritance
  Assert.assertEquals( column.getDataType(), logicalColumn.getDataType() );

  Category mainCategory = new Category();
  mainCategory.setId( "CATEGORY" );
  mainCategory.setName( new LocalizedString( locale, "Category" ) );

  // replacement for formula / is exact could be
  // target column + target column type (calculated, exact, etc)
}
 

开发者ID:pentaho,
项目名称:pentaho-metadata,
代码行数:54,
代码来源:ThinModelIT.java

示例9: testSerializeSqlPhysicalModel

点赞 2

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
@Test
public void testSerializeSqlPhysicalModel() {

  String locale = LocaleHelper.getLocale().toString();

  SqlPhysicalModel model = new SqlPhysicalModel();
  SqlDataSource dataSource = new SqlDataSource();
  dataSource.setDatabaseName( "SampleData" );
  model.setDatasource( dataSource );
  SqlPhysicalTable table = new SqlPhysicalTable( model );
  model.getPhysicalTables().add( table );
  table.setTargetTableType( TargetTableType.INLINE_SQL );
  table.setTargetTable( "select * from customers" );

  SqlPhysicalColumn column = new SqlPhysicalColumn( table );
  column.setTargetColumn( "customername" );
  column.setName( new LocalizedString( locale, "Customer Name" ) );
  column.setDescription( new LocalizedString( locale, "Customer Name Desc" ) );
  column.setDataType( DataType.STRING );

  table.getPhysicalColumns().add( column );

  LogicalModel logicalModel = new LogicalModel();
  model.setId( "MODEL" );
  model.setName( new LocalizedString( locale, "My Model" ) );
  model.setDescription( new LocalizedString( locale, "A Description of the Model" ) );

  LogicalTable logicalTable = new LogicalTable();
  logicalTable.setPhysicalTable( table );

  logicalModel.getLogicalTables().add( logicalTable );

  LogicalColumn logicalColumn = new LogicalColumn();
  logicalColumn.setId( "LC_CUSTOMERNAME" );
  logicalColumn.setPhysicalColumn( column );

  logicalTable.addLogicalColumn( logicalColumn );

  Category mainCategory = new Category();
  mainCategory.setId( "CATEGORY" );
  mainCategory.setName( new LocalizedString( locale, "Category" ) );
  mainCategory.addLogicalColumn( logicalColumn );

  logicalModel.getCategories().add( mainCategory );

  Domain domain = new Domain();
  domain.addPhysicalModel( model );
  domain.addLogicalModel( logicalModel );

  // basic tests
  SerializationService service = new SerializationService();

  String xml = service.serializeDomain( domain );

  // System.out.println(xml);

  Domain domain2 = service.deserializeDomain( xml );

  Assert.assertEquals( 1, domain2.getPhysicalModels().size() );
  SqlPhysicalModel model2 = (SqlPhysicalModel) domain2.getPhysicalModels().get( 0 );
  Assert.assertEquals( "SampleData", model2.getDatasource().getDatabaseName() );
  Assert.assertEquals( 1, model.getPhysicalTables().size() );
  Assert.assertEquals( TargetTableType.INLINE_SQL, model.getPhysicalTables().get( 0 ).getTargetTableType() );

  Assert.assertEquals( 1, domain.getLogicalModels().size() );
  Assert.assertEquals( 1, domain.getLogicalModels().get( 0 ).getCategories().size() );
  Assert.assertEquals( 1, domain.getLogicalModels().get( 0 ).getCategories().get( 0 ).getLogicalColumns().size() );
  Assert.assertEquals( domain.getLogicalModels().get( 0 ).getLogicalTables().get( 0 ).getLogicalColumns().get( 0 ),
      domain.getLogicalModels().get( 0 ).getCategories().get( 0 ).getLogicalColumns().get( 0 ) );
  Assert.assertEquals( "Customer Name", domain.getLogicalModels().get( 0 ).getCategories().get( 0 )
      .getLogicalColumns().get( 0 ).getName().getString( "en_US" ) );
  Assert.assertEquals( "Customer Name Desc", domain.getLogicalModels().get( 0 ).getCategories().get( 0 )
      .getLogicalColumns().get( 0 ).getDescription().getString( "en_US" ) );

}
 

开发者ID:pentaho,
项目名称:pentaho-metadata,
代码行数:76,
代码来源:ThinModelIT.java

示例10: getBasicDomain

点赞 2

import org.pentaho.metadata.model.SqlDataSource; //导入依赖的package包/类
public static Domain getBasicDomain() {

    String locale = LocaleHelper.getLocale().toString();

    SqlPhysicalModel model = new SqlPhysicalModel();
    SqlDataSource dataSource = new SqlDataSource();
    dataSource.setDatabaseName( "SampleData" );
    model.setDatasource( dataSource );
    SqlPhysicalTable table = new SqlPhysicalTable( model );
    table.setId( "PT1" );
    model.getPhysicalTables().add( table );
    table.setTargetTableType( TargetTableType.INLINE_SQL );
    table.setTargetTable( "select * from customers" );

    SqlPhysicalColumn column = new SqlPhysicalColumn( table );
    column.setId( "PC1" );
    column.setTargetColumn( "customername" );
    column.setName( new LocalizedString( locale, "Customer Name" ) );
    column.setDescription( new LocalizedString( locale, "Customer Name Desc" ) );
    column.setDataType( DataType.STRING );
    table.getPhysicalColumns().add( column );

    LogicalModel logicalModel = new LogicalModel();
    logicalModel.setId( "MODEL" );
    logicalModel.setName( new LocalizedString( locale, "My Model" ) );
    logicalModel.setDescription( new LocalizedString( locale, "A Description of the Model" ) );

    LogicalTable logicalTable = new LogicalTable();
    logicalTable.setId( "LT" );
    logicalTable.setPhysicalTable( table );
    logicalTable.setLogicalModel( logicalModel );

    logicalModel.getLogicalTables().add( logicalTable );

    LogicalColumn logicalColumn = new LogicalColumn();
    logicalColumn.setId( "LC_CUSTOMERNAME" );
    logicalColumn.setPhysicalColumn( column );
    logicalColumn.setLogicalTable( logicalTable );
    logicalTable.addLogicalColumn( logicalColumn );

    Category mainCategory = new Category( logicalModel );
    mainCategory.setId( "CATEGORY" );
    mainCategory.setName( new LocalizedString( locale, "Category" ) );
    mainCategory.addLogicalColumn( logicalColumn );

    logicalModel.getCategories().add( mainCategory );

    Domain domain = new Domain();
    domain.setId( "DOMAIN" );
    domain.addPhysicalModel( model );
    domain.addLogicalModel( logicalModel );

    return domain;
  }
 

开发者ID:pentaho,
项目名称:pentaho-metadata,
代码行数:55,
代码来源:TestHelper.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)