use of org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class UserDefinedJavaClassDialog method test.
private boolean test() {
PluginRegistry registry = PluginRegistry.getInstance();
String scriptStepName = wStepname.getText();
if (!checkForTransformClass()) {
return false;
}
// Create a step with the information in this dialog
UserDefinedJavaClassMeta udjcMeta = new UserDefinedJavaClassMeta();
getInfo(udjcMeta);
try {
// First, before we get into the trial run, just see if the classes
// all compile.
udjcMeta.cookClasses();
if (udjcMeta.cookErrors.size() == 1) {
Exception e = udjcMeta.cookErrors.get(0);
new ErrorDialog(shell, "Error during class compilation", e.toString(), e);
return false;
} else if (udjcMeta.cookErrors.size() > 1) {
Exception e = udjcMeta.cookErrors.get(0);
new ErrorDialog(shell, "Errors during class compilation", String.format("Multiple errors during class compilation. First error:\n%s", e.toString()), e);
return false;
}
// What fields are coming into the step?
RowMetaInterface rowMeta = transMeta.getPrevStepFields(stepname).clone();
if (rowMeta != null) {
// time
if (genMeta == null) {
genMeta = new RowGeneratorMeta();
genMeta.setRowLimit("10");
genMeta.allocate(rowMeta.size());
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < rowMeta.size(); i++) {
ValueMetaInterface valueMeta = rowMeta.getValueMeta(i);
if (valueMeta.isStorageBinaryString()) {
valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
}
genMeta.getFieldName()[i] = valueMeta.getName();
genMeta.getFieldType()[i] = valueMeta.getTypeDesc();
genMeta.getFieldLength()[i] = valueMeta.getLength();
genMeta.getFieldPrecision()[i] = valueMeta.getPrecision();
genMeta.getCurrency()[i] = valueMeta.getCurrencySymbol();
genMeta.getDecimal()[i] = valueMeta.getDecimalSymbol();
genMeta.getGroup()[i] = valueMeta.getGroupingSymbol();
String string = null;
switch(valueMeta.getType()) {
case ValueMetaInterface.TYPE_DATE:
genMeta.getFieldFormat()[i] = "yyyy/MM/dd HH:mm:ss";
valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
string = valueMeta.getString(new Date());
break;
case ValueMetaInterface.TYPE_STRING:
string = "test value test value";
break;
case ValueMetaInterface.TYPE_INTEGER:
genMeta.getFieldFormat()[i] = "#";
valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
string = valueMeta.getString(Long.valueOf(0L));
break;
case ValueMetaInterface.TYPE_NUMBER:
genMeta.getFieldFormat()[i] = "#.#";
valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
string = valueMeta.getString(Double.valueOf(0.0D));
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
genMeta.getFieldFormat()[i] = "#.#";
valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
string = valueMeta.getString(BigDecimal.ZERO);
break;
case ValueMetaInterface.TYPE_BOOLEAN:
string = valueMeta.getString(Boolean.TRUE);
break;
case ValueMetaInterface.TYPE_BINARY:
string = valueMeta.getString(new byte[] { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74 });
break;
default:
break;
}
genMeta.getValue()[i] = string;
}
}
StepMeta genStep = new StepMeta(registry.getPluginId(StepPluginType.class, genMeta), "## TEST DATA ##", genMeta);
genStep.setLocation(50, 50);
StepMeta scriptStep = new StepMeta(registry.getPluginId(StepPluginType.class, udjcMeta), Const.NVL(scriptStepName, "## SCRIPT ##"), udjcMeta);
scriptStepName = scriptStep.getName();
scriptStep.setLocation(150, 50);
// Create a hop between both steps...
//
TransHopMeta hop = new TransHopMeta(genStep, scriptStep);
// Generate a new test transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName(wStepname.getText() + " - PREVIEW");
transMeta.addStep(genStep);
transMeta.addStep(scriptStep);
transMeta.addTransHop(hop);
//
if (Spoon.getInstance().editStep(transMeta, genStep) != null) {
// Now run this transformation and grab the results...
//
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, transMeta, new String[] { scriptStepName }, new int[] { Const.toInt(genMeta.getRowLimit(), 10) });
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("System.Dialog.PreviewError.Title"), BaseMessages.getString("System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
}
RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta(wStepname.getText());
List<Object[]> previewRows = progressDialog.getPreviewRows(wStepname.getText());
if (previewRowsMeta != null && previewRows != null && previewRows.size() > 0) {
PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), previewRowsMeta, previewRows, loggingText);
prd.open();
}
}
return true;
} else {
throw new KettleException(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Exception.CouldNotGetFields"));
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.TestFailed.DialogTitle"), BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.TestFailed.DialogMessage"), e);
return false;
}
}
use of org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class GaInputStepDialog method preview.
// Preview the data
private void preview() {
// Create the XML input step
GaInputStepMeta oneMeta = new GaInputStepMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GoogleAnalyticsDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "GoogleAnalyticsDialog.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.ui.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class SapInputDialog method preview.
// Preview the data
// unused
// preserve for later
private void preview() {
// Create the XML input step
SapInputMeta oneMeta = new SapInputMeta();
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.ui.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class XMLInputDialog method preview.
// Preview the data
private void preview() {
try {
// Create the XML input step
XMLInputMeta oneMeta = new XMLInputMeta();
getInfo(oneMeta);
// check if the path is given
if (!checkInputPositionsFilled(oneMeta)) {
return;
}
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "XMLInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.NumberRows.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
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();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "XMLInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.ErrorPreviewingData.DialogMessage"), e);
}
}
use of org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class CommonStepDialog method preview.
private void preview() {
// good measure
if (!fieldsExist()) {
openNoFieldsDialog();
return;
}
// Create the XML meta step
final StepMetaType populatedMeta = (StepMetaType) getPopulatedMeta();
final TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, populatedMeta, wStepname.getText());
final EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, // $NON-NLS-1$
"CommonStepDialog.PreviewSize.DialogTitle"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CommonStepDialog.PreviewSize.DialogMessage"));
final int previewSize = numberDialog.open();
if (previewSize > 0) {
final TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open(false);
final Trans trans = progressDialog.getTrans();
final String loggingText = progressDialog.getLoggingText();
if (!progressDialog.isCancelled()) {
if (trans.getResult() != null) {
if (trans.getResult().getNrErrors() > 0) {
openPreviewError();
// there are errors - return
return;
}
}
}
final List previewRows = progressDialog.getPreviewRows(wStepname.getText());
if (previewRows == null || previewRows.size() == 0) {
openNoRowsToPreviewError();
} else {
final PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), previewRows, loggingText);
prd.open();
}
}
}
Aggregations