Java Code Examples for org.pentaho.di.core.database.DatabaseMeta#getSchemaTableCombination()
The following examples show how to use
org.pentaho.di.core.database.DatabaseMeta#getSchemaTableCombination() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhysicalTableImporter.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 4 votes |
public static PhysicalTable importTableDefinition( Database database, String schemaName, String tableName, String locale ) throws KettleException { UniqueList<PhysicalColumn> fields = new UniqueArrayList<PhysicalColumn>(); String id = tableName; String tablename = tableName; // Remove id = Const.toID( tableName ); // Set the id to a certain standard... id = Settings.getPhysicalTableIDPrefix() + id; if ( Settings.isAnIdUppercase() ) { id = id.toUpperCase(); } PhysicalTable physicalTable = new PhysicalTable( id, schemaName, tableName, database.getDatabaseMeta(), fields ); // Also set a localized description... String niceName = beautifyName( tablename ); physicalTable.getConcept().setName( locale, niceName ); DatabaseMeta dbMeta = database.getDatabaseMeta(); String schemaTableCombination = dbMeta.getSchemaTableCombination( dbMeta.quoteField( schemaName ), dbMeta.quoteField( tableName ) ); RowMetaInterface row = database.getTableFields( schemaTableCombination ); if ( row != null && row.size() > 0 ) { for ( int i = 0; i < row.size(); i++ ) { ValueMetaInterface v = row.getValueMeta( i ); PhysicalColumn physicalColumn = importPhysicalColumnDefinition( v, physicalTable, locale ); try { fields.add( physicalColumn ); } catch ( ObjectAlreadyExistsException e ) { // Don't add this column // TODO: show error dialog. } } } String upper = tablename.toUpperCase(); if ( upper.startsWith( "D_" ) || upper.startsWith( "DIM" ) || upper.endsWith( "DIM" ) ) { physicalTable.setTableType( TableTypeSettings.DIMENSION ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } if ( upper.startsWith( "F_" ) || upper.startsWith( "FACT" ) || upper.endsWith( "FACT" ) ) { physicalTable.setTableType( TableTypeSettings.FACT ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return physicalTable; }
Example 2
Source File: PhysicalTableImporter.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 4 votes |
public static SqlPhysicalTable importTableDefinition( Database database, String schemaName, String tableName, String locale, ImportStrategy importStrategy ) throws KettleException { String id = ( Util.getPhysicalTableIdPrefix() + Util.toId( tableName ) ).toUpperCase(); SqlPhysicalTable physicalTable = new SqlPhysicalTable(); physicalTable.setId( id ); physicalTable.setTargetSchema( schemaName ); List<IPhysicalColumn> fields = physicalTable.getPhysicalColumns(); physicalTable.setTargetTable( tableName ); // id, schemaName, tableName, // database.getDatabaseMeta(), fields); // Also set a localized description... String niceName = beautifyName( tableName ); physicalTable.setName( new LocalizedString( locale, niceName ) ); DatabaseMeta dbMeta = database.getDatabaseMeta(); String schemaTableCombination = dbMeta.getSchemaTableCombination( dbMeta.quoteField( schemaName ), dbMeta.quoteField( tableName ) ); RowMetaInterface row = database.getTableFields( schemaTableCombination ); if ( row != null && row.size() > 0 ) { for ( int i = 0; i < row.size(); i++ ) { ValueMetaInterface v = row.getValueMeta( i ); if ( importStrategy.shouldInclude( v ) ) { IPhysicalColumn physicalColumn = importPhysicalColumnDefinition( v, physicalTable, locale, importStrategy ); fields.add( physicalColumn ); } } } String upper = tableName.toUpperCase(); if ( upper.startsWith( "D_" ) || upper.startsWith( "DIM" ) || upper.endsWith( "DIM" ) ) { physicalTable.setTableType( TableType.DIMENSION ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } if ( upper.startsWith( "F_" ) || upper.startsWith( "FACT" ) || upper.endsWith( "FACT" ) ) { physicalTable.setTableType( TableType.FACT ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return physicalTable; }