use of org.pentaho.di.trans.steps.csvinput.CsvInputMeta in project pentaho-kettle by pentaho.
the class CsvInputDialog method preview.
// Preview the data
private synchronized void preview() {
// Create the XML input step
CsvInputMeta oneMeta = new CsvInputMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
transMeta.getVariable("Internal.Transformation.Filename.Directory");
previewMeta.getVariable("Internal.Transformation.Filename.Directory");
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "CsvInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "CsvInputDialog.PreviewSize.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open();
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (!progressDialog.isCancelled()) {
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
prd.open();
}
}
use of org.pentaho.di.trans.steps.csvinput.CsvInputMeta in project pentaho-kettle by pentaho.
the class CsvInputDialog method updatePreview.
/**
* Load metadata from step window
*/
protected void updatePreview() {
if (initializing) {
return;
}
if (previewBusy.get()) {
return;
}
try {
previewBusy.set(true);
CsvInputMeta meta = new CsvInputMeta();
getInfo(meta);
//
if (Utils.isEmpty(meta.getFilename())) {
return;
}
if (Utils.isEmpty(meta.getInputFields())) {
return;
}
String stepname = wStepname.getText();
// StepMeta stepMeta = new StepMeta(stepname, meta);
StringBuffer buffer = new StringBuffer();
final List<Object[]> rowsData = new ArrayList<Object[]>();
final RowMetaInterface rowMeta = new RowMeta();
try {
meta.getFields(rowMeta, stepname, null, null, transMeta, repository, metaStore);
TransMeta previewTransMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, meta, stepname);
final Trans trans = new Trans(previewTransMeta);
trans.prepareExecution(null);
StepInterface step = trans.getRunThread(stepname, 0);
step.addRowListener(new RowAdapter() {
@Override
public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
rowsData.add(row);
//
if (rowsData.size() > PropsUI.getInstance().getDefaultPreviewSize()) {
trans.stopAll();
}
}
});
trans.startThreads();
trans.waitUntilFinished();
if (trans.getErrors() > 0) {
StringBuffer log = KettleLogStore.getAppender().getBuffer(trans.getLogChannelId(), false);
buffer.append(log);
}
KettleLogStore.discardLines(trans.getLogChannelId(), false);
LoggingRegistry.getInstance().removeIncludingChildren(trans.getLogChannelId());
} catch (Exception e) {
buffer.append(Const.getStackTracker(e));
}
TransGraph transGraph = Spoon.getInstance().getActiveTransGraph();
if (transGraph != null) {
if (!transGraph.isExecutionResultsPaneVisible()) {
transGraph.showExecutionResults();
}
transGraph.extraViewTabFolder.setSelection(5);
transGraph.transPreviewDelegate.addPreviewData(stepMeta, rowMeta, rowsData, buffer);
transGraph.transPreviewDelegate.setSelectedStep(stepMeta);
transGraph.transPreviewDelegate.refreshView();
}
} finally {
previewBusy.set(false);
}
}
Aggregations