Search in sources :

Example 1 with PreviewRowsDialog

use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.

the class DataGridDialog method preview.

/**
 * Preview the data generated by this transform. This generates a pipeline using this transform &
 * a dummy and previews it.
 */
private void preview() {
    // Create the table input reader transform...
    DataGridMeta oneMeta = new DataGridMeta();
    getInfo(oneMeta);
    PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(pipelineMeta.getMetadataProvider(), oneMeta, wTransformName.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "DataGridDialog.EnterPreviewSize.Title"), BaseMessages.getString(PKG, "DataGridDialog.EnterPreviewSize.Message"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(shell, variables, previewMeta, new String[] { wTransformName.getText() }, new int[] { previewSize });
        progressDialog.open();
        Pipeline pipeline = progressDialog.getPipeline();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled() && pipeline.getResult() != null && pipeline.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, variables, SWT.NONE, wTransformName.getText(), progressDialog.getPreviewRowsMeta(wTransformName.getText()), progressDialog.getPreviewRows(wTransformName.getText()), loggingText);
        prd.open();
    }
}
Also used : EnterTextDialog(org.apache.hop.ui.core.dialog.EnterTextDialog) PreviewRowsDialog(org.apache.hop.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.apache.hop.ui.core.dialog.EnterNumberDialog) Point(org.eclipse.swt.graphics.Point) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) PipelinePreviewProgressDialog(org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog) Pipeline(org.apache.hop.pipeline.Pipeline)

Example 2 with PreviewRowsDialog

use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.

the class MetadataInputDialog method preview.

// Preview the data
private void preview() {
    try {
        // Create the Access input transform
        MetadataInputMeta oneMeta = new MetadataInputMeta();
        getInfo(oneMeta);
        PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(metadataProvider, oneMeta, wTransformName.getText());
        // Preview the first 1000 rows...
        // 
        PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(shell, variables, previewMeta, new String[] { wTransformName.getText() }, new int[] { 1000 });
        progressDialog.open();
        if (!progressDialog.isCancelled()) {
            Pipeline pipeline = progressDialog.getPipeline();
            String loggingText = progressDialog.getLoggingText();
            if (pipeline.getResult() != null && pipeline.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, variables, SWT.NONE, wTransformName.getText(), progressDialog.getPreviewRowsMeta(wTransformName.getText()), progressDialog.getPreviewRows(wTransformName.getText()), loggingText);
            prd.open();
        }
    } catch (HopException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "MetadataInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "MetadataInputDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : HopException(org.apache.hop.core.exception.HopException) EnterTextDialog(org.apache.hop.ui.core.dialog.EnterTextDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) PreviewRowsDialog(org.apache.hop.ui.core.dialog.PreviewRowsDialog) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) PipelinePreviewProgressDialog(org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog) Pipeline(org.apache.hop.pipeline.Pipeline)

Example 3 with PreviewRowsDialog

use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.

the class TableInputDialog method preview.

/**
 * Preview the data generated by this transform. This generates a pipeline using this transform &
 * a dummy and previews it.
 */
private void preview() {
    // Create the table input reader transform...
    TableInputMeta oneMeta = new TableInputMeta();
    getInfo(oneMeta, true);
    PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(pipelineMeta.getMetadataProvider(), oneMeta, wTransformName.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "TableInputDialog.EnterPreviewSize"), BaseMessages.getString(PKG, "TableInputDialog.NumberOfRowsToPreview"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(shell, variables, previewMeta, new String[] { wTransformName.getText() }, new int[] { previewSize });
        progressDialog.open();
        Pipeline pipeline = progressDialog.getPipeline();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled()) {
            if (pipeline.getResult() != null && pipeline.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();
            } else {
                PreviewRowsDialog prd = new PreviewRowsDialog(shell, variables, SWT.NONE, wTransformName.getText(), progressDialog.getPreviewRowsMeta(wTransformName.getText()), progressDialog.getPreviewRows(wTransformName.getText()), loggingText);
                prd.open();
            }
        }
    }
}
Also used : EnterTextDialog(org.apache.hop.ui.core.dialog.EnterTextDialog) PreviewRowsDialog(org.apache.hop.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.apache.hop.ui.core.dialog.EnterNumberDialog) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) PipelinePreviewProgressDialog(org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog) Pipeline(org.apache.hop.pipeline.Pipeline)

Example 4 with PreviewRowsDialog

use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.

the class SqlEditor method exec.

private void exec() {
    DatabaseMeta databaseMeta = connection;
    if (databaseMeta == null) {
        return;
    }
    StringBuilder message = new StringBuilder();
    Database db = new Database(loggingObject, variables, databaseMeta);
    try {
        db.connect();
        String sqlScript = Utils.isEmpty(wScript.getSelectionText()) ? wScript.getText() : wScript.getSelectionText();
        // Multiple statements in the script need to be split into individual
        // executable statements
        List<SqlScriptStatement> statements = databaseMeta.getIDatabase().getSqlScriptStatements(sqlScript + Const.CR);
        int nrstats = 0;
        for (SqlScriptStatement sql : statements) {
            if (sql.isQuery()) {
                // A Query
                log.logDetailed("launch SELECT statement: " + Const.CR + sql);
                nrstats++;
                try {
                    List<Object[]> rows = db.getRows(sql.getStatement(), 1000);
                    IRowMeta rowMeta = db.getReturnRowMeta();
                    if (rows.size() > 0) {
                        PreviewRowsDialog prd = new PreviewRowsDialog(shell, variables, SWT.NONE, BaseMessages.getString(PKG, "SQLEditor.ResultRows.Title", Integer.toString(nrstats)), rowMeta, rows);
                        prd.open();
                    } else {
                        MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
                        mb.setMessage(BaseMessages.getString(PKG, "SQLEditor.NoRows.Message", sql));
                        mb.setText(BaseMessages.getString(PKG, "SQLEditor.NoRows.Title"));
                        mb.open();
                    }
                } catch (HopDatabaseException dbe) {
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "SQLEditor.ErrorExecSQL.Title"), BaseMessages.getString(PKG, "SQLEditor.ErrorExecSQL.Message", sql), dbe);
                }
            } else {
                log.logDetailed("launch DDL statement: " + Const.CR + sql);
                // A DDL statement
                nrstats++;
                int startLogLine = HopLogStore.getLastBufferLineNr();
                try {
                    log.logDetailed("Executing SQL: " + Const.CR + sql);
                    db.execStatement(sql.getStatement());
                    message.append(BaseMessages.getString(PKG, "SQLEditor.Log.SQLExecuted", sql));
                    message.append(Const.CR);
                    // Clear the database cache, in case we're using one...
                    if (dbcache != null) {
                        dbcache.clear(databaseMeta.getName());
                    }
                    // mark the statement in green in the dialog...
                    // 
                    sql.setOk(true);
                } catch (Exception dbe) {
                    sql.setOk(false);
                    String error = BaseMessages.getString(PKG, "SQLEditor.Log.SQLExecError", sql, dbe.toString());
                    message.append(error).append(Const.CR);
                    ErrorDialog dialog = new ErrorDialog(shell, BaseMessages.getString(PKG, "SQLEditor.ErrorExecSQL.Title"), error, dbe, true);
                    if (dialog.isCancelled()) {
                        break;
                    }
                } finally {
                    int endLogLine = HopLogStore.getLastBufferLineNr();
                    sql.setLoggingText(HopLogStore.getAppender().getLogBufferFromTo(db.getLogChannelId(), true, startLogLine, endLogLine).toString());
                    sql.setComplete(true);
                    refreshExecutionResults();
                }
            }
        }
        message.append(BaseMessages.getString(PKG, "SQLEditor.Log.StatsExecuted", Integer.toString(nrstats)));
        message.append(Const.CR);
    } catch (HopDatabaseException dbe) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        String error = BaseMessages.getString(PKG, "SQLEditor.Error.CouldNotConnect.Message", (connection == null ? "" : connection.getName()), dbe.getMessage());
        message.append(error).append(Const.CR);
        mb.setMessage(error);
        mb.setText(BaseMessages.getString(PKG, "SQLEditor.Error.CouldNotConnect.Title"));
        mb.open();
    } finally {
        db.disconnect();
        refreshExecutionResults();
    }
    EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SQLEditor.Result.Title"), BaseMessages.getString(PKG, "SQLEditor.Result.Message"), message.toString(), true);
    dialog.open();
}
Also used : IRowMeta(org.apache.hop.core.row.IRowMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopDatabaseException(org.apache.hop.core.exception.HopDatabaseException) PreviewRowsDialog(org.apache.hop.ui.core.dialog.PreviewRowsDialog) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) HopDatabaseException(org.apache.hop.core.exception.HopDatabaseException) MessageBox(org.eclipse.swt.widgets.MessageBox) Database(org.apache.hop.core.database.Database) EnterTextDialog(org.apache.hop.ui.core.dialog.EnterTextDialog) SqlScriptStatement(org.apache.hop.core.database.SqlScriptStatement)

Example 5 with PreviewRowsDialog

use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.

the class GetSubFoldersDialog method preview.

// Preview the data
private void preview() {
    // Create the XML input transform
    GetSubFoldersMeta oneMeta = new GetSubFoldersMeta();
    getInfo(oneMeta);
    PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(pipelineMeta.getMetadataProvider(), oneMeta, wTransformName.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GetSubFoldersDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "GetSubFoldersDialog.PreviewSize.DialogMessage"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(shell, variables, previewMeta, new String[] { wTransformName.getText() }, new int[] { previewSize });
        progressDialog.open();
        if (!progressDialog.isCancelled()) {
            Pipeline pipeline = progressDialog.getPipeline();
            String loggingText = progressDialog.getLoggingText();
            if (pipeline.getResult() != null && pipeline.getResult().getNrErrors() > 0) {
                EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "GetSubFoldersDialog.ErrorInPreview.DialogMessage"), loggingText, true);
                etd.setReadOnly();
                etd.open();
            }
            PreviewRowsDialog prd = new PreviewRowsDialog(shell, variables, SWT.NONE, wTransformName.getText(), progressDialog.getPreviewRowsMeta(wTransformName.getText()), progressDialog.getPreviewRows(wTransformName.getText()), loggingText);
            prd.open();
        }
    }
}
Also used : EnterTextDialog(org.apache.hop.ui.core.dialog.EnterTextDialog) PreviewRowsDialog(org.apache.hop.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.apache.hop.ui.core.dialog.EnterNumberDialog) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) PipelinePreviewProgressDialog(org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog) Pipeline(org.apache.hop.pipeline.Pipeline)

Aggregations

PreviewRowsDialog (org.apache.hop.ui.core.dialog.PreviewRowsDialog)10 EnterTextDialog (org.apache.hop.ui.core.dialog.EnterTextDialog)7 Pipeline (org.apache.hop.pipeline.Pipeline)6 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)6 PipelinePreviewProgressDialog (org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog)6 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)5 HopException (org.apache.hop.core.exception.HopException)4 IRowMeta (org.apache.hop.core.row.IRowMeta)4 EnterNumberDialog (org.apache.hop.ui.core.dialog.EnterNumberDialog)3 Point (org.eclipse.swt.graphics.Point)2 Database (org.apache.hop.core.database.Database)1 DatabaseMeta (org.apache.hop.core.database.DatabaseMeta)1 SqlScriptStatement (org.apache.hop.core.database.SqlScriptStatement)1 HopDatabaseException (org.apache.hop.core.exception.HopDatabaseException)1 PluginRegistry (org.apache.hop.core.plugins.PluginRegistry)1 TransformPluginType (org.apache.hop.core.plugins.TransformPluginType)1 IValueMeta (org.apache.hop.core.row.IValueMeta)1 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)1 Variables (org.apache.hop.core.variables.Variables)1 PipelineHopMeta (org.apache.hop.pipeline.PipelineHopMeta)1