use of org.pentaho.di.trans.steps.accessoutput.AccessOutputMeta in project pentaho-kettle by pentaho.
the class AccessOutputDialog method getTableName.
private void getTableName() {
AccessOutputMeta meta = new AccessOutputMeta();
getInfo(meta);
Database database = null;
// New class: SelectTableDialog
try {
String realFilename = transMeta.environmentSubstitute(meta.getFilename());
FileObject fileObject = KettleVFS.getFileObject(realFilename, transMeta);
File file = FileUtils.toFile(fileObject.getURL());
if (!file.exists() || !file.isFile()) {
throw new KettleException(BaseMessages.getString(PKG, "AccessOutputMeta.Exception.FileDoesNotExist", realFilename));
}
database = Database.open(file);
Set<String> set = database.getTableNames();
String[] tablenames = set.toArray(new String[set.size()]);
EnterSelectionDialog dialog = new EnterSelectionDialog(shell, tablenames, BaseMessages.getString(PKG, "AccessOutputDialog.Dialog.SelectATable.Title"), BaseMessages.getString(PKG, "AccessOutputDialog.Dialog.SelectATable.Message"));
String tablename = dialog.open();
if (tablename != null) {
wTablename.setText(tablename);
}
} catch (Throwable e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "AccessOutputDialog.UnableToGetListOfTables.Title"), BaseMessages.getString(PKG, "AccessOutputDialog.UnableToGetListOfTables.Message"), e);
} finally {
// Don't forget to close the bugger.
try {
if (database != null) {
database.close();
}
} catch (Exception e) {
// Ignore close errors
}
}
}
Aggregations