Java Code Examples for org.pentaho.di.core.database.DatabaseMeta#setDisplayName()
The following examples show how to use
org.pentaho.di.core.database.DatabaseMeta#setDisplayName() .
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: TransTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void testFindDatabaseWithEncodedConnectionName() { DatabaseMeta dbMeta1 = new DatabaseMeta( "encoded_DBConnection", "Oracle", "localhost", "access", "test", "111", "test", "test" ); dbMeta1.setDisplayName( "encoded.DBConnection" ); meta.addDatabase( dbMeta1 ); DatabaseMeta dbMeta2 = new DatabaseMeta( "normalDBConnection", "Oracle", "localhost", "access", "test", "111", "test", "test" ); dbMeta2.setDisplayName( "normalDBConnection" ); meta.addDatabase( dbMeta2 ); DatabaseMeta databaseMeta = meta.findDatabase( dbMeta1.getDisplayName() ); assertNotNull( databaseMeta ); assertEquals( "encoded_DBConnection", databaseMeta.getName() ); assertEquals( "encoded.DBConnection", databaseMeta.getDisplayName() ); }
Example 2
Source File: SpoonDBDelegate.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void editConnection( DatabaseMeta databaseMeta ) { HasDatabasesInterface hasDatabasesInterface = spoon.getActiveHasDatabasesInterface(); if ( hasDatabasesInterface == null ) { return; // program error, exit just to make sure. } String originalName = databaseMeta.getName(); getDatabaseDialog().setDatabaseMeta( databaseMeta ); getDatabaseDialog().setDatabases( hasDatabasesInterface.getDatabases() ); String newname = getDatabaseDialog().open(); if ( !Utils.isEmpty( newname ) ) { // null: CANCEL databaseMeta.setName( originalName ); databaseMeta = getDatabaseDialog().getDatabaseMeta(); if ( !newname.equals( originalName ) && databaseMeta.findDatabase( hasDatabasesInterface.getDatabases(), newname ) != null ) { databaseMeta.setName( newname.trim() ); DatabaseDialog.showDatabaseExistsDialog( spoon.getShell(), databaseMeta ); databaseMeta.setName( originalName ); databaseMeta.setDisplayName( originalName ); return; } databaseMeta.setName( newname.trim() ); databaseMeta.setDisplayName( newname.trim() ); saveConnection( databaseMeta, Const.VERSION_COMMENT_EDIT_VERSION ); if ( databaseMeta.isShared() ) { sharedObjectSyncUtil.synchronizeConnections( databaseMeta, originalName ); } saveConnection( databaseMeta, Const.VERSION_COMMENT_EDIT_VERSION ); if ( databaseMeta.isShared() ) { sharedObjectSyncUtil.synchronizeConnections( databaseMeta, originalName ); } refreshTree(); } spoon.setShellText(); }
Example 3
Source File: DatabaseDelegate.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public DatabaseMeta assemble( RepositoryFile file, NodeRepositoryFileData data, VersionSummary version ) throws KettleException { DatabaseMeta databaseMeta = (DatabaseMeta) dataNodeToElement( data.getNode() ); String fileName = file.getName(); if ( fileName.endsWith( ".kdb" ) ) { fileName = fileName.substring( 0, fileName.length() - 4 ); } databaseMeta.setChangedDate( file.getLastModifiedDate() ); databaseMeta.setName( fileName ); databaseMeta.setDisplayName( file.getTitle() ); databaseMeta.setObjectId( new StringObjectId( file.getId().toString() ) ); databaseMeta.setObjectRevision( repo.createObjectRevision( version ) ); databaseMeta.clearChanged(); return databaseMeta; }
Example 4
Source File: ConnectionsController.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void createConnection() { try { DatabaseMeta databaseMeta = new DatabaseMeta(); databaseMeta.initializeVariablesFrom( null ); getDatabaseDialog().setDatabaseMeta( databaseMeta ); String dbName = getDatabaseDialog().open(); if ( dbName != null ) { dbName = dbName.trim(); databaseMeta.setName( dbName ); databaseMeta.setDisplayName( dbName ); getDatabaseDialog().setDatabaseMeta( databaseMeta ); if ( !dbName.isEmpty() ) { // See if this user connection exists... ObjectId idDatabase = repository.getDatabaseID( dbName ); if ( idDatabase == null ) { repository.insertLogEntry( BaseMessages.getString( PKG, "ConnectionsController.Message.CreatingDatabase", getDatabaseDialog() .getDatabaseMeta().getName() ) ); repository.save( getDatabaseDialog().getDatabaseMeta(), Const.VERSION_COMMENT_INITIAL_VERSION, null ); reloadLoadedJobsAndTransformations(); } else { showAlreadyExistsMessage(); } } } // We should be able to tell the difference between a cancel and an empty database name // // else { // MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); // mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.MissingName.Message")); // mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.MissingName.Title")); // mb.open(); // } } catch ( KettleException e ) { if ( mainController == null || !mainController.handleLostRepository( e ) ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title" ), BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Message" ), e ); } } finally { refreshConnectionList(); } }
Example 5
Source File: SpoonDBDelegate.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void newConnection( HasDatabasesInterface hasDatabasesInterface ) { DatabaseMeta databaseMeta = new DatabaseMeta(); if ( hasDatabasesInterface instanceof VariableSpace ) { databaseMeta.shareVariablesWith( (VariableSpace) hasDatabasesInterface ); } else { databaseMeta.initializeVariablesFrom( null ); } getDatabaseDialog().setDatabaseMeta( databaseMeta ); String con_name = getDatabaseDialog().open(); if ( !Utils.isEmpty( con_name ) ) { con_name = con_name.trim(); databaseMeta.setName( con_name ); databaseMeta.setDisplayName( con_name ); databaseMeta = getDatabaseDialog().getDatabaseMeta(); if ( databaseMeta.findDatabase( hasDatabasesInterface.getDatabases(), con_name ) == null ) { hasDatabasesInterface.addDatabase( databaseMeta ); spoon.addUndoNew( (UndoInterface) hasDatabasesInterface, new DatabaseMeta[]{(DatabaseMeta) databaseMeta .clone()}, new int[]{hasDatabasesInterface.indexOfDatabase( databaseMeta )} ); if ( spoon.rep != null ) { try { if ( !spoon.rep.getSecurityProvider().isReadOnly() ) { // spoon.rep.getDatabaseID( ) spoon.rep.save( databaseMeta, Const.VERSION_COMMENT_INITIAL_VERSION, null ); } else { throw new KettleException( BaseMessages.getString( PKG, "Spoon.Dialog.Exception.ReadOnlyRepositoryUser" ) ); } } catch ( KettleException e ) { new ErrorDialog( spoon.getShell(), BaseMessages.getString( PKG, "Spoon.Dialog.ErrorSavingConnection.Title" ), BaseMessages.getString( PKG, "Spoon.Dialog.ErrorSavingConnection.Message", databaseMeta.getName() ), e ); } } refreshTree(); } else { DatabaseDialog.showDatabaseExistsDialog( spoon.getShell(), databaseMeta ); } } }