Search in sources :

Example 41 with PreviewRowsDialog

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

the class Spoon method showLastImpactAnalyses.

public void showLastImpactAnalyses(TransMeta transMeta) {
    if (transMeta == null) {
        return;
    }
    TransGraph transGraph = delegates.trans.findTransGraphOfTransformation(transMeta);
    if (transGraph == null) {
        return;
    }
    List<Object[]> rows = new ArrayList<>();
    RowMetaInterface rowMeta = null;
    for (int i = 0; i < transGraph.getImpact().size(); i++) {
        DatabaseImpact ii = transGraph.getImpact().get(i);
        RowMetaAndData row = ii.getRow();
        rowMeta = row.getRowMeta();
        rows.add(row.getData());
    }
    if (rows.size() > 0) {
        // Display all the rows...
        PreviewRowsDialog prd = new PreviewRowsDialog(shell, Variables.getADefaultVariableSpace(), SWT.NONE, "-", rowMeta, rows);
        prd.setTitleMessage(// "Result of analyses:"
        BaseMessages.getString(PKG, "Spoon.Dialog.ImpactAnalyses.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ImpactAnalyses.Message"));
        prd.open();
    } else {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
        if (transGraph.isImpactFinished()) {
            // "As far as I can tell, this transformation has no impact on any database."
            mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.TransformationNoImpactOnDatabase.Message"));
        } else {
            // "Please run the impact analyses first on this transformation."
            mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.RunImpactAnalysesFirst.Message"));
        }
        // Impact
        mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.ImpactAnalyses.Title"));
        mb.open();
    }
}
Also used : DatabaseImpact(org.pentaho.di.trans.DatabaseImpact) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 42 with PreviewRowsDialog

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

the class SpoonSlave method sniff.

protected void sniff() {
    TreeItem[] ti = wTree.getSelection();
    if (ti.length == 1) {
        TreeItem treeItem = ti[0];
        String[] path = ConstUI.getTreeStrings(treeItem);
        // Make sure we're positioned on a step
        if (path.length <= 2) {
            return;
        }
        String name = path[1];
        String step = path[2];
        String copy = treeItem.getText(1);
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, PropsUI.getInstance().getDefaultPreviewSize(), BaseMessages.getString(PKG, "SpoonSlave.SniffSizeQuestion.Title"), BaseMessages.getString(PKG, "SpoonSlave.SniffSizeQuestion.Message"));
        int lines = numberDialog.open();
        if (lines <= 0) {
            return;
        }
        EnterSelectionDialog selectionDialog = new EnterSelectionDialog(shell, new String[] { SniffStepServlet.TYPE_INPUT, SniffStepServlet.TYPE_OUTPUT }, BaseMessages.getString(PKG, "SpoonSlave.SniffTypeQuestion.Title"), BaseMessages.getString(PKG, "SpoonSlave.SniffTypeQuestion.Message"));
        String type = selectionDialog.open(1);
        if (type == null) {
            return;
        }
        try {
            String xml = slaveServer.sniffStep(name, step, copy, lines, type);
            Document doc = XMLHandler.loadXMLString(xml);
            Node node = XMLHandler.getSubNode(doc, SniffStepServlet.XML_TAG);
            Node metaNode = XMLHandler.getSubNode(node, RowMeta.XML_META_TAG);
            RowMetaInterface rowMeta = new RowMeta(metaNode);
            int nrRows = Const.toInt(XMLHandler.getTagValue(node, "nr_rows"), 0);
            List<Object[]> rowBuffer = new ArrayList<Object[]>();
            for (int i = 0; i < nrRows; i++) {
                Node dataNode = XMLHandler.getSubNodeByNr(node, RowMeta.XML_DATA_TAG, i);
                Object[] row = rowMeta.getRow(dataNode);
                rowBuffer.add(row);
            }
            PreviewRowsDialog prd = new PreviewRowsDialog(shell, new Variables(), SWT.NONE, step, rowMeta, rowBuffer);
            prd.open();
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorSniffingStep.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorSniffingStep.Message"), e);
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) RowMeta(org.pentaho.di.core.row.RowMeta) Node(org.w3c.dom.Node) 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) Document(org.w3c.dom.Document) Variables(org.pentaho.di.core.variables.Variables) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 43 with PreviewRowsDialog

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

the class CommonStepDialog method preview.

private void preview() {
    // good measure
    if (!fieldsExist()) {
        openNoFieldsDialog();
        return;
    }
    // Create the XML meta step
    final StepMetaType populatedMeta = (StepMetaType) getPopulatedMeta();
    final TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, populatedMeta, wStepname.getText());
    final EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, // $NON-NLS-1$
    "CommonStepDialog.PreviewSize.DialogTitle"), // $NON-NLS-1$
    BaseMessages.getString(PKG, "CommonStepDialog.PreviewSize.DialogMessage"));
    final int previewSize = numberDialog.open();
    if (previewSize > 0) {
        final TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
        progressDialog.open(false);
        final Trans trans = progressDialog.getTrans();
        final String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled()) {
            if (trans.getResult() != null) {
                if (trans.getResult().getNrErrors() > 0) {
                    openPreviewError();
                    // there are errors - return
                    return;
                }
            }
        }
        final List previewRows = progressDialog.getPreviewRows(wStepname.getText());
        if (previewRows == null || previewRows.size() == 0) {
            openNoRowsToPreviewError();
        } else {
            final PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), previewRows, loggingText);
            prd.open();
        }
    }
}
Also used : TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) List(java.util.List) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans)

Example 44 with PreviewRowsDialog

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

the class CsvInputDialog method preview.

// Preview the data
private synchronized void preview() {
    // Create the XML input step
    CsvInputMeta oneMeta = new CsvInputMeta();
    getInfo(oneMeta);
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    transMeta.getVariable("Internal.Transformation.Filename.Directory");
    previewMeta.getVariable("Internal.Transformation.Filename.Directory");
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "CsvInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "CsvInputDialog.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) CsvInputMeta(org.pentaho.di.trans.steps.csvinput.CsvInputMeta) 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)

Example 45 with PreviewRowsDialog

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

the class DataGridDialog method preview.

/**
 * Preview the data generated by this step. This generates a transformation using this step & a dummy and previews it.
 */
private void preview() {
    // Create the table input reader step...
    DataGridMeta oneMeta = new DataGridMeta();
    getInfo(oneMeta);
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.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) {
        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) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) DataGridMeta(org.pentaho.di.trans.steps.datagrid.DataGridMeta) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans) Point(org.eclipse.swt.graphics.Point)

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