Search in sources :

Example 11 with RowGeneratorMeta

use of org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta in project pentaho-kettle by pentaho.

the class JsonOutputTest method createRowGeneratorStep.

/**
 * Creates a row generator step for this class..
 *
 * @param name
 * @param registry
 * @return
 */
private StepMeta createRowGeneratorStep(String name, PluginRegistry registry) {
    // Default the name if it is empty
    String testFileOutputName = (Utils.isEmpty(name) ? "generate rows" : name);
    // create the RowGenerator and Step Meta
    RowGeneratorMeta rowGeneratorMeta = new RowGeneratorMeta();
    String rowGeneratorPid = registry.getPluginId(StepPluginType.class, rowGeneratorMeta);
    StepMeta generateRowsStep = new StepMeta(rowGeneratorPid, testFileOutputName, rowGeneratorMeta);
    // Set the field names, types and values
    rowGeneratorMeta.setFieldName(new String[] { "Id", "State", "City" });
    rowGeneratorMeta.setFieldType(new String[] { "Integer", "String", "String" });
    rowGeneratorMeta.setValue(new String[] { "1", "Florida", "Orlando" });
    rowGeneratorMeta.setFieldLength(new int[] { -1, -1, -1 });
    rowGeneratorMeta.setFieldPrecision(new int[] { -1, -1, -1 });
    rowGeneratorMeta.setGroup(new String[] { "", "", "" });
    rowGeneratorMeta.setDecimal(new String[] { "", "", "" });
    rowGeneratorMeta.setCurrency(new String[] { "", "", "" });
    rowGeneratorMeta.setFieldFormat(new String[] { "", "", "" });
    rowGeneratorMeta.setRowLimit("10");
    // return the step meta
    return generateRowsStep;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowGeneratorMeta(org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta) StepMeta(org.pentaho.di.trans.step.StepMeta)

Example 12 with RowGeneratorMeta

use of org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta in project pentaho-kettle by pentaho.

the class JobEntryTransIntIT method createPDI14676Transformation.

private String createPDI14676Transformation() throws IOException, KettleException {
    // Setup Transformation
    String rowGenStepName = "Generate Rows";
    RowGeneratorMeta rowGenMeta = new RowGeneratorMeta();
    rowGenMeta.setRowLimit(String.valueOf(Integer.MAX_VALUE));
    rowGenMeta.setNeverEnding(true);
    rowGenMeta.setIntervalInMs("0");
    rowGenMeta.allocate(0);
    TransMeta tMeta = TransTestFactory.generateTestTransformation(new Variables(), rowGenMeta, rowGenStepName);
    // Remove the Injector step, as it's not needed for this transformation
    TransHopMeta hopToRemove = tMeta.findTransHop(tMeta.findStep(TransTestFactory.INJECTOR_STEPNAME), tMeta.findStep(rowGenStepName));
    tMeta.removeTransHop(tMeta.indexOfTransHop(hopToRemove));
    tMeta.removeStep(tMeta.indexOfStep(tMeta.findStep(TransTestFactory.INJECTOR_STEPNAME)));
    // Write transformation to temp file, for use within a job
    String transFilename = TestUtilities.createEmptyTempFile(this.getClass().getSimpleName() + "_PDI14676_", ".ktr");
    FileObject transFile = TestUtils.getFileObject(transFilename);
    OutputStream outStream = transFile.getContent().getOutputStream();
    PrintWriter pw = new PrintWriter(outStream);
    pw.write(tMeta.getXML());
    pw.close();
    outStream.close();
    return transFilename;
}
Also used : Variables(org.pentaho.di.core.variables.Variables) OutputStream(java.io.OutputStream) TransMeta(org.pentaho.di.trans.TransMeta) TransHopMeta(org.pentaho.di.trans.TransHopMeta) FileObject(org.apache.commons.vfs2.FileObject) RowGeneratorMeta(org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta) PrintWriter(java.io.PrintWriter)

Example 13 with RowGeneratorMeta

use of org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta in project pentaho-kettle by pentaho.

the class TextFileOutputIT method createRowGeneratorStep.

/**
 * Creates a row generator step for this class..
 *
 * @param name
 * @param registry
 * @return
 */
private StepMeta createRowGeneratorStep(String name, PluginRegistry registry) {
    // Default the name if it is empty
    String testFileOutputName = (Utils.isEmpty(name) ? "generate rows" : name);
    // create the RowGenerator and Step Meta
    RowGeneratorMeta rowGeneratorMeta = new RowGeneratorMeta();
    String rowGeneratorPid = registry.getPluginId(StepPluginType.class, rowGeneratorMeta);
    StepMeta generateRowsStep = new StepMeta(rowGeneratorPid, testFileOutputName, rowGeneratorMeta);
    // Set the field names, types and values
    rowGeneratorMeta.setFieldName(new String[] { "Id", "State", "City" });
    rowGeneratorMeta.setFieldType(new String[] { "Integer", "String", "String" });
    rowGeneratorMeta.setValue(new String[] { "1", "Orlando", "Florida" });
    rowGeneratorMeta.setFieldLength(new int[] { -1, -1, -1 });
    rowGeneratorMeta.setFieldPrecision(new int[] { -1, -1, -1 });
    rowGeneratorMeta.setGroup(new String[] { "", "", "" });
    rowGeneratorMeta.setDecimal(new String[] { "", "", "" });
    rowGeneratorMeta.setCurrency(new String[] { "", "", "" });
    rowGeneratorMeta.setFieldFormat(new String[] { "", "", "" });
    rowGeneratorMeta.setRowLimit("10");
    // return the step meta
    return generateRowsStep;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowGeneratorMeta(org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta) StepMeta(org.pentaho.di.trans.step.StepMeta)

Example 14 with RowGeneratorMeta

use of org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta in project pentaho-kettle by pentaho.

the class CarteIT method generateTestTransformation.

// CHECKSTYLE:Indentation:OFF
public static Trans generateTestTransformation() {
    RowGeneratorMeta A = new RowGeneratorMeta();
    A.allocate(3);
    A.setRowLimit("10000000");
    A.getFieldName()[0] = "ID";
    A.getFieldType()[0] = ValueMetaFactory.getValueMetaName(ValueMetaInterface.TYPE_INTEGER);
    A.getFieldLength()[0] = 7;
    A.getValue()[0] = "1234";
    A.getFieldName()[1] = "Name";
    A.getFieldType()[1] = ValueMetaFactory.getValueMetaName(ValueMetaInterface.TYPE_STRING);
    A.getFieldLength()[1] = 35;
    A.getValue()[1] = "Some name";
    A.getFieldName()[2] = "Last updated";
    A.getFieldType()[2] = ValueMetaFactory.getValueMetaName(ValueMetaInterface.TYPE_DATE);
    A.getFieldFormat()[2] = "yyyy/MM/dd";
    A.getValue()[2] = "2010/02/09";
    TransMeta transMeta = TransPreviewFactory.generatePreviewTransformation(null, A, "A");
    transMeta.setName("CarteUnitTest");
    transMeta.setSizeRowset(2500);
    transMeta.setFeedbackSize(50000);
    transMeta.setUsingThreadPriorityManagment(false);
    return new Trans(transMeta);
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) RowGeneratorMeta(org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta) Trans(org.pentaho.di.trans.Trans)

Aggregations

RowGeneratorMeta (org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta)14 StepMeta (org.pentaho.di.trans.step.StepMeta)10 TransMeta (org.pentaho.di.trans.TransMeta)9 Trans (org.pentaho.di.trans.Trans)8 TransHopMeta (org.pentaho.di.trans.TransHopMeta)8 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)6 KettleException (org.pentaho.di.core.exception.KettleException)5 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)5 Point (org.eclipse.swt.graphics.Point)4 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)4 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)4 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)4 Date (java.util.Date)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 StepPluginType (org.pentaho.di.core.plugins.StepPluginType)3 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)3 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)3 RowStepCollector (org.pentaho.di.trans.RowStepCollector)3 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)3 StepInterface (org.pentaho.di.trans.step.StepInterface)3