Search in sources :

Example 11 with UIDatabaseConnection

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection in project pentaho-kettle by pentaho.

the class ConnectionsController method refreshConnectionList.

// package-local visibility for testing purposes
void refreshConnectionList() {
    final List<UIDatabaseConnection> tmpList = new ArrayList<UIDatabaseConnection>();
    Runnable r = new Runnable() {

        @Override
        public void run() {
            try {
                ObjectId[] dbIdList = repository.getDatabaseIDs(false);
                for (ObjectId dbId : dbIdList) {
                    DatabaseMeta dbMeta = repository.loadDatabaseMeta(dbId, null);
                    RepositoryElementMetaInterface repoMeta = repository.getObjectInformation(dbId, RepositoryObjectType.DATABASE);
                    UIDatabaseConnection conn = null;
                    try {
                        conn = UIObjectRegistry.getInstance().constructUIDatabaseConnection(dbMeta, repository);
                    } catch (UIObjectCreationException uoe) {
                        conn = new UIDatabaseConnection(dbMeta, repository);
                    }
                    if (conn != null) {
                        conn.setRepositoryElementMetaInterface(repoMeta);
                        tmpList.add(conn);
                    }
                }
            } catch (KettleException e) {
                if (mainController == null || !mainController.handleLostRepository(e)) {
                    // convert to runtime exception so it bubbles up through the UI
                    throw new RuntimeException(e);
                }
            }
        }
    };
    doWithBusyIndicator(r);
    dbConnectionList.setChildren(tmpList);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) ArrayList(java.util.ArrayList) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) UIObjectCreationException(org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)

Aggregations

UIDatabaseConnection (org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection)11 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)5 StringObjectId (org.pentaho.di.repository.StringObjectId)5 Test (org.junit.Test)4 KettleException (org.pentaho.di.core.exception.KettleException)3 ObjectId (org.pentaho.di.repository.ObjectId)3 ArrayList (java.util.ArrayList)2 MessageBox (org.eclipse.swt.widgets.MessageBox)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 IAclObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject)2 AccessDeniedException (org.pentaho.di.ui.repository.repositoryexplorer.AccessDeniedException)2 List (java.util.List)1 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)1 UIRepositoryObjectAcl (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectAcl)1 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)1 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)1 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)1