Search in sources :

Example 1 with SampleRowsMeta

use of org.pentaho.di.trans.steps.samplerows.SampleRowsMeta in project pdi-dataservice-server-plugin by pentaho.

the class SqlTransGenerator method generateSampleStep.

private StepMeta generateSampleStep() {
    SampleRowsMeta meta = new SampleRowsMeta();
    meta.setLinesRange("1.." + rowLimit);
    StepMeta stepMeta = new StepMeta("Sample rows", meta);
    stepMeta.setLocation(xLocation, 50);
    xLocation += 100;
    stepMeta.setDraw(true);
    return stepMeta;
}
Also used : SampleRowsMeta(org.pentaho.di.trans.steps.samplerows.SampleRowsMeta) StepMeta(org.pentaho.di.trans.step.StepMeta)

Example 2 with SampleRowsMeta

use of org.pentaho.di.trans.steps.samplerows.SampleRowsMeta in project pdi-dataservice-server-plugin by pentaho.

the class SqlTransGeneratorTest method testServiceLimit.

@Test
public void testServiceLimit() throws KettleException {
    SQL sql = new SQL("SELECT * FROM table");
    RowMetaInterface rowMeta = new RowMeta();
    rowMeta.addValueMeta(new ValueMetaString("foo"));
    sql.parse(rowMeta);
    final String genLimitStep = "Limit input rows";
    SqlTransGenerator generator = new SqlTransGenerator(sql, 0, 2);
    TransMeta transMeta = generator.generateTransMeta();
    SampleRowsMeta limitInput = (SampleRowsMeta) getStepByName(transMeta, genLimitStep);
    assertEquals("limit not generated", "1..2", limitInput.getLinesRange());
    // bad value
    generator = new SqlTransGenerator(sql, 0, -3);
    transMeta = generator.generateTransMeta();
    assertTrue("limit<=0 not ignored", Arrays.asList(transMeta.getStepNames()).indexOf(genLimitStep) < 0);
}
Also used : SampleRowsMeta(org.pentaho.di.trans.steps.samplerows.SampleRowsMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Example 3 with SampleRowsMeta

use of org.pentaho.di.trans.steps.samplerows.SampleRowsMeta in project pdi-dataservice-server-plugin by pentaho.

the class SqlTransGenerator method generateLimitStep.

private StepMeta generateLimitStep(final String name, int offset, int limit) {
    SampleRowsMeta meta = new SampleRowsMeta();
    meta.setLinesRange((offset + 1) + ".." + (offset + limit));
    StepMeta stepMeta = new StepMeta(name, meta);
    stepMeta.setLocation(xLocation, 50);
    xLocation += 100;
    stepMeta.setDraw(true);
    return stepMeta;
}
Also used : SampleRowsMeta(org.pentaho.di.trans.steps.samplerows.SampleRowsMeta) StepMeta(org.pentaho.di.trans.step.StepMeta)

Aggregations

SampleRowsMeta (org.pentaho.di.trans.steps.samplerows.SampleRowsMeta)3 StepMeta (org.pentaho.di.trans.step.StepMeta)2 Test (org.junit.Test)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 SQL (org.pentaho.di.core.sql.SQL)1 TransMeta (org.pentaho.di.trans.TransMeta)1