Search in sources :

Example 1 with PipelineDebugDialog

use of org.apache.hop.ui.pipeline.debug.PipelineDebugDialog in project hop by apache.

the class HopGuiPipelineRunDelegate method executePipeline.

public PipelineExecutionConfiguration executePipeline(final ILogChannel log, final PipelineMeta pipelineMeta, final boolean preview, final boolean debug, LogLevel logLevel) throws HopException {
    if (pipelineMeta == null) {
        return null;
    }
    // See if we need to ask for debugging information...
    // 
    PipelineDebugMeta pipelineDebugMeta = null;
    PipelineExecutionConfiguration executionConfiguration = null;
    if (preview) {
        executionConfiguration = getPipelinePreviewExecutionConfiguration();
    } else if (debug) {
        executionConfiguration = getPipelineDebugExecutionConfiguration();
    } else {
        executionConfiguration = getPipelineExecutionConfiguration();
    }
    // Set MetaStore and safe mode information in both the exec config and the metadata
    // 
    pipelineMeta.setMetadataProvider(hopGui.getMetadataProvider());
    if (debug) {
        // See if we have debugging information stored somewhere?
        // 
        pipelineDebugMeta = pipelineDebugMetaMap.get(pipelineMeta);
        if (pipelineDebugMeta == null) {
            pipelineDebugMeta = new PipelineDebugMeta(pipelineMeta);
            pipelineDebugMetaMap.put(pipelineMeta, pipelineDebugMeta);
        }
        // Set the default number of rows to retrieve on all selected transforms...
        // 
        List<TransformMeta> selectedTransforms = pipelineMeta.getSelectedTransforms();
        if (selectedTransforms != null && selectedTransforms.size() > 0) {
            pipelineDebugMeta.getTransformDebugMetaMap().clear();
            for (TransformMeta transformMeta : pipelineMeta.getSelectedTransforms()) {
                TransformDebugMeta transformDebugMeta = new TransformDebugMeta(transformMeta);
                transformDebugMeta.setRowCount(PropsUi.getInstance().getDefaultPreviewSize());
                transformDebugMeta.setPausingOnBreakPoint(true);
                transformDebugMeta.setReadingFirstRows(false);
                pipelineDebugMeta.getTransformDebugMetaMap().put(transformMeta, transformDebugMeta);
            }
        }
    } else if (preview) {
        // See if we have preview information stored somewhere?
        // 
        pipelineDebugMeta = pipelinePreviewMetaMap.get(pipelineMeta);
        if (pipelineDebugMeta == null) {
            pipelineDebugMeta = new PipelineDebugMeta(pipelineMeta);
            pipelinePreviewMetaMap.put(pipelineMeta, pipelineDebugMeta);
        }
        // Set the default number of preview rows on all selected transforms...
        // 
        List<TransformMeta> selectedTransforms = pipelineMeta.getSelectedTransforms();
        if (selectedTransforms != null && selectedTransforms.size() > 0) {
            pipelineDebugMeta.getTransformDebugMetaMap().clear();
            for (TransformMeta transformMeta : pipelineMeta.getSelectedTransforms()) {
                TransformDebugMeta transformDebugMeta = new TransformDebugMeta(transformMeta);
                transformDebugMeta.setRowCount(PropsUi.getInstance().getDefaultPreviewSize());
                transformDebugMeta.setPausingOnBreakPoint(false);
                transformDebugMeta.setReadingFirstRows(true);
                pipelineDebugMeta.getTransformDebugMetaMap().put(transformMeta, transformDebugMeta);
            }
        }
    }
    int debugAnswer = PipelineDebugDialog.DEBUG_CONFIG;
    if (debug || preview) {
        PipelineDebugDialog pipelineDebugDialog = new PipelineDebugDialog(hopGui.getShell(), pipelineGraph.getVariables(), pipelineDebugMeta);
        debugAnswer = pipelineDebugDialog.open();
        if (debugAnswer == PipelineDebugDialog.DEBUG_CANCEL) {
            // 
            return null;
        }
    }
    Map<String, String> variableMap = new HashMap<>();
    // the default
    variableMap.putAll(executionConfiguration.getVariablesMap());
    executionConfiguration.setVariablesMap(variableMap);
    executionConfiguration.getUsedVariables(pipelineGraph.getVariables(), pipelineMeta);
    executionConfiguration.setLogLevel(logLevel);
    boolean execConfigAnswer = true;
    if (debugAnswer == PipelineDebugDialog.DEBUG_CONFIG && pipelineMeta.isShowDialog()) {
        PipelineExecutionConfigurationDialog dialog = new PipelineExecutionConfigurationDialog(hopGui.getShell(), executionConfiguration, pipelineMeta);
        execConfigAnswer = dialog.open();
    }
    if (execConfigAnswer) {
        pipelineGraph.pipelineGridDelegate.addPipelineGrid();
        pipelineGraph.pipelineLogDelegate.addPipelineLog();
        pipelineGraph.extraViewTabFolder.setSelection(0);
        // Set the run options
        pipelineMeta.setClearingLog(executionConfiguration.isClearingLog());
        ExtensionPointHandler.callExtensionPoint(log, pipelineGraph.getVariables(), HopExtensionPoint.HopGuiPipelineMetaExecutionStart.id, pipelineMeta);
        ExtensionPointHandler.callExtensionPoint(log, pipelineGraph.getVariables(), HopExtensionPoint.HopGuiPipelineExecutionConfiguration.id, executionConfiguration);
        // distinction
        if (debug || preview) {
            if (pipelineDebugMeta.getNrOfUsedTransforms() == 0) {
                MessageBox box = new MessageBox(hopGui.getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO);
                box.setText(BaseMessages.getString(PKG, "HopGui.Dialog.Warning.NoPreviewOrDebugTransforms.Title"));
                box.setMessage(BaseMessages.getString(PKG, "HopGui.Dialog.Warning.NoPreviewOrDebugTransforms.Message"));
                int answer = box.open();
                if (answer != SWT.YES) {
                    return null;
                }
            }
            pipelineGraph.debug(executionConfiguration, pipelineDebugMeta);
        } else {
            pipelineGraph.start(executionConfiguration);
        }
    }
    return executionConfiguration;
}
Also used : HashMap(java.util.HashMap) PipelineDebugDialog(org.apache.hop.ui.pipeline.debug.PipelineDebugDialog) TransformDebugMeta(org.apache.hop.pipeline.debug.TransformDebugMeta) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) MessageBox(org.eclipse.swt.widgets.MessageBox) PipelineExecutionConfigurationDialog(org.apache.hop.ui.pipeline.dialog.PipelineExecutionConfigurationDialog) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) ArrayList(java.util.ArrayList) List(java.util.List) PipelineExecutionConfiguration(org.apache.hop.pipeline.PipelineExecutionConfiguration) PipelineDebugMeta(org.apache.hop.pipeline.debug.PipelineDebugMeta)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)1 PipelineExecutionConfiguration (org.apache.hop.pipeline.PipelineExecutionConfiguration)1 PipelineDebugMeta (org.apache.hop.pipeline.debug.PipelineDebugMeta)1 TransformDebugMeta (org.apache.hop.pipeline.debug.TransformDebugMeta)1 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)1 PipelineDebugDialog (org.apache.hop.ui.pipeline.debug.PipelineDebugDialog)1 PipelineExecutionConfigurationDialog (org.apache.hop.ui.pipeline.dialog.PipelineExecutionConfigurationDialog)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1