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();
}
Aggregations