Java Code Examples for org.pentaho.di.core.database.DatabaseMeta#clone()
The following examples show how to use
org.pentaho.di.core.database.DatabaseMeta#clone() .
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: BaseStepDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void widgetSelected( SelectionEvent e ) { DatabaseMeta databaseMeta = transMeta.findDatabase( wConnection.getText() ); if ( databaseMeta != null ) { // cloning to avoid spoiling data on cancel or incorrect input DatabaseMeta clone = (DatabaseMeta) databaseMeta.clone(); // setting old Id, so a repository (if it used) could find and replace the existing connection clone.setObjectId( databaseMeta.getObjectId() ); String connectionName = showDbDialogUnlessCancelledOrValid( clone, databaseMeta ); if ( connectionName != null ) { // need to replace the old connection with a new one if ( databaseMeta.isShared() ) { if ( !replaceSharedConnection( databaseMeta, clone ) ) { return; } } transMeta.removeDatabase( transMeta.indexOfDatabase( databaseMeta ) ); transMeta.addDatabase( clone ); reinitConnectionDropDown( wConnection, connectionName ); } } }
Example 2
Source File: SpoonDBDelegate.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void dupeConnection( HasDatabasesInterface hasDatabasesInterface, DatabaseMeta databaseMeta ) { String name = databaseMeta.getName(); int pos = hasDatabasesInterface.indexOfDatabase( databaseMeta ); if ( databaseMeta != null ) { DatabaseMeta databaseMetaCopy = (DatabaseMeta) databaseMeta.clone(); String dupename = BaseMessages.getString( PKG, "Spoon.Various.DupeName" ) + name; databaseMetaCopy.setName( dupename ); getDatabaseDialog().setDatabaseMeta( databaseMetaCopy ); String newname = getDatabaseDialog().open(); if ( newname != null ) { // null: CANCEL databaseMetaCopy.verifyAndModifyDatabaseName( hasDatabasesInterface.getDatabases(), name ); hasDatabasesInterface.addDatabase( pos + 1, databaseMetaCopy ); spoon.addUndoNew( (UndoInterface) hasDatabasesInterface, new DatabaseMeta[] { (DatabaseMeta) databaseMetaCopy.clone() }, new int[] { pos + 1 } ); saveConnection( databaseMetaCopy, Const.VERSION_COMMENT_EDIT_VERSION ); refreshTree(); } } }
Example 3
Source File: JobEntryDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void widgetSelected( SelectionEvent e ) { DatabaseMeta databaseMeta = jobMeta.findDatabase( wConnection.getText() ); if ( databaseMeta != null ) { // cloning to avoid spoiling data on cancel or incorrect input DatabaseMeta clone = (DatabaseMeta) databaseMeta.clone(); String connectionName = showDbDialogUnlessCancelledOrValid( clone, databaseMeta ); if ( connectionName != null ) { // need to replace the old connection with a new one jobMeta.removeDatabase( jobMeta.indexOfDatabase( databaseMeta ) ); jobMeta.addDatabase( clone ); reinitConnectionDropDown( wConnection, connectionName ); } } }
Example 4
Source File: SimplePmdDataFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
private DatabaseMeta getActiveDatabaseMeta( final DatabaseMeta databaseMeta, final DataRow dataRow ) { // retrieve a temporary connection to determine if a dialect change is necessary // for generating the MQL Query. final String user = computeUsername( dataRow ); final String password = computePassword( dataRow ); final Connection connection; try { connection = getConnectionProvider().createConnection( databaseMeta, user, password ); } catch ( final ReportDataFactoryException rdfe ) { return databaseMeta; } try { // if the connection type is not of the current dialect, regenerate the query final DatabaseInterface di = getDatabaseInterface( connection, databaseMeta ); if ( ( di != null ) && !databaseMeta.getPluginId().equals( di.getPluginId() ) ) { // we need to reinitialize our mqlQuery object and reset the query. // note that using this di object wipes out connection info final DatabaseMeta meta = (DatabaseMeta) databaseMeta.clone(); final DatabaseInterface di2 = (DatabaseInterface) di.clone(); di2.setAccessType( databaseMeta.getAccessType() ); di2.setDatabaseName( databaseMeta.getDatabaseName() ); meta.setDatabaseInterface( di2 ); return meta; } else { return databaseMeta; } } finally { if ( connection != null ) { try { connection.close(); } catch ( final SQLException ignored ) { // this is just cleanup logger.debug( "debug", ignored ); //$NON-NLS-1$ } } } }