Search in sources :

Example 61 with DummyTransMeta

use of org.pentaho.di.trans.steps.dummytrans.DummyTransMeta in project pentaho-kettle by pentaho.

the class TransMetaTest method infoStepFieldsAreNotIncludedInGetStepFields.

@Test
public void infoStepFieldsAreNotIncludedInGetStepFields() throws KettleStepException {
    // validates that the fields from info steps are not included in the resulting step fields for a stepMeta.
    // This is important with steps like StreamLookup and Append, where the previous steps may or may not
    // have their fields included in the current step.
    TransMeta transMeta = new TransMeta(new Variables());
    StepMeta toBeAppended1 = testStep("toBeAppended1", // no info steps
    emptyList(), // names of fields from this step
    asList("field1", "field2"));
    StepMeta toBeAppended2 = testStep("toBeAppended2", emptyList(), asList("field1", "field2"));
    StepMeta append = testStep("append", // info step names
    asList("toBeAppended1", "toBeAppended2"), // output field of this step
    singletonList("outputField"));
    StepMeta after = new StepMeta("after", new DummyTransMeta());
    wireUpTestTransMeta(transMeta, toBeAppended1, toBeAppended2, append, after);
    RowMetaInterface results = transMeta.getStepFields(append, after, mock(ProgressMonitorListener.class));
    assertThat(1, equalTo(results.size()));
    assertThat("outputField", equalTo(results.getFieldNames()[0]));
}
Also used : Variables(org.pentaho.di.core.variables.Variables) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) ProgressMonitorListener(org.pentaho.di.core.ProgressMonitorListener) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) Test(org.junit.Test)

Example 62 with DummyTransMeta

use of org.pentaho.di.trans.steps.dummytrans.DummyTransMeta in project pentaho-kettle by pentaho.

the class TransPartitioningTest method prepareStepMetas_cl1_cl2.

/**
 * This is a case when we have 2 steps, but partitioned differently
 *
 * @throws KettlePluginException
 */
private void prepareStepMetas_cl1_cl2() throws KettlePluginException {
    StepMeta dummy1 = new StepMeta(ONE, null);
    StepMeta dummy2 = new StepMeta(TWO, null);
    PartitionSchema schema1 = new PartitionSchema("p1", Arrays.asList(new String[] { PID1, PID2 }));
    PartitionSchema schema2 = new PartitionSchema("p2", Arrays.asList(new String[] { PID1, PID2 }));
    StepPartitioningMeta partMeta1 = new StepPartitioningMeta("Mirror to all partitions", schema1);
    StepPartitioningMeta partMeta2 = new StepPartitioningMeta("Mirror to all partitions", schema2);
    partMeta1.setPartitionSchemaName(schema1.getName());
    partMeta2.setPartitionSchemaName(schema2.getName());
    dummy1.setStepPartitioningMeta(partMeta1);
    dummy2.setStepPartitioningMeta(partMeta2);
    chain.add(dummy1);
    chain.add(dummy2);
    for (StepMeta item : chain) {
        item.setStepMetaInterface(new DummyTransMeta());
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) StepPartitioningMeta(org.pentaho.di.trans.step.StepPartitioningMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)

Example 63 with DummyTransMeta

use of org.pentaho.di.trans.steps.dummytrans.DummyTransMeta in project pentaho-kettle by pentaho.

the class TransPartitioningTest method prepareStepMetas_x2_1.

/**
 * many steps copies to one
 */
private void prepareStepMetas_x2_1() {
    StepMeta dummy1 = new StepMeta(ONE, null);
    StepMeta dummy2 = new StepMeta(TWO, null);
    dummy1.setCopies(2);
    chain.add(dummy1);
    chain.add(dummy2);
    for (StepMeta item : chain) {
        item.setStepMetaInterface(new DummyTransMeta());
    }
}
Also used : StepMeta(org.pentaho.di.trans.step.StepMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)

Example 64 with DummyTransMeta

use of org.pentaho.di.trans.steps.dummytrans.DummyTransMeta in project pentaho-kettle by pentaho.

the class TransPartitioningTest method prepareStepMetas_cl1_cl1.

/**
 * This case simulates when we do have 2 step partitioned with one same partitioner We want to get a 'swim-lanes'
 * transformation
 *
 * @throws KettlePluginException
 */
private void prepareStepMetas_cl1_cl1() throws KettlePluginException {
    StepMeta dummy1 = new StepMeta(ONE, null);
    StepMeta dummy2 = new StepMeta(TWO, null);
    PartitionSchema schema = new PartitionSchema("p1", Arrays.asList(new String[] { PID1, PID2 }));
    // for delayed binding StepPartitioning meta does not achieve
    // schema name when using in constructor so we have to set it
    // explicitly. See equals implementation for StepPartitioningMeta.
    StepPartitioningMeta partMeta = new StepPartitioningMeta("Mirror to all partitions", schema);
    // that is what I am talking about:
    partMeta.setPartitionSchemaName(schema.getName());
    dummy1.setStepPartitioningMeta(partMeta);
    dummy2.setStepPartitioningMeta(partMeta);
    chain.add(dummy1);
    chain.add(dummy2);
    for (StepMeta item : chain) {
        item.setStepMetaInterface(new DummyTransMeta());
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) StepPartitioningMeta(org.pentaho.di.trans.step.StepPartitioningMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)

Example 65 with DummyTransMeta

use of org.pentaho.di.trans.steps.dummytrans.DummyTransMeta in project pentaho-kettle by pentaho.

the class GetXMLDataTest method testGetXMLData.

/**
 * Test case for Get XML Data step, very simple example.
 *
 * @throws Exception
 *           Upon any exception
 */
private void testGetXMLData(String missingElementValue) throws Exception {
    // 
    // Create a new transformation...
    // 
    TransMeta transMeta = new TransMeta();
    transMeta.setName("getxmldata1");
    PluginRegistry registry = PluginRegistry.getInstance();
    // 
    // create an injector step...
    // 
    String injectorStepname = "injector step";
    InjectorMeta im = new InjectorMeta();
    // Set the information of the injector.
    String injectorPid = registry.getPluginId(StepPluginType.class, im);
    StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, im);
    transMeta.addStep(injectorStep);
    // 
    // Create a Get XML Data step
    // 
    String getXMLDataName = "get xml data step";
    GetXMLDataMeta gxdm = new GetXMLDataMeta();
    String getXMLDataPid = registry.getPluginId(StepPluginType.class, gxdm);
    StepMeta getXMLDataStep = new StepMeta(getXMLDataPid, getXMLDataName, gxdm);
    transMeta.addStep(getXMLDataStep);
    GetXMLDataField[] fields = new GetXMLDataField[5];
    for (int idx = 0; idx < fields.length; idx++) {
        fields[idx] = new GetXMLDataField();
    }
    fields[0].setName("objectid");
    fields[0].setXPath("ObjectID");
    fields[0].setElementType(GetXMLDataField.ELEMENT_TYPE_NODE);
    fields[0].setType(ValueMetaInterface.TYPE_STRING);
    fields[0].setFormat("");
    fields[0].setLength(-1);
    fields[0].setPrecision(-1);
    fields[0].setCurrencySymbol("");
    fields[0].setDecimalSymbol("");
    fields[0].setGroupSymbol("");
    fields[0].setTrimType(GetXMLDataField.TYPE_TRIM_NONE);
    fields[1].setName("sapident");
    fields[1].setXPath("SAPIDENT");
    fields[1].setElementType(GetXMLDataField.ELEMENT_TYPE_NODE);
    fields[1].setType(ValueMetaInterface.TYPE_STRING);
    fields[1].setFormat("");
    fields[1].setLength(-1);
    fields[1].setPrecision(-1);
    fields[1].setCurrencySymbol("");
    fields[1].setDecimalSymbol("");
    fields[1].setGroupSymbol("");
    fields[1].setTrimType(GetXMLDataField.TYPE_TRIM_NONE);
    fields[2].setName("quantity");
    fields[2].setXPath("Quantity");
    fields[2].setElementType(GetXMLDataField.ELEMENT_TYPE_NODE);
    fields[2].setType(ValueMetaInterface.TYPE_STRING);
    fields[2].setFormat("");
    fields[2].setLength(-1);
    fields[2].setPrecision(-1);
    fields[2].setCurrencySymbol("");
    fields[2].setDecimalSymbol("");
    fields[2].setGroupSymbol("");
    fields[2].setTrimType(GetXMLDataField.TYPE_TRIM_NONE);
    fields[3].setName("merkmalname");
    fields[3].setXPath("Merkmalname");
    fields[3].setElementType(GetXMLDataField.ELEMENT_TYPE_NODE);
    fields[3].setType(ValueMetaInterface.TYPE_STRING);
    fields[3].setFormat("");
    fields[3].setLength(-1);
    fields[3].setPrecision(-1);
    fields[3].setCurrencySymbol("");
    fields[3].setDecimalSymbol("");
    fields[3].setGroupSymbol("");
    fields[3].setTrimType(GetXMLDataField.TYPE_TRIM_NONE);
    fields[4].setName("merkmalswert");
    fields[4].setXPath("Merkmalswert");
    fields[4].setElementType(GetXMLDataField.ELEMENT_TYPE_NODE);
    fields[4].setType(ValueMetaInterface.TYPE_STRING);
    fields[4].setFormat("");
    fields[4].setLength(-1);
    fields[4].setPrecision(-1);
    fields[4].setCurrencySymbol("");
    fields[4].setDecimalSymbol("");
    fields[4].setGroupSymbol("");
    fields[4].setTrimType(GetXMLDataField.TYPE_TRIM_NONE);
    gxdm.setEncoding("UTF-8");
    gxdm.setIsAFile(false);
    gxdm.setInFields(true);
    gxdm.setLoopXPath("Level1/Level2/Props");
    gxdm.setXMLField("field1");
    gxdm.setInputFields(fields);
    TransHopMeta hi = new TransHopMeta(injectorStep, getXMLDataStep);
    transMeta.addTransHop(hi);
    // 
    // Create a dummy step 1
    // 
    String dummyStepname1 = "dummy step 1";
    DummyTransMeta dm1 = new DummyTransMeta();
    String dummyPid1 = registry.getPluginId(StepPluginType.class, dm1);
    StepMeta dummyStep1 = new StepMeta(dummyPid1, dummyStepname1, dm1);
    transMeta.addStep(dummyStep1);
    TransHopMeta hi1 = new TransHopMeta(getXMLDataStep, dummyStep1);
    transMeta.addTransHop(hi1);
    // Now execute the transformation...
    Trans trans = new Trans(transMeta);
    trans.prepareExecution(null);
    StepInterface si = trans.getStepInterface(dummyStepname1, 0);
    RowStepCollector dummyRc1 = new RowStepCollector();
    si.addRowListener(dummyRc1);
    RowProducer rp = trans.addRowProducer(injectorStepname, 0);
    trans.startThreads();
    // add rows
    List<RowMetaAndData> inputList = createData();
    Iterator<RowMetaAndData> it = inputList.iterator();
    while (it.hasNext()) {
        RowMetaAndData rm = it.next();
        rp.putRow(rm.getRowMeta(), rm.getData());
    }
    rp.finished();
    trans.waitUntilFinished();
    // Compare the results
    List<RowMetaAndData> resultRows = dummyRc1.getRowsWritten();
    List<RowMetaAndData> goldenImageRows = createResultData(missingElementValue);
    checkRows(goldenImageRows, resultRows);
}
Also used : RowProducer(org.pentaho.di.trans.RowProducer) RowStepCollector(org.pentaho.di.trans.RowStepCollector) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) InjectorMeta(org.pentaho.di.trans.steps.injector.InjectorMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) StepInterface(org.pentaho.di.trans.step.StepInterface) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) TransHopMeta(org.pentaho.di.trans.TransHopMeta) Trans(org.pentaho.di.trans.Trans)

Aggregations

DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)85 StepMeta (org.pentaho.di.trans.step.StepMeta)84 TransMeta (org.pentaho.di.trans.TransMeta)53 TransHopMeta (org.pentaho.di.trans.TransHopMeta)52 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)49 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)46 Trans (org.pentaho.di.trans.Trans)46 StepInterface (org.pentaho.di.trans.step.StepInterface)46 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)45 RowStepCollector (org.pentaho.di.trans.RowStepCollector)42 InjectorMeta (org.pentaho.di.trans.steps.injector.InjectorMeta)38 RowProducer (org.pentaho.di.trans.RowProducer)36 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)11 UniqueRowsMeta (org.pentaho.di.trans.steps.uniquerows.UniqueRowsMeta)7 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)6 PartitionSchema (org.pentaho.di.partition.PartitionSchema)5 StepPartitioningMeta (org.pentaho.di.trans.step.StepPartitioningMeta)5 GetVariableMeta (org.pentaho.di.trans.steps.getvariable.GetVariableMeta)5 FieldDefinition (org.pentaho.di.trans.steps.getvariable.GetVariableMeta.FieldDefinition)5