Search in sources :

Example 1 with TransDebugMetaWrapper

use of org.pentaho.di.trans.debug.TransDebugMetaWrapper in project pentaho-kettle by pentaho.

the class TransGraph method debug.

public synchronized void debug(TransExecutionConfiguration executionConfiguration, TransDebugMeta transDebugMeta) {
    if (!running) {
        try {
            this.lastTransDebugMeta = transDebugMeta;
            log.setLogLevel(executionConfiguration.getLogLevel());
            if (log.isDetailed()) {
                log.logDetailed(BaseMessages.getString(PKG, "TransLog.Log.DoPreview"));
            }
            String[] args = null;
            Map<String, String> arguments = executionConfiguration.getArguments();
            if (arguments != null) {
                args = convertArguments(arguments);
            }
            transMeta.injectVariables(executionConfiguration.getVariables());
            // Set the named parameters
            Map<String, String> paramMap = executionConfiguration.getParams();
            Set<String> keys = paramMap.keySet();
            for (String key : keys) {
                transMeta.setParameterValue(key, Const.NVL(paramMap.get(key), ""));
            }
            transMeta.activateParameters();
            // 
            if (executionConfiguration.isClearingLog()) {
                transLogDelegate.clearLog();
            }
            // 
            if (trans != null) {
                KettleLogStore.discardLines(trans.getLogChannelId(), false);
                LoggingRegistry.getInstance().removeIncludingChildren(trans.getLogChannelId());
            }
            // Create a new transformation to execution
            // 
            trans = new Trans(transMeta);
            trans.setSafeModeEnabled(executionConfiguration.isSafeModeEnabled());
            trans.setPreview(true);
            trans.setGatheringMetrics(executionConfiguration.isGatheringMetrics());
            trans.setMetaStore(spoon.getMetaStore());
            trans.prepareExecution(args);
            trans.setRepository(spoon.rep);
            List<SpoonUiExtenderPluginInterface> relevantExtenders = SpoonUiExtenderPluginType.getInstance().getRelevantExtenders(TransDebugMetaWrapper.class, PREVIEW_TRANS);
            TransDebugMetaWrapper transDebugMetaWrapper = new TransDebugMetaWrapper(trans, transDebugMeta);
            for (SpoonUiExtenderPluginInterface relevantExtender : relevantExtenders) {
                relevantExtender.uiEvent(transDebugMetaWrapper, PREVIEW_TRANS);
            }
            // Add the row listeners to the allocated threads
            // 
            transDebugMeta.addRowListenersToTransformation(trans);
            // What method should we call back when a break-point is hit?
            transDebugMeta.addBreakPointListers(new BreakPointListener() {

                @Override
                public void breakPointHit(TransDebugMeta transDebugMeta, StepDebugMeta stepDebugMeta, RowMetaInterface rowBufferMeta, List<Object[]> rowBuffer) {
                    showPreview(transDebugMeta, stepDebugMeta, rowBufferMeta, rowBuffer);
                }
            });
            // 
            if (transPreviewDelegate.isActive()) {
                transPreviewDelegate.capturePreviewData(trans, transMeta.getSteps());
            }
            // Start the threads for the steps...
            // 
            startThreads();
            debug = true;
            // Show the execution results view...
            // 
            shell.getDisplay().asyncExec(new Runnable() {

                @Override
                public void run() {
                    addAllTabs();
                }
            });
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "TransLog.Dialog.UnexpectedErrorDuringPreview.Title"), BaseMessages.getString(PKG, "TransLog.Dialog.UnexpectedErrorDuringPreview.Message"), e);
        }
    } else {
        MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
        m.setText(BaseMessages.getString(PKG, "TransLog.Dialog.DoNoPreviewWhileRunning.Title"));
        m.setMessage(BaseMessages.getString(PKG, "TransLog.Dialog.DoNoPreviewWhileRunning.Message"));
        m.open();
    }
    checkErrorVisuals();
}
Also used : TransDebugMetaWrapper(org.pentaho.di.trans.debug.TransDebugMetaWrapper) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) XulException(org.pentaho.ui.xul.XulException) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException) MessageBox(org.eclipse.swt.widgets.MessageBox) SpoonUiExtenderPluginInterface(org.pentaho.di.ui.spoon.SpoonUiExtenderPluginInterface) BreakPointListener(org.pentaho.di.trans.debug.BreakPointListener) Trans(org.pentaho.di.trans.Trans) TransDebugMeta(org.pentaho.di.trans.debug.TransDebugMeta) StepDebugMeta(org.pentaho.di.trans.debug.StepDebugMeta)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 KettleValueException (org.pentaho.di.core.exception.KettleValueException)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)1 Trans (org.pentaho.di.trans.Trans)1 BreakPointListener (org.pentaho.di.trans.debug.BreakPointListener)1 StepDebugMeta (org.pentaho.di.trans.debug.StepDebugMeta)1 TransDebugMeta (org.pentaho.di.trans.debug.TransDebugMeta)1 TransDebugMetaWrapper (org.pentaho.di.trans.debug.TransDebugMetaWrapper)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 SpoonUiExtenderPluginInterface (org.pentaho.di.ui.spoon.SpoonUiExtenderPluginInterface)1 XulException (org.pentaho.ui.xul.XulException)1