Search in sources :

Example 1 with PreviewRowsDialog

use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog in project pentaho-cassandra-plugin by pentaho.

the class CassandraInputDialog method preview.

private void preview() {
    CassandraInputMeta oneMeta = new CassandraInputMeta();
    getInfo(oneMeta);
    // Turn off execute for each incoming row (if set). Query is still going to
    // be stuffed if the user has specified field replacement (i.e. ?{...}) in
    // the query string
    oneMeta.setExecuteForEachIncomingRow(false);
    if (!checkForUnresolved(oneMeta, BaseMessages.getString(PKG, "CassandraInputDialog.Warning.Message.CassandraQueryContainsUnresolvedVarsFieldSubs.PreviewTitle"))) {
        return;
    }
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, m_stepnameText.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, // $NON-NLS-1$
    "CassandraInputDialog.PreviewSize.DialogTitle"), // $NON-NLS-1$
    BaseMessages.getString(PKG, "CassandraInputDialog.PreviewSize.DialogMessage"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { m_stepnameText.getText() }, new int[] { previewSize });
        progressDialog.open();
        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled()) {
            if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                EnterTextDialog etd = new // $NON-NLS-1$
                EnterTextDialog(// $NON-NLS-1$
                shell, // $NON-NLS-1$
                BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), // $NON-NLS-1$
                BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                etd.setReadOnly();
                etd.open();
            }
        }
        PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, m_stepnameText.getText(), progressDialog.getPreviewRowsMeta(m_stepnameText.getText()), progressDialog.getPreviewRows(m_stepnameText.getText()), loggingText);
        prd.open();
    }
}
Also used : TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans)

Example 2 with PreviewRowsDialog

use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog in project pentaho-kettle by pentaho.

the class XulDatabaseExplorerController method preview.

public void preview(boolean askLimit) {
    if (model.getTable() == null) {
        return;
    }
    try {
        PromptCallback theCallback = new PromptCallback();
        @SuppressWarnings("unused") boolean execute = true;
        int limit = 100;
        if (askLimit) {
            XulPromptBox thePromptBox = (XulPromptBox) this.document.createElement("promptbox");
            thePromptBox.setModalParent(this.dbExplorerDialog.getShell());
            thePromptBox.setTitle("Enter Max Rows");
            thePromptBox.setMessage("Max Rows:");
            thePromptBox.addDialogCallback(theCallback);
            thePromptBox.open();
            execute = theCallback.getLimit() != -1;
            limit = theCallback.getLimit();
        }
        // if (execute) {
        // XulPreviewRowsDialog thePreviewRowsDialog = new XulPreviewRowsDialog(this.shell, SWT.NONE,
        // this.model.getDatabaseMeta(), this.model.getTable(), theCallback.getLimit());
        // thePreviewRowsDialog.open();
        // }
        GetPreviewTableProgressDialog pd = new GetPreviewTableProgressDialog(this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), model.getSchema(), model.getTable(), limit);
        List<Object[]> rows = pd.open();
        if (rows != null) {
            if (rows.size() > 0) {
                PreviewRowsDialog prd = new PreviewRowsDialog(this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), SWT.None, this.model.getTable(), pd.getRowMeta(), rows);
                prd.open();
            } else {
                MessageBox mb = new MessageBox(this.dbExplorerDialog.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoRows.Message"));
                mb.setText(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoRows.Title"));
                mb.open();
            }
        }
    } catch (Exception e) {
        LogChannel.GENERAL.logError("Error previewing rows", e);
    }
}
Also used : XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) XulException(org.pentaho.ui.xul.XulException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 3 with PreviewRowsDialog

use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog in project pentaho-kettle by pentaho.

the class XulDatabaseExplorerController method dataProfile.

public void dataProfile() {
    if (model.getTable() == null) {
        return;
    }
    Shell dbShell = (Shell) dbExplorerDialog.getRootObject();
    try {
        TransProfileFactory profileFactory = new TransProfileFactory(this.model.getDatabaseMeta(), getSchemaAndTable(this.model));
        TransMeta transMeta = profileFactory.generateTransformation(new LoggingObject(model.getTable()));
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(dbShell, transMeta, new String[] { TransProfileFactory.RESULT_STEP_NAME }, new int[] { 25000 });
        progressDialog.open();
        if (!progressDialog.isCancelled()) {
            Trans trans = progressDialog.getTrans();
            String loggingText = progressDialog.getLoggingText();
            if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                EnterTextDialog etd = new EnterTextDialog(dbShell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                etd.setReadOnly();
                etd.open();
            }
            PreviewRowsDialog prd = new PreviewRowsDialog(dbShell, transMeta, SWT.NONE, TransProfileFactory.RESULT_STEP_NAME, progressDialog.getPreviewRowsMeta(TransProfileFactory.RESULT_STEP_NAME), progressDialog.getPreviewRows(TransProfileFactory.RESULT_STEP_NAME), loggingText);
            prd.open();
        }
    } catch (Exception e) {
        new ErrorDialog(this.dbExplorerDialog.getShell(), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Title"), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Message"), e);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) TransProfileFactory(org.pentaho.di.trans.TransProfileFactory) LoggingObject(org.pentaho.di.core.logging.LoggingObject) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) Trans(org.pentaho.di.trans.Trans) XulException(org.pentaho.ui.xul.XulException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Example 4 with PreviewRowsDialog

use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog in project pentaho-kettle by pentaho.

the class DataOverrideHandler method showFeatureList.

public void showFeatureList() {
    Shell parent = getShell();
    DatabaseMeta dbinfo = new DatabaseMeta();
    getInfo(dbinfo);
    try {
        java.util.List<RowMetaAndData> buffer = dbinfo.getFeatureSummary();
        if (buffer.size() > 0) {
            RowMetaInterface rowMeta = buffer.get(0).getRowMeta();
            java.util.List<Object[]> rowData = new ArrayList<Object[]>();
            for (RowMetaAndData row : buffer) {
                rowData.add(row.getData());
            }
            PreviewRowsDialog prd = new PreviewRowsDialog(parent, dbinfo, SWT.NONE, null, rowMeta, rowData);
            prd.setTitleMessage(BaseMessages.getString(PKG, "DatabaseDialog.FeatureList.title"), BaseMessages.getString(PKG, "DatabaseDialog.FeatureList.title"));
            prd.open();
        }
    } catch (Exception e) {
        new ErrorDialog(parent, BaseMessages.getString(PKG, "DatabaseDialog.FeatureListError.title"), BaseMessages.getString(PKG, "DatabaseDialog.FeatureListError.description"), e);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 5 with PreviewRowsDialog

use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog in project pentaho-kettle by pentaho.

the class ParGzipCsvInputDialog method preview.

// Preview the data
private void preview() {
    // Create the XML input step
    ParGzipCsvInputMeta oneMeta = new ParGzipCsvInputMeta();
    getInfo(oneMeta);
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "ParGzipCsvInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "ParGzipCsvInputDialog.PreviewSize.DialogMessage"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
        progressDialog.open();
        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled()) {
            if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                etd.setReadOnly();
                etd.open();
            }
        }
        PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
        prd.open();
    }
}
Also used : TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans) ParGzipCsvInputMeta(org.pentaho.di.trans.steps.parallelgzipcsv.ParGzipCsvInputMeta)

Aggregations

PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)56 TransMeta (org.pentaho.di.trans.TransMeta)49 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)48 Trans (org.pentaho.di.trans.Trans)47 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)47 EnterNumberDialog (org.pentaho.di.ui.core.dialog.EnterNumberDialog)44 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)30 KettleException (org.pentaho.di.core.exception.KettleException)25 MessageBox (org.eclipse.swt.widgets.MessageBox)10 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)9 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)9 ArrayList (java.util.ArrayList)5 Point (org.eclipse.swt.graphics.Point)5 StepMeta (org.pentaho.di.trans.step.StepMeta)4 Date (java.util.Date)3 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)3 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)3 StepPluginType (org.pentaho.di.core.plugins.StepPluginType)3 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)3 TransHopMeta (org.pentaho.di.trans.TransHopMeta)3