Search in sources :

Example 1 with TransformDebugMeta

use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.

the class HopGuiPipelineGraph method showLastPreviewResults.

public synchronized void showLastPreviewResults() {
    if (lastPipelineDebugMeta == null || lastPipelineDebugMeta.getTransformDebugMetaMap().isEmpty()) {
        return;
    }
    final List<String> transformnames = new ArrayList<>();
    final List<IRowMeta> rowMetas = new ArrayList<>();
    final List<List<Object[]>> rowBuffers = new ArrayList<>();
    // 
    for (TransformMeta transformMeta : lastPipelineDebugMeta.getTransformDebugMetaMap().keySet()) {
        TransformDebugMeta transformDebugMeta = lastPipelineDebugMeta.getTransformDebugMetaMap().get(transformMeta);
        transformnames.add(transformMeta.getName());
        rowMetas.add(transformDebugMeta.getRowBufferMeta());
        rowBuffers.add(transformDebugMeta.getRowBuffer());
    }
    hopDisplay().asyncExec(() -> {
        EnterPreviewRowsDialog dialog = new EnterPreviewRowsDialog(hopShell(), SWT.NONE, transformnames, rowMetas, rowBuffers);
        dialog.open();
    });
}
Also used : IRowMeta(org.apache.hop.core.row.IRowMeta) List(java.util.List) FileObject(org.apache.commons.vfs2.FileObject) EnterPreviewRowsDialog(org.apache.hop.ui.hopgui.dialog.EnterPreviewRowsDialog) TransformDebugMeta(org.apache.hop.pipeline.debug.TransformDebugMeta)

Example 2 with TransformDebugMeta

use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.

the class PipelineDebugDialog method showTransformDebugInformation.

private void showTransformDebugInformation() {
    // 
    for (Control control : wComposite.getChildren()) {
        control.dispose();
    }
    wComposite.layout(true, true);
    int[] selectionIndices = wTransforms.table.getSelectionIndices();
    if (selectionIndices == null || selectionIndices.length != 1) {
        return;
    }
    previousIndex = selectionIndices[0];
    // What transform did we click on?
    // 
    final TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform(selectionIndices[0]);
    // What is the transform debugging metadata?
    // --> This can be null (most likely scenario)
    // 
    final TransformDebugMeta transformDebugMeta = transformDebugMetaMap.get(transformMeta);
    // At the top we'll put a few common items like first[x], etc.
    // 
    // The row count (e.g. number of rows to keep)
    // 
    wRowCount = new LabelText(wComposite, BaseMessages.getString(PKG, "PipelineDebugDialog.RowCount.Label"), BaseMessages.getString(PKG, "PipelineDebugDialog.RowCount.ToolTip"));
    FormData fdRowCount = new FormData();
    fdRowCount.left = new FormAttachment(0, 0);
    fdRowCount.right = new FormAttachment(100, 0);
    fdRowCount.top = new FormAttachment(0, 0);
    wRowCount.setLayoutData(fdRowCount);
    wRowCount.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
            ok(false);
        }
    });
    // Do we retrieve the first rows passing?
    // 
    wFirstRows = new Button(wComposite, SWT.CHECK);
    props.setLook(wFirstRows);
    wFirstRows.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.FirstRows.Label"));
    wFirstRows.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.FirstRows.ToolTip"));
    FormData fdFirstRows = new FormData();
    fdFirstRows.left = new FormAttachment(middle, 0);
    fdFirstRows.right = new FormAttachment(100, 0);
    fdFirstRows.top = new FormAttachment(wRowCount, margin);
    wFirstRows.setLayoutData(fdFirstRows);
    // Do we pause on break point, when the condition is met?
    // 
    wPauseBreakPoint = new Button(wComposite, SWT.CHECK);
    props.setLook(wPauseBreakPoint);
    wPauseBreakPoint.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.PauseBreakPoint.Label"));
    wPauseBreakPoint.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.PauseBreakPoint.ToolTip"));
    FormData fdPauseBreakPoint = new FormData();
    fdPauseBreakPoint.left = new FormAttachment(middle, 0);
    fdPauseBreakPoint.right = new FormAttachment(100, 0);
    fdPauseBreakPoint.top = new FormAttachment(wFirstRows, margin);
    wPauseBreakPoint.setLayoutData(fdPauseBreakPoint);
    // The condition to pause for...
    // 
    condition = null;
    if (transformDebugMeta != null) {
        condition = transformDebugMeta.getCondition();
    }
    if (condition == null) {
        condition = new Condition();
    }
    // The input fields...
    IRowMeta transformInputFields;
    try {
        transformInputFields = pipelineDebugMeta.getPipelineMeta().getTransformFields(variables, transformMeta);
    } catch (HopTransformException e) {
        transformInputFields = new RowMeta();
    }
    Label wlCondition = new Label(wComposite, SWT.RIGHT);
    props.setLook(wlCondition);
    wlCondition.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.Condition.Label"));
    wlCondition.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.Condition.ToolTip"));
    FormData fdlCondition = new FormData();
    fdlCondition.left = new FormAttachment(0, 0);
    fdlCondition.right = new FormAttachment(middle, -margin);
    fdlCondition.top = new FormAttachment(wPauseBreakPoint, margin);
    wlCondition.setLayoutData(fdlCondition);
    ConditionEditor wCondition = new ConditionEditor(wComposite, SWT.BORDER, condition, transformInputFields);
    FormData fdCondition = new FormData();
    fdCondition.left = new FormAttachment(middle, 0);
    fdCondition.right = new FormAttachment(100, 0);
    fdCondition.top = new FormAttachment(wPauseBreakPoint, margin);
    fdCondition.bottom = new FormAttachment(100, 0);
    wCondition.setLayoutData(fdCondition);
    getTransformDebugData(transformDebugMeta);
    // Add a "clear" button at the bottom on the left...
    // 
    Button wClear = new Button(wComposite, SWT.PUSH);
    props.setLook(wClear);
    wClear.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.Clear.Label"));
    wClear.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.Clear.ToolTip"));
    FormData fdClear = new FormData();
    fdClear.left = new FormAttachment(0, 0);
    fdClear.bottom = new FormAttachment(100, 0);
    wClear.setLayoutData(fdClear);
    wClear.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            // Clear the preview transform information for this transform...
            // 
            transformDebugMetaMap.remove(transformMeta);
            wTransforms.table.setSelection(new int[] {});
            previousIndex = -1;
            // refresh the transforms list...
            // 
            refreshTransformList();
            showTransformDebugInformation();
        }
    });
    wComposite.layout(true, true);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Condition(org.apache.hop.core.Condition) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ConditionEditor(org.apache.hop.ui.core.widget.ConditionEditor) TransformDebugMeta(org.apache.hop.pipeline.debug.TransformDebugMeta) HopTransformException(org.apache.hop.core.exception.HopTransformException) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LabelText(org.apache.hop.ui.core.widget.LabelText) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with TransformDebugMeta

use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.

the class PipelineDebugDialog method refreshTransformList.

private void refreshTransformList() {
    GuiResource resource = GuiResource.getInstance();
    // Add the list of transforms...
    // 
    int maxIconSize = 0;
    int indexSelected = -1;
    wTransforms.table.removeAll();
    for (int i = 0; i < pipelineDebugMeta.getPipelineMeta().getTransforms().size(); i++) {
        TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform(i);
        TableItem item = new TableItem(wTransforms.table, SWT.NONE);
        Image image = resource.getImagesTransforms().get(transformMeta.getTransformPluginId()).getAsBitmapForSize(display, ConstUi.ICON_SIZE, ConstUi.ICON_SIZE);
        item.setImage(0, image);
        item.setText(0, "");
        item.setText(1, transformMeta.getName());
        if (image.getBounds().width > maxIconSize) {
            maxIconSize = image.getBounds().width;
        }
        TransformDebugMeta transformDebugMeta = transformDebugMetaMap.get(transformMeta);
        if (transformDebugMeta != null) {
            // We have debugging information so we mark the row
            // 
            item.setBackground(resource.getColorLight());
            if (indexSelected < 0) {
                indexSelected = i;
            }
        }
    }
    wTransforms.removeEmptyRows();
    wTransforms.optWidth(false);
    wTransforms.table.getColumn(0).setWidth(maxIconSize + 10);
    wTransforms.table.getColumn(0).setAlignment(SWT.CENTER);
    // 
    if (indexSelected >= 0) {
        wTransforms.table.setSelection(indexSelected);
        showTransformDebugInformation();
    }
}
Also used : TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) TransformDebugMeta(org.apache.hop.pipeline.debug.TransformDebugMeta) GuiResource(org.apache.hop.ui.core.gui.GuiResource) Image(org.eclipse.swt.graphics.Image)

Example 4 with TransformDebugMeta

use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.

the class PipelineDebugDialog method getTransformDebugMeta.

/**
 * Grab the transform debugging information from the dialog. Store it in our private map
 */
private void getTransformDebugMeta() {
    int index = wTransforms.getSelectionIndex();
    if (previousIndex >= 0) {
        // 
        if (wComposite.getChildren().length == 0) {
            return;
        }
        TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform(previousIndex);
        TransformDebugMeta transformDebugMeta = new TransformDebugMeta(transformMeta);
        transformDebugMeta.setCondition(condition);
        transformDebugMeta.setPausingOnBreakPoint(wPauseBreakPoint.getSelection());
        transformDebugMeta.setReadingFirstRows(wFirstRows.getSelection());
        transformDebugMeta.setRowCount(Const.toInt(wRowCount.getText(), -1));
        transformDebugMetaMap.put(transformMeta, transformDebugMeta);
    }
    previousIndex = index;
}
Also used : TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) TransformDebugMeta(org.apache.hop.pipeline.debug.TransformDebugMeta)

Example 5 with TransformDebugMeta

use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.

the class PipelinePreviewProgressDialog method doPreview.

private void doPreview(final HopGui hopGui, final IProgressMonitor progressMonitor, final boolean showErrorDialogs) {
    progressMonitor.beginTask(BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.Monitor.BeginTask.Title"), 100);
    // This pipeline is ready to run in preview!
    // 
    pipeline = new LocalPipelineEngine(pipelineMeta, variables, hopGui.getLoggingObject());
    pipeline.setPreview(true);
    pipeline.setMetadataProvider(hopGui.getMetadataProvider());
    // 
    try {
        pipeline.prepareExecution();
    } catch (final HopException e) {
        if (showErrorDialogs) {
            shell.getDisplay().asyncExec(() -> new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.Exception.ErrorPreparingPipeline"), e));
        }
        // 
        return;
    }
    // Add the preview / debugging information...
    // 
    pipelineDebugMeta = new PipelineDebugMeta(pipelineMeta);
    for (int i = 0; i < previewTransformNames.length; i++) {
        TransformMeta transformMeta = pipelineMeta.findTransform(previewTransformNames[i]);
        TransformDebugMeta transformDebugMeta = new TransformDebugMeta(transformMeta);
        transformDebugMeta.setReadingFirstRows(true);
        transformDebugMeta.setRowCount(previewSize[i]);
        pipelineDebugMeta.getTransformDebugMetaMap().put(transformMeta, transformDebugMeta);
    }
    int previousPct = 0;
    final List<String> previewComplete = new ArrayList<>();
    // We add a break-point that is called every time we have a transform with a full preview row
    // buffer
    // That makes it easy and fast to see if we have all the rows we need
    // 
    pipelineDebugMeta.addBreakPointListers((pipelineDebugMeta, transformDebugMeta, rowBufferMeta, rowBuffer) -> {
        String transformName = transformDebugMeta.getTransformMeta().getName();
        previewComplete.add(transformName);
        progressMonitor.subTask(BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.SubTask.TransformPreviewFinished", transformName));
    });
    // set the appropriate listeners on the pipeline...
    // 
    pipelineDebugMeta.addRowListenersToPipeline(pipeline);
    // 
    try {
        pipeline.startThreads();
    } catch (final HopException e) {
        shell.getDisplay().asyncExec(() -> new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.Exception.ErrorPreparingPipeline"), e));
        // 
        return;
    }
    while (previewComplete.size() < previewTransformNames.length && !pipeline.isFinished() && !progressMonitor.isCanceled()) {
        // How many rows are done?
        int nrDone = 0;
        int nrTotal = 0;
        for (TransformDebugMeta transformDebugMeta : pipelineDebugMeta.getTransformDebugMetaMap().values()) {
            nrDone += transformDebugMeta.getRowBuffer().size();
            nrTotal += transformDebugMeta.getRowCount();
        }
        int pct = 100 * nrDone / nrTotal;
        int worked = pct - previousPct;
        if (worked > 0) {
            progressMonitor.worked(worked);
        }
        previousPct = pct;
        // Change the percentage...
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
        // Ignore errors
        }
        if (progressMonitor.isCanceled()) {
            cancelled = true;
            pipeline.stopAll();
        }
    }
    pipeline.stopAll();
    // Capture preview activity to a String:
    loggingText = HopLogStore.getAppender().getBuffer(pipeline.getLogChannel().getLogChannelId(), true).toString();
    progressMonitor.done();
}
Also used : LocalPipelineEngine(org.apache.hop.pipeline.engines.local.LocalPipelineEngine) HopException(org.apache.hop.core.exception.HopException) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) ArrayList(java.util.ArrayList) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) TransformDebugMeta(org.apache.hop.pipeline.debug.TransformDebugMeta) PipelineDebugMeta(org.apache.hop.pipeline.debug.PipelineDebugMeta)

Aggregations

TransformDebugMeta (org.apache.hop.pipeline.debug.TransformDebugMeta)6 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)5 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IRowMeta (org.apache.hop.core.row.IRowMeta)2 PipelineDebugMeta (org.apache.hop.pipeline.debug.PipelineDebugMeta)2 HashMap (java.util.HashMap)1 FileObject (org.apache.commons.vfs2.FileObject)1 Condition (org.apache.hop.core.Condition)1 HopException (org.apache.hop.core.exception.HopException)1 HopTransformException (org.apache.hop.core.exception.HopTransformException)1 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)1 RowMeta (org.apache.hop.core.row.RowMeta)1 PipelineExecutionConfiguration (org.apache.hop.pipeline.PipelineExecutionConfiguration)1 LocalPipelineEngine (org.apache.hop.pipeline.engines.local.LocalPipelineEngine)1 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)1 GuiResource (org.apache.hop.ui.core.gui.GuiResource)1 ConditionEditor (org.apache.hop.ui.core.widget.ConditionEditor)1 LabelText (org.apache.hop.ui.core.widget.LabelText)1 EnterPreviewRowsDialog (org.apache.hop.ui.hopgui.dialog.EnterPreviewRowsDialog)1