Search in sources :

Example 6 with HasDatabasesInterface

use of org.pentaho.di.trans.HasDatabasesInterface in project pentaho-kettle by pentaho.

the class Spoon method exploreDatabase.

public void exploreDatabase() {
    if (RepositorySecurityUI.verifyOperations(shell, rep, RepositoryOperation.EXPLORE_DATABASE)) {
        return;
    }
    // Show a minimal window to allow you to quickly select the database
    // connection to explore
    // 
    List<DatabaseMeta> databases = new ArrayList<>();
    // First load the connections from the loaded file
    // 
    HasDatabasesInterface databasesInterface = getActiveHasDatabasesInterface();
    if (databasesInterface != null) {
        databases.addAll(databasesInterface.getDatabases());
    }
    // 
    if (rep != null) {
        try {
            List<DatabaseMeta> list = rep.readDatabases();
            for (DatabaseMeta databaseMeta : list) {
                int index = databases.indexOf(databaseMeta);
                if (index < 0) {
                    databases.add(databaseMeta);
                } else {
                    databases.set(index, databaseMeta);
                }
            }
        } catch (KettleException e) {
            log.logError("Unexpected repository error", e.getMessage());
        }
    }
    if (databases.size() == 0) {
        return;
    }
    // OK, get a list of all the database names...
    // 
    String[] databaseNames = new String[databases.size()];
    for (int i = 0; i < databases.size(); i++) {
        databaseNames[i] = databases.get(i).getName();
    }
    // show the shell...
    // 
    EnterSelectionDialog dialog = new EnterSelectionDialog(shell, databaseNames, BaseMessages.getString(PKG, "Spoon.ExploreDB.SelectDB.Title"), BaseMessages.getString(PKG, "Spoon.ExploreDB.SelectDB.Message"));
    String name = dialog.open();
    if (name != null) {
        selectionObject = DatabaseMeta.findDatabase(databases, name);
        exploreDB();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ArrayList(java.util.ArrayList) HasDatabasesInterface(org.pentaho.di.trans.HasDatabasesInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 7 with HasDatabasesInterface

use of org.pentaho.di.trans.HasDatabasesInterface in project pentaho-kettle by pentaho.

the class Spoon method createDatabaseWizard.

/**
 * Shows a wizard that creates a new database connection...
 */
public void createDatabaseWizard() {
    HasDatabasesInterface hasDatabasesInterface = getActiveHasDatabasesInterface();
    if (hasDatabasesInterface == null) {
        // nowhere to put the new database
        return;
    }
    CreateDatabaseWizard cdw = new CreateDatabaseWizard();
    DatabaseMeta newDBInfo = cdw.createAndRunDatabaseWizard(shell, props, hasDatabasesInterface.getDatabases());
    if (newDBInfo != null) {
        // finished
        hasDatabasesInterface.addDatabase(newDBInfo);
        refreshTree();
        refreshGraph();
    }
}
Also used : CreateDatabaseWizard(org.pentaho.di.ui.core.database.wizard.CreateDatabaseWizard) HasDatabasesInterface(org.pentaho.di.trans.HasDatabasesInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 8 with HasDatabasesInterface

use of org.pentaho.di.trans.HasDatabasesInterface in project pentaho-kettle by pentaho.

the class SpoonDBDelegate method newConnection.

public void newConnection() {
    HasDatabasesInterface hasDatabasesInterface = spoon.getActiveHasDatabasesInterface();
    if (hasDatabasesInterface == null && spoon.rep == null) {
        return;
    }
    newConnection(hasDatabasesInterface);
}
Also used : HasDatabasesInterface(org.pentaho.di.trans.HasDatabasesInterface)

Example 9 with HasDatabasesInterface

use of org.pentaho.di.trans.HasDatabasesInterface in project pentaho-kettle by pentaho.

the class Spoon method dupeConnection.

public void dupeConnection() {
    final DatabaseMeta databaseMeta = (DatabaseMeta) selectionObject;
    final HasDatabasesInterface hasDatabasesInterface = (HasDatabasesInterface) selectionObjectParent;
    delegates.db.dupeConnection(hasDatabasesInterface, databaseMeta);
}
Also used : HasDatabasesInterface(org.pentaho.di.trans.HasDatabasesInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Aggregations

HasDatabasesInterface (org.pentaho.di.trans.HasDatabasesInterface)9 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)7 ArrayList (java.util.ArrayList)3 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)3 Point (org.pentaho.di.core.gui.Point)3 KettleException (org.pentaho.di.core.exception.KettleException)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 MalformedURLException (java.net.MalformedURLException)1 Hashtable (java.util.Hashtable)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 SWTException (org.eclipse.swt.SWTException)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)1 KettleFileException (org.pentaho.di.core.exception.KettleFileException)1 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)1 KettleRowException (org.pentaho.di.core.exception.KettleRowException)1 KettleValueException (org.pentaho.di.core.exception.KettleValueException)1 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)1 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)1 ImportValidationFeedback (org.pentaho.di.imp.rule.ImportValidationFeedback)1