Search in sources :

Example 1 with PipelinePreviewProgressDialog

use of org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog in project hop by apache.

the class CypherDialog method preview.

private synchronized void preview() {
    CypherMeta oneMeta = new CypherMeta();
    this.getInfo(oneMeta);
    PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(HopGui.getInstance().getMetadataProvider(), oneMeta, this.wTransformName.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(this.shell, this.props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "CypherDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "CypherDialog.PreviewSize.DialogMessage"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(this.shell, variables, previewMeta, new String[] { this.wTransformName.getText() }, new int[] { previewSize });
        progressDialog.open();
        Pipeline pipeline = progressDialog.getPipeline();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled() && pipeline.getResult() != null && pipeline.getResult().getNrErrors() > 0L) {
            EnterTextDialog etd = new EnterTextDialog(this.shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title", new String[0]), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message", new String[0]), loggingText, true);
            etd.setReadOnly();
            etd.open();
        }
        PreviewRowsDialog prd = new PreviewRowsDialog(this.shell, variables, 0, this.wTransformName.getText(), progressDialog.getPreviewRowsMeta(this.wTransformName.getText()), progressDialog.getPreviewRows(this.wTransformName.getText()), loggingText);
        prd.open();
    }
}
Also used : PipelineMeta(org.apache.hop.pipeline.PipelineMeta) PipelinePreviewProgressDialog(org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog) Pipeline(org.apache.hop.pipeline.Pipeline)

Example 2 with PipelinePreviewProgressDialog

use of org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog in project hop by apache.

the class UserDefinedJavaClassDialog method test.

private boolean test() {
    PluginRegistry registry = PluginRegistry.getInstance();
    String scriptTransformName = wTransformName.getText();
    if (!checkForTransformClass()) {
        return false;
    }
    // Create a transform with the information in this dialog
    UserDefinedJavaClassMeta udjcMeta = new UserDefinedJavaClassMeta();
    getInfo(udjcMeta);
    try {
        // First, before we get into the trial run, just see if the classes
        // all compile.
        udjcMeta.cookClasses();
        if (udjcMeta.cookErrors.size() == 1) {
            Exception e = udjcMeta.cookErrors.get(0);
            new ErrorDialog(shell, "Error during class compilation", e.toString(), e);
            return false;
        } else if (udjcMeta.cookErrors.size() > 1) {
            Exception e = udjcMeta.cookErrors.get(0);
            new ErrorDialog(shell, "Errors during class compilation", String.format("Multiple errors during class compilation. First error:\n%s", e.toString()), e);
            return false;
        }
        // What fields are coming into the transform?
        IRowMeta rowMeta = pipelineMeta.getPrevTransformFields(variables, transformName).clone();
        if (rowMeta != null) {
            // time
            if (genMeta == null) {
                genMeta = new RowGeneratorMeta();
                genMeta.setRowLimit("10");
                // CHECKSTYLE:Indentation:OFF
                for (int i = 0; i < rowMeta.size(); i++) {
                    IValueMeta valueMeta = rowMeta.getValueMeta(i);
                    if (valueMeta.isStorageBinaryString()) {
                        valueMeta.setStorageType(IValueMeta.STORAGE_TYPE_NORMAL);
                    }
                    GeneratorField field = new GeneratorField();
                    field.setName(valueMeta.getName());
                    field.setType(valueMeta.getTypeDesc());
                    field.setLength(valueMeta.getLength());
                    field.setPrecision(valueMeta.getPrecision());
                    field.setCurrency(valueMeta.getCurrencySymbol());
                    field.setDecimal(valueMeta.getDecimalSymbol());
                    field.setGroup(valueMeta.getGroupingSymbol());
                    String string = null;
                    switch(valueMeta.getType()) {
                        case IValueMeta.TYPE_DATE:
                            field.setFormat("yyyy/MM/dd HH:mm:ss");
                            valueMeta.setConversionMask(field.getFormat());
                            string = valueMeta.getString(new Date());
                            break;
                        case IValueMeta.TYPE_STRING:
                            string = "test value test value";
                            break;
                        case IValueMeta.TYPE_INTEGER:
                            field.setFormat("#");
                            valueMeta.setConversionMask(field.getFormat());
                            string = valueMeta.getString(Long.valueOf(0L));
                            break;
                        case IValueMeta.TYPE_NUMBER:
                            field.setFormat("#.#");
                            valueMeta.setConversionMask(field.getFormat());
                            string = valueMeta.getString(Double.valueOf(0.0D));
                            break;
                        case IValueMeta.TYPE_BIGNUMBER:
                            field.setFormat("#.#");
                            valueMeta.setConversionMask(field.getFormat());
                            string = valueMeta.getString(BigDecimal.ZERO);
                            break;
                        case IValueMeta.TYPE_BOOLEAN:
                            string = valueMeta.getString(Boolean.TRUE);
                            break;
                        case IValueMeta.TYPE_BINARY:
                            string = valueMeta.getString(new byte[] { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74 });
                            break;
                        default:
                            break;
                    }
                    field.setValue(string);
                    genMeta.getFields().add(field);
                }
            }
            TransformMeta genTransform = new TransformMeta(registry.getPluginId(TransformPluginType.class, genMeta), "## TEST DATA ##", genMeta);
            genTransform.setLocation(50, 50);
            TransformMeta scriptTransform = new TransformMeta(registry.getPluginId(TransformPluginType.class, udjcMeta), Const.NVL(scriptTransformName, "## SCRIPT ##"), udjcMeta);
            scriptTransformName = scriptTransform.getName();
            scriptTransform.setLocation(150, 50);
            // Create a hop between both transforms...
            // 
            PipelineHopMeta hop = new PipelineHopMeta(genTransform, scriptTransform);
            // Generate a new test pipeline...
            // 
            PipelineMeta pipelineMeta = new PipelineMeta();
            pipelineMeta.setName(wTransformName.getText() + " - PREVIEW");
            pipelineMeta.addTransform(genTransform);
            pipelineMeta.addTransform(scriptTransform);
            pipelineMeta.addPipelineHop(hop);
            // OK, now we ask the user to edit this dialog...
            // 
            // Now run this pipeline and grab the results...
            // 
            PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(shell, variables, pipelineMeta, new String[] { scriptTransformName }, new int[] { Const.toInt(genMeta.getRowLimit(), 10) });
            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("System.Dialog.PreviewError.Title"), BaseMessages.getString("System.Dialog.PreviewError.Message"), loggingText, true);
                    etd.setReadOnly();
                    etd.open();
                }
            }
            IRowMeta previewRowsMeta = progressDialog.getPreviewRowsMeta(wTransformName.getText());
            List<Object[]> previewRows = progressDialog.getPreviewRows(wTransformName.getText());
            if (previewRowsMeta != null && previewRows != null && previewRows.size() > 0) {
                PreviewRowsDialog prd = new PreviewRowsDialog(shell, variables, SWT.NONE, wTransformName.getText(), previewRowsMeta, previewRows, loggingText);
                prd.open();
            }
            return true;
        } else {
            throw new HopException(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Exception.CouldNotGetFields"));
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.TestFailed.DialogTitle"), BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.TestFailed.DialogMessage"), e);
        return false;
    }
}
Also used : HopException(org.apache.hop.core.exception.HopException) IRowMeta(org.apache.hop.core.row.IRowMeta) PipelineHopMeta(org.apache.hop.pipeline.PipelineHopMeta) RowGeneratorMeta(org.apache.hop.pipeline.transforms.rowgenerator.RowGeneratorMeta) HopException(org.apache.hop.core.exception.HopException) HopXmlException(org.apache.hop.core.exception.HopXmlException) IOException(java.io.IOException) Point(org.eclipse.swt.graphics.Point) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) Pipeline(org.apache.hop.pipeline.Pipeline) IValueMeta(org.apache.hop.core.row.IValueMeta) GeneratorField(org.apache.hop.pipeline.transforms.rowgenerator.GeneratorField) PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) TransformPluginType(org.apache.hop.core.plugins.TransformPluginType) PipelinePreviewProgressDialog(org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog)

Example 3 with PipelinePreviewProgressDialog

use of org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog in project hop by apache.

the class RowGeneratorDialog method preview.

/**
 * Preview the data generated by this transform. This generates a pipeline using this transform &
 * a dummy and previews it.
 */
private void preview() {
    RowGeneratorMeta oneMeta = new RowGeneratorMeta();
    try {
        getInfo(oneMeta);
    } catch (HopException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RowGeneratorDialog.Illegal.Dialog.Settings.Title"), BaseMessages.getString(PKG, "RowGeneratorDialog.Illegal.Dialog.Settings.Message"), e);
        return;
    }
    PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(pipelineMeta.getMetadataProvider(), oneMeta, wTransformName.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "System.Dialog.EnterPreviewSize.Title"), BaseMessages.getString(PKG, "System.Dialog.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()) {
            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();
    }
}
Also used : HopException(org.apache.hop.core.exception.HopException) 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 4 with PipelinePreviewProgressDialog

use of org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog in project hop by apache.

the class SplunkInputDialog method preview.

private synchronized void preview() {
    SplunkInputMeta oneMeta = new SplunkInputMeta();
    this.getInfo(oneMeta);
    PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(metadataProvider, oneMeta, this.wTransformName.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(this.shell, this.props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "QueryDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "QueryDialog.PreviewSize.DialogMessage"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(this.shell, variables, previewMeta, new String[] { this.wTransformName.getText() }, new int[] { previewSize });
        progressDialog.open();
        Pipeline pipeline = progressDialog.getPipeline();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled() && pipeline.getResult() != null && pipeline.getResult().getNrErrors() > 0L) {
            EnterTextDialog etd = new EnterTextDialog(this.shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title", new String[0]), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message", new String[0]), loggingText, true);
            etd.setReadOnly();
            etd.open();
        }
        PreviewRowsDialog prd = new PreviewRowsDialog(this.shell, variables, 0, this.wTransformName.getText(), progressDialog.getPreviewRowsMeta(this.wTransformName.getText()), progressDialog.getPreviewRows(this.wTransformName.getText()), loggingText);
        prd.open();
    }
}
Also used : PipelineMeta(org.apache.hop.pipeline.PipelineMeta) PipelinePreviewProgressDialog(org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog) Pipeline(org.apache.hop.pipeline.Pipeline)

Example 5 with PipelinePreviewProgressDialog

use of org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog in project hop by apache.

the class GetLoggingInfoDialog method preview.

// Preview the data
private void preview() {
    try {
        GetLoggingInfoMeta oneMeta = new GetLoggingInfoMeta();
        getInfo(oneMeta);
        PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(metadataProvider, oneMeta, wTransformname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GetLoggingInfoDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "GetLoggingInfoDialog.NumberRows.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.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, "GetLoggingInfoDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "GetLoggingInfoDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : HopException(org.apache.hop.core.exception.HopException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) PipelinePreviewProgressDialog(org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog) Pipeline(org.apache.hop.pipeline.Pipeline)

Aggregations

Pipeline (org.apache.hop.pipeline.Pipeline)32 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)32 PipelinePreviewProgressDialog (org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog)32 HopException (org.apache.hop.core.exception.HopException)17 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)6 EnterTextDialog (org.apache.hop.ui.core.dialog.EnterTextDialog)6 PreviewRowsDialog (org.apache.hop.ui.core.dialog.PreviewRowsDialog)6 Point (org.eclipse.swt.graphics.Point)4 EnterNumberDialog (org.apache.hop.ui.core.dialog.EnterNumberDialog)3 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)3 PluginRegistry (org.apache.hop.core.plugins.PluginRegistry)2 TransformPluginType (org.apache.hop.core.plugins.TransformPluginType)2 IRowMeta (org.apache.hop.core.row.IRowMeta)2 IValueMeta (org.apache.hop.core.row.IValueMeta)2 PipelineHopMeta (org.apache.hop.pipeline.PipelineHopMeta)2 BaseTransformMeta (org.apache.hop.pipeline.transform.BaseTransformMeta)2 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)2 GeneratorField (org.apache.hop.pipeline.transforms.rowgenerator.GeneratorField)2 RowGeneratorMeta (org.apache.hop.pipeline.transforms.rowgenerator.RowGeneratorMeta)2 IOException (java.io.IOException)1