Search in sources :

Example 46 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class AddSequenceDialog method activeSequence.

private void activeSequence() {
    boolean useDatabase = wUseDatabase.getSelection();
    DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
    wbSequence.setEnabled(databaseMeta == null ? false : useDatabase && databaseMeta.supportsSequences());
}
Also used : DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 47 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class AddSequenceDialog method getSequences.

private void getSequences() {
    DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
    if (databaseMeta != null) {
        Database database = new Database(loggingObject, databaseMeta);
        try {
            database.connect();
            String[] sequences = database.getSequences();
            if (null != sequences && sequences.length > 0) {
                sequences = Const.sortStrings(sequences);
                EnterSelectionDialog dialog = new EnterSelectionDialog(shell, sequences, BaseMessages.getString(PKG, "AddSequenceDialog.SelectSequence.Title", wConnection.getText()), BaseMessages.getString(PKG, "AddSequenceDialog.SelectSequence.Message"));
                String d = dialog.open();
                if (d != null) {
                    wSeqname.setText(Const.NVL(d.toString(), ""));
                }
            } else {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "AddSequenceDialog.NoSequence.Message"));
                mb.setText(BaseMessages.getString(PKG, "AddSequenceDialog.NoSequence.Title"));
                mb.open();
            }
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "AddSequenceDialog.ErrorGettingSequences"), e);
        } finally {
            if (database != null) {
                database.disconnect();
                database = null;
            }
        }
    }
}
Also used : Database(org.pentaho.di.core.database.Database) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 48 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class JobEntryCheckDbConnectionsDialog method addDatabases.

public void addDatabases() {
    connections = new String[jobMeta.nrDatabases()];
    for (int i = 0; i < jobMeta.nrDatabases(); i++) {
        DatabaseMeta ci = jobMeta.getDatabase(i);
        connections[i] = ci.getName();
    }
}
Also used : DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 49 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class SQLStatementTest method testClass.

@Test
public void testClass() throws KettleException {
    final String name = "stepName";
    final DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    final String sql = "sql string";
    final String error = "error";
    SQLStatement statement = new SQLStatement(name, dbMeta, sql);
    assertSame(name, statement.getStepname());
    assertSame(dbMeta, statement.getDatabase());
    assertTrue(statement.hasSQL());
    assertSame(sql, statement.getSQL());
    statement.setStepname(null);
    assertNull(statement.getStepname());
    statement.setDatabase(null);
    assertNull(statement.getDatabase());
    statement.setSQL(null);
    assertNull(statement.getSQL());
    assertFalse(statement.hasSQL());
    assertFalse(statement.hasError());
    statement.setError(error);
    assertTrue(statement.hasError());
    assertSame(error, statement.getError());
}
Also used : DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Example 50 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class JobMeta method getUsedDatabaseMetas.

private Set<DatabaseMeta> getUsedDatabaseMetas() {
    Set<DatabaseMeta> databaseMetas = new HashSet<DatabaseMeta>();
    for (JobEntryCopy jobEntryCopy : getJobCopies()) {
        DatabaseMeta[] dbs = jobEntryCopy.getEntry().getUsedDatabaseConnections();
        if (dbs != null) {
            for (DatabaseMeta db : dbs) {
                databaseMetas.add(db);
            }
        }
    }
    databaseMetas.add(jobLogTable.getDatabaseMeta());
    for (LogTableInterface logTable : getExtraLogTables()) {
        databaseMetas.add(logTable.getDatabaseMeta());
    }
    return databaseMetas;
}
Also used : LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) HashSet(java.util.HashSet)

Aggregations

DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)522 Test (org.junit.Test)133 KettleException (org.pentaho.di.core.exception.KettleException)131 Database (org.pentaho.di.core.database.Database)88 MessageBox (org.eclipse.swt.widgets.MessageBox)66 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)63 TransMeta (org.pentaho.di.trans.TransMeta)57 StepMeta (org.pentaho.di.trans.step.StepMeta)54 ArrayList (java.util.ArrayList)53 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)48 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)44 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)42 SlaveServer (org.pentaho.di.cluster.SlaveServer)33 IMetaStore (org.pentaho.metastore.api.IMetaStore)30 ObjectId (org.pentaho.di.repository.ObjectId)29 DatabaseExplorerDialog (org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog)29 JobMeta (org.pentaho.di.job.JobMeta)26 TransHopMeta (org.pentaho.di.trans.TransHopMeta)26 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)24 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)24