use of org.pentaho.di.trans.steps.datagrid.DataGridMeta in project pentaho-kettle by pentaho.
the class TransMetaTest method testGetPrevInfoFields.
@Test
public void testGetPrevInfoFields() throws KettleStepException {
DataGridMeta dgm1 = new DataGridMeta();
dgm1.setFieldName(new String[] { "id", "colA" });
dgm1.allocate(2);
dgm1.setFieldType(new String[] { ValueMetaFactory.getValueMetaName(ValueMetaInterface.TYPE_INTEGER), ValueMetaFactory.getValueMetaName(ValueMetaInterface.TYPE_STRING) });
List<List<String>> dgm1Data = new ArrayList<>();
dgm1Data.add(Arrays.asList("1", "A"));
dgm1Data.add(Arrays.asList("2", "B"));
dgm1.setDataLines(dgm1Data);
DataGridMeta dgm2 = new DataGridMeta();
dgm2.allocate(1);
dgm2.setFieldName(new String[] { "moreData" });
dgm2.setFieldType(new String[] { ValueMetaFactory.getValueMetaName(ValueMetaInterface.TYPE_STRING) });
List<List<String>> dgm2Data = new ArrayList<>();
dgm2Data.add(Arrays.asList("Some Informational Data"));
dgm2.setDataLines(dgm2Data);
StepMeta dg1 = new StepMeta("input1", dgm1);
StepMeta dg2 = new StepMeta("input2", dgm2);
final String UDJC_METHOD = "public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { return false; }";
UserDefinedJavaClassMeta udjcMeta = new UserDefinedJavaClassMeta();
udjcMeta.getInfoStepDefinitions().add(new StepDefinition(dg2.getName(), dg2.getName(), dg2, "info_data"));
udjcMeta.replaceDefinitions(Collections.singletonList(new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "MainClass", UDJC_METHOD)));
StepMeta udjc = new StepMeta("PDI-14910", udjcMeta);
TransHopMeta hop1 = new TransHopMeta(dg1, udjc, true);
TransHopMeta hop2 = new TransHopMeta(dg2, udjc, true);
transMeta.addStep(dg1);
transMeta.addStep(dg2);
transMeta.addStep(udjc);
transMeta.addTransHop(hop1);
transMeta.addTransHop(hop2);
RowMetaInterface row = null;
row = transMeta.getPrevInfoFields(udjc);
assertNotNull(row);
assertEquals(1, row.size());
assertEquals("moreData", row.getValueMeta(0).getName());
assertEquals(ValueMetaInterface.TYPE_STRING, row.getValueMeta(0).getType());
}
use of org.pentaho.di.trans.steps.datagrid.DataGridMeta in project pentaho-kettle by pentaho.
the class TransMetaTest method testGetPrevStepFields.
@Test
public void testGetPrevStepFields() throws KettleStepException {
DataGridMeta dgm = new DataGridMeta();
dgm.allocate(2);
dgm.setFieldName(new String[] { "id" });
dgm.setFieldType(new String[] { ValueMetaFactory.getValueMetaName(ValueMetaInterface.TYPE_INTEGER) });
List<List<String>> dgm1Data = new ArrayList<>();
dgm1Data.add(Collections.singletonList("1"));
dgm1Data.add(Collections.singletonList("2"));
dgm.setDataLines(dgm1Data);
StepMeta dg = new StepMeta("input1", dgm);
TextFileOutputMeta textFileOutputMeta = new TextFileOutputMeta();
StepMeta textFileOutputStep = new StepMeta("BACKLOG-21039", textFileOutputMeta);
TransHopMeta hop = new TransHopMeta(dg, textFileOutputStep, true);
transMeta.addStep(dg);
transMeta.addStep(textFileOutputStep);
transMeta.addTransHop(hop);
RowMetaInterface row = transMeta.getPrevStepFields(textFileOutputStep);
assertNotNull(row);
assertEquals(1, row.size());
assertEquals("id", row.getValueMeta(0).getName());
assertEquals(ValueMetaInterface.TYPE_INTEGER, row.getValueMeta(0).getType());
dgm.setFieldName(new String[] { "id", "name" });
dgm.setFieldType(new String[] { ValueMetaFactory.getValueMetaName(ValueMetaInterface.TYPE_INTEGER), ValueMetaFactory.getValueMetaName(ValueMetaInterface.TYPE_STRING) });
row = transMeta.getPrevStepFields(textFileOutputStep);
assertNotNull(row);
assertEquals(2, row.size());
assertEquals("id", row.getValueMeta(0).getName());
assertEquals("name", row.getValueMeta(1).getName());
assertEquals(ValueMetaInterface.TYPE_INTEGER, row.getValueMeta(0).getType());
assertEquals(ValueMetaInterface.TYPE_STRING, row.getValueMeta(1).getType());
}
use of org.pentaho.di.trans.steps.datagrid.DataGridMeta in project pentaho-kettle by pentaho.
the class DataGridDialog method preview.
/**
* Preview the data generated by this step. This generates a transformation using this step & a dummy and previews it.
*/
private void preview() {
// Create the table input reader step...
DataGridMeta oneMeta = new DataGridMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "DataGridDialog.EnterPreviewSize.Title"), BaseMessages.getString(PKG, "DataGridDialog.EnterPreviewSize.Message"));
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.datagrid.DataGridMeta in project pentaho-kettle by pentaho.
the class PentahoReportingOutputIT method runTransformation.
private void runTransformation(PentahoReportingOutputMeta.ProcessorType processorType) throws Exception {
File tmp = File.createTempFile("PentahoReportingOutputTest", "PentahoReportingOutputTest");
tmp.deleteOnExit();
StepMeta outputStep = transMeta.findStep("Data Grid");
DataGridMeta metaGrid = (DataGridMeta) outputStep.getStepMetaInterface();
metaGrid.getDataLines().clear();
metaGrid.getDataLines().add(asList("src/it/resources/org/pentaho/di/trans/steps/pentahoreporting/pdi-13434.prpt", tmp.getAbsolutePath()));
StepMeta reportingStep = transMeta.findStep("Pentaho Reporting Output");
PentahoReportingOutputMeta reportingMeta = (PentahoReportingOutputMeta) reportingStep.getStepMetaInterface();
reportingMeta.setOutputProcessorType(processorType);
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
trans.startThreads();
trans.waitUntilFinished();
Assert.assertEquals(0, trans.getErrors());
Assert.assertTrue(tmp.length() > 0);
tmp.delete();
}
Aggregations