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());
}
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;
}
}
}
}
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();
}
}
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());
}
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;
}
Aggregations