use of org.pentaho.di.trans.debug.StepDebugMeta in project pentaho-kettle by pentaho.
the class TransGraph method showLastPreviewResults.
public synchronized void showLastPreviewResults() {
if (lastTransDebugMeta == null || lastTransDebugMeta.getStepDebugMetaMap().isEmpty()) {
return;
}
final List<String> stepnames = new ArrayList<>();
final List<RowMetaInterface> rowMetas = new ArrayList<>();
final List<List<Object[]>> rowBuffers = new ArrayList<>();
//
for (StepMeta stepMeta : lastTransDebugMeta.getStepDebugMetaMap().keySet()) {
StepDebugMeta stepDebugMeta = lastTransDebugMeta.getStepDebugMetaMap().get(stepMeta);
stepnames.add(stepMeta.getName());
rowMetas.add(stepDebugMeta.getRowBufferMeta());
rowBuffers.add(stepDebugMeta.getRowBuffer());
}
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
EnterPreviewRowsDialog dialog = new EnterPreviewRowsDialog(shell, SWT.NONE, stepnames, rowMetas, rowBuffers);
dialog.open();
}
});
}
use of org.pentaho.di.trans.debug.StepDebugMeta in project pentaho-kettle by pentaho.
the class TransDebugDialog method showStepDebugInformation.
private void showStepDebugInformation() {
//
for (Control control : wComposite.getChildren()) {
control.dispose();
}
wComposite.layout(true, true);
int[] selectionIndices = wSteps.table.getSelectionIndices();
if (selectionIndices == null || selectionIndices.length != 1) {
return;
}
previousIndex = selectionIndices[0];
// What step did we click on?
//
final StepMeta stepMeta = transDebugMeta.getTransMeta().getStep(selectionIndices[0]);
// What is the step debugging metadata?
// --> This can be null (most likely scenario)
//
final StepDebugMeta stepDebugMeta = stepDebugMetaMap.get(stepMeta);
// 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, "TransDebugDialog.RowCount.Label"), BaseMessages.getString(PKG, "TransDebugDialog.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, "TransDebugDialog.FirstRows.Label"));
wFirstRows.setToolTipText(BaseMessages.getString(PKG, "TransDebugDialog.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, "TransDebugDialog.PauseBreakPoint.Label"));
wPauseBreakPoint.setToolTipText(BaseMessages.getString(PKG, "TransDebugDialog.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 (stepDebugMeta != null) {
condition = stepDebugMeta.getCondition();
}
if (condition == null) {
condition = new Condition();
}
// The input fields...
try {
stepInputFields = transDebugMeta.getTransMeta().getStepFields(stepMeta);
} catch (KettleStepException e) {
stepInputFields = new RowMeta();
}
wlCondition = new Label(wComposite, SWT.RIGHT);
props.setLook(wlCondition);
wlCondition.setText(BaseMessages.getString(PKG, "TransDebugDialog.Condition.Label"));
wlCondition.setToolTipText(BaseMessages.getString(PKG, "TransDebugDialog.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);
wCondition = new ConditionEditor(wComposite, SWT.BORDER, condition, stepInputFields);
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);
getStepDebugData(stepDebugMeta);
// 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, "TransDebugDialog.Clear.Label"));
wClear.setToolTipText(BaseMessages.getString(PKG, "TransDebugDialog.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 step information for this step...
//
stepDebugMetaMap.remove(stepMeta);
wSteps.table.setSelection(new int[] {});
previousIndex = -1;
// refresh the steps list...
//
refreshStepList();
showStepDebugInformation();
}
});
wComposite.layout(true, true);
}
use of org.pentaho.di.trans.debug.StepDebugMeta in project pentaho-kettle by pentaho.
the class TransPreviewProgressDialog method doPreview.
private void doPreview(final IProgressMonitor progressMonitor, final boolean showErrorDialogs) {
// capture the date/time before trying to preview...used only if there is an error.
Date now = new Date();
progressMonitor.beginTask(BaseMessages.getString(PKG, "TransPreviewProgressDialog.Monitor.BeginTask.Title"), 100);
// This transformation is ready to run in preview!
trans = new Trans(transMeta);
trans.setPreview(true);
//
try {
trans.prepareExecution(null);
} catch (final KettleException e) {
if (showErrorDialogs) {
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
// We do not want to display all of the error messages for this ktr's log channel ID
// So we must parse out the error messages to display only the messages that are specific
// to this preview Exception
//
String errorMessage = parseErrorMessage(e.getMessage(), now);
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "TransPreviewProgressDialog.Exception.ErrorPreparingTransformation"), new Exception(errorMessage, e.getCause()));
}
});
}
//
return;
}
// Add the preview / debugging information...
//
transDebugMeta = new TransDebugMeta(transMeta);
for (int i = 0; i < previewStepNames.length; i++) {
StepMeta stepMeta = transMeta.findStep(previewStepNames[i]);
StepDebugMeta stepDebugMeta = new StepDebugMeta(stepMeta);
stepDebugMeta.setReadingFirstRows(true);
stepDebugMeta.setRowCount(previewSize[i]);
transDebugMeta.getStepDebugMetaMap().put(stepMeta, stepDebugMeta);
}
int previousPct = 0;
final List<String> previewComplete = new ArrayList<String>();
// We add a break-point that is called every time we have a step with a full preview row buffer
// That makes it easy and fast to see if we have all the rows we need
//
transDebugMeta.addBreakPointListers(new BreakPointListener() {
public void breakPointHit(TransDebugMeta transDebugMeta, StepDebugMeta stepDebugMeta, RowMetaInterface rowBufferMeta, List<Object[]> rowBuffer) {
String stepName = stepDebugMeta.getStepMeta().getName();
previewComplete.add(stepName);
progressMonitor.subTask(BaseMessages.getString(PKG, "TransPreviewProgressDialog.SubTask.StepPreviewFinished", stepName));
}
});
// set the appropriate listeners on the transformation...
//
transDebugMeta.addRowListenersToTransformation(trans);
//
try {
trans.startThreads();
} catch (final KettleException e) {
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "TransPreviewProgressDialog.Exception.ErrorPreparingTransformation"), e);
}
});
//
return;
}
while (previewComplete.size() < previewStepNames.length && !trans.isFinished() && !progressMonitor.isCanceled()) {
// How many rows are done?
int nrDone = 0;
int nrTotal = 0;
for (StepDebugMeta stepDebugMeta : transDebugMeta.getStepDebugMetaMap().values()) {
nrDone += stepDebugMeta.getRowBuffer().size();
nrTotal += stepDebugMeta.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;
trans.stopAll();
}
}
trans.stopAll();
// Capture preview activity to a String:
loggingText = KettleLogStore.getAppender().getBuffer(trans.getLogChannel().getLogChannelId(), true).toString();
progressMonitor.done();
}
use of org.pentaho.di.trans.debug.StepDebugMeta in project pentaho-kettle by pentaho.
the class TransDebugDialog method getStepDebugMeta.
/**
* Grab the step debugging information from the dialog. Store it in our private map
*/
private void getStepDebugMeta() {
int index = wSteps.getSelectionIndex();
if (previousIndex >= 0) {
//
if (wComposite.getChildren().length == 0) {
return;
}
StepMeta stepMeta = transDebugMeta.getTransMeta().getStep(previousIndex);
StepDebugMeta stepDebugMeta = new StepDebugMeta(stepMeta);
stepDebugMeta.setCondition(condition);
stepDebugMeta.setPausingOnBreakPoint(wPauseBreakPoint.getSelection());
stepDebugMeta.setReadingFirstRows(wFirstRows.getSelection());
stepDebugMeta.setRowCount(Const.toInt(wRowCount.getText(), -1));
stepDebugMetaMap.put(stepMeta, stepDebugMeta);
}
previousIndex = index;
}
use of org.pentaho.di.trans.debug.StepDebugMeta in project pentaho-kettle by pentaho.
the class TransDebugDialog method refreshStepList.
private void refreshStepList() {
GUIResource resource = GUIResource.getInstance();
// Add the list of steps...
//
int maxIconSize = 0;
int indexSelected = -1;
wSteps.table.removeAll();
for (int i = 0; i < transDebugMeta.getTransMeta().getSteps().size(); i++) {
StepMeta stepMeta = transDebugMeta.getTransMeta().getStep(i);
TableItem item = new TableItem(wSteps.table, SWT.NONE);
Image image = resource.getImagesSteps().get(stepMeta.getStepID()).getAsBitmapForSize(display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE);
item.setImage(0, image);
item.setText(0, "");
item.setText(1, stepMeta.getName());
if (image.getBounds().width > maxIconSize) {
maxIconSize = image.getBounds().width;
}
StepDebugMeta stepDebugMeta = stepDebugMetaMap.get(stepMeta);
if (stepDebugMeta != null) {
// We have debugging information so we mark the row
//
item.setBackground(resource.getColorLightPentaho());
if (indexSelected < 0) {
indexSelected = i;
}
}
}
wSteps.removeEmptyRows();
wSteps.optWidth(false);
wSteps.table.getColumn(0).setWidth(maxIconSize + 10);
wSteps.table.getColumn(0).setAlignment(SWT.CENTER);
//
if (indexSelected >= 0) {
wSteps.table.setSelection(indexSelected);
showStepDebugInformation();
}
}
Aggregations