Search in sources :

Example 1 with AccessOutputMeta

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
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Database(com.healthmarketscience.jackcess.Database) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) FileObject(org.apache.commons.vfs2.FileObject) File(java.io.File) AccessOutputMeta(org.pentaho.di.trans.steps.accessoutput.AccessOutputMeta) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

Database (com.healthmarketscience.jackcess.Database)1 File (java.io.File)1 FileObject (org.apache.commons.vfs2.FileObject)1 KettleException (org.pentaho.di.core.exception.KettleException)1 AccessOutputMeta (org.pentaho.di.trans.steps.accessoutput.AccessOutputMeta)1 EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1