Search in sources :

Example 31 with EnterTextDialog

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

the class SpoonSlave method pause.

protected void pause() {
    TreeEntry treeEntry = getTreeEntry();
    if (treeEntry == null) {
        return;
    }
    if (treeEntry.isTransformation()) {
        // Transformation
        try {
            WebResult webResult = slaveServer.pauseResumeTransformation(treeEntry.name, treeEntry.id);
            if (!WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
                EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorPausingOrResumingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorPausingOrResumingTrans.Message"), webResult.getMessage());
                dialog.setReadOnly();
                dialog.open();
            }
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorPausingOrResumingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorPausingOrResumingTrans.Message"), e);
        }
    }
}
Also used : EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) WebResult(org.pentaho.di.www.WebResult)

Example 32 with EnterTextDialog

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

the class SpoonSlave method start.

protected void start() {
    TreeEntry treeEntry = getTreeEntry();
    if (treeEntry == null) {
        return;
    }
    if (treeEntry.isTransformation()) {
        // Transformation
        SlaveServerTransStatus transStatus = slaveServerStatus.findTransStatus(treeEntry.name, treeEntry.id);
        if (transStatus != null) {
            if (!transStatus.isRunning()) {
                try {
                    WebResult webResult = slaveServer.startTransformation(treeEntry.name, transStatus.getId());
                    if (!WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
                        EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingTrans.Message"), webResult.getMessage());
                        dialog.setReadOnly();
                        dialog.open();
                    }
                } catch (Exception e) {
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingTrans.Message"), e);
                }
            }
        }
    } else if (treeEntry.isJob()) {
        // Job
        SlaveServerJobStatus jobStatus = slaveServerStatus.findJobStatus(treeEntry.name, treeEntry.id);
        if (jobStatus != null) {
            if (!jobStatus.isRunning()) {
                try {
                    WebResult webResult = slaveServer.startJob(treeEntry.name, jobStatus.getId());
                    if (!WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
                        EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingJob.Message"), webResult.getMessage());
                        dialog.setReadOnly();
                        dialog.open();
                    }
                } catch (Exception e) {
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingJob.Message"), e);
                }
            }
        }
    }
}
Also used : SlaveServerJobStatus(org.pentaho.di.www.SlaveServerJobStatus) SlaveServerTransStatus(org.pentaho.di.www.SlaveServerTransStatus) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) WebResult(org.pentaho.di.www.WebResult)

Example 33 with EnterTextDialog

use of org.pentaho.di.ui.core.dialog.EnterTextDialog 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 34 with EnterTextDialog

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

the class DatabaseDialog method test.

/**
 * Test the database connection
 */
public static final void test(Shell shell, DatabaseMeta dbinfo) {
    String[] remarks = dbinfo.checkParameters();
    if (remarks.length == 0) {
        // Get a "test" report from this database
        // 
        String reportMessage = dbinfo.testConnection();
        EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "DatabaseDialog.ConnectionReport.title"), BaseMessages.getString(PKG, "DatabaseDialog.ConnectionReport.description"), reportMessage.toString());
        dialog.setReadOnly();
        dialog.setFixed(true);
        dialog.setModal();
        dialog.open();
    } else {
        String message = "";
        for (int i = 0; i < remarks.length; i++) {
            message += "    * " + remarks[i] + Const.CR;
        }
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(BaseMessages.getString(PKG, "DatabaseDialog.ErrorParameters2.title"));
        mb.setMessage(BaseMessages.getString(PKG, "DatabaseDialog.ErrorParameters2.description", message));
        mb.open();
    }
}
Also used : EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 35 with EnterTextDialog

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

the class SQLEditor method exec.

private void exec() {
    DatabaseMeta ci = connection;
    if (ci == null) {
        return;
    }
    StringBuilder message = new StringBuilder();
    Database db = new Database(loggingObject, ci);
    boolean first = true;
    PartitionDatabaseMeta[] partitioningInformation = ci.getPartitioningInformation();
    for (int partitionNr = 0; first || (partitioningInformation != null && partitionNr < partitioningInformation.length); partitionNr++) {
        first = false;
        String partitionId = null;
        if (partitioningInformation != null && partitioningInformation.length > 0) {
            partitionId = partitioningInformation[partitionNr].getPartitionId();
        }
        try {
            db.connect(partitionId);
            String sqlScript = Utils.isEmpty(wScript.getSelectionText()) ? wScript.getText() : wScript.getSelectionText();
            // Multiple statements in the script need to be split into individual
            // executable statements
            statements = ci.getDatabaseInterface().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);
                        RowMetaInterface rowMeta = db.getReturnRowMeta();
                        if (rows.size() > 0) {
                            PreviewRowsDialog prd = new PreviewRowsDialog(shell, ci, 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 (KettleDatabaseException 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 = KettleLogStore.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(ci.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 = KettleLogStore.getLastBufferLineNr();
                        sql.setLoggingText(KettleLogStore.getAppender().getLogBufferFromTo(db.getLogChannelId(), true, startLogLine, endLogLine).toString());
                        sql.setComplete(true);
                        refreshExecutionResults();
                    }
                }
            }
            message.append(BaseMessages.getString(PKG, "SQLEditor.Log.StatsExecuted", Integer.toString(nrstats)));
            if (partitionId != null) {
                message.append(BaseMessages.getString(PKG, "SQLEditor.Log.OnPartition", partitionId));
            }
            message.append(Const.CR);
        } catch (KettleDatabaseException 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 : KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PartitionDatabaseMeta(org.pentaho.di.core.database.PartitionDatabaseMeta) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) PartitionDatabaseMeta(org.pentaho.di.core.database.PartitionDatabaseMeta) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) MessageBox(org.eclipse.swt.widgets.MessageBox) Database(org.pentaho.di.core.database.Database) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) SqlScriptStatement(org.pentaho.di.core.database.SqlScriptStatement)

Aggregations

EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)70 EnterNumberDialog (org.pentaho.di.ui.core.dialog.EnterNumberDialog)48 Trans (org.pentaho.di.trans.Trans)47 TransMeta (org.pentaho.di.trans.TransMeta)47 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)47 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)47 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)44 KettleException (org.pentaho.di.core.exception.KettleException)35 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)17 MessageBox (org.eclipse.swt.widgets.MessageBox)15 IOException (java.io.IOException)7 InputStream (java.io.InputStream)6 FileObject (org.apache.commons.vfs2.FileObject)6 InputStreamReader (java.io.InputStreamReader)5 Point (org.eclipse.swt.graphics.Point)5 TableItem (org.eclipse.swt.widgets.TableItem)5 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)5 FileDialog (org.eclipse.swt.widgets.FileDialog)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 DecimalFormat (java.text.DecimalFormat)3