@Test public void createConnection_NewName() throws Exception { final String dbName = "name"; when( databaseDialog.open() ).thenReturn( dbName ); when( databaseDialog.getDatabaseMeta() ).thenReturn( new DatabaseMeta() ); when( repository.getDatabaseID( dbName ) ).thenReturn( null ); controller.createConnection(); assertRepositorySavedDb(); }
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() ) { 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(); } } } } 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(); } }
ConnectionsController extends LazilyInitializedController implements IUISupportController { 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() ) { 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(); } } } } 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(); } } }
ConnectionsController extends LazilyInitializedController implements IUISupportController { 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() ) { 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(); } } } } 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(); } } ConnectionsController(); }
ConnectionsController extends LazilyInitializedController implements IUISupportController { 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() ) { 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(); } } } } 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(); } } ConnectionsController(); @Override String getName(); @Override void init( Repository repository ); Repository getRepository(); void setRepReadOnly( boolean isRepReadOnly ); boolean isRepReadOnly(); void createConnection(); void addContextChangeVetoer( ContextChangeVetoer listener ); void removeContextChangeVetoer( ContextChangeVetoer listener ); void editConnection(); void removeConnection(); void setSelectedConnections( List<UIDatabaseConnection> connections ); List<UIDatabaseConnection> getRepositoryConnections(); void setRepositoryConnections( List<UIDatabaseConnection> connections ); void enableButtons( boolean enableNew, boolean enableEdit, boolean enableRemove ); void tabClicked(); }
ConnectionsController extends LazilyInitializedController implements IUISupportController { 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() ) { 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(); } } } } 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(); } } ConnectionsController(); @Override String getName(); @Override void init( Repository repository ); Repository getRepository(); void setRepReadOnly( boolean isRepReadOnly ); boolean isRepReadOnly(); void createConnection(); void addContextChangeVetoer( ContextChangeVetoer listener ); void removeContextChangeVetoer( ContextChangeVetoer listener ); void editConnection(); void removeConnection(); void setSelectedConnections( List<UIDatabaseConnection> connections ); List<UIDatabaseConnection> getRepositoryConnections(); void setRepositoryConnections( List<UIDatabaseConnection> connections ); void enableButtons( boolean enableNew, boolean enableEdit, boolean enableRemove ); void tabClicked();  }