Java Code Examples for org.pentaho.di.trans.Trans#findBaseSteps()

The following examples show how to use org.pentaho.di.trans.Trans#findBaseSteps() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MappingIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * This method runs transformations related to PDI-13545.<br/> The scenario is the following: there are two step
 * generating data, the latter of which is a Mapping step. They are followed with a Join Rows step, that has two
 * copies. The last in a row is a Dummy step, named "Last". Since both generating steps output 3 rows ([10, 20, 30]
 * and [1, 2, 3] respectively), the last step must obtain 3*3=9 rows.
 *
 * @param transPath a path to transformation file
 * @throws Exception
 */
private void runTransWhenMappingsIsFollowedByCopiedStep( String transPath ) throws Exception {
  KettleEnvironment.init();

  TransMeta transMeta = new TransMeta( transPath );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );

  Trans trans = new Trans( transMeta );
  trans.prepareExecution( null );
  trans.startThreads();
  trans.waitUntilFinished();

  assertEquals( 0, trans.getErrors() );

  List<StepInterface> list = trans.findBaseSteps( "Last" );
  assertEquals( 1, list.size() );
  assertEquals( 9, list.get( 0 ).getLinesRead() );
}
 
Example 2
Source File: TransDebugMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public synchronized void addRowListenersToTransformation( final Trans trans ) {

    final TransDebugMeta self = this;

    // for every step in the map, add a row listener...
    //
    for ( final Map.Entry<StepMeta, StepDebugMeta> entry : stepDebugMetaMap.entrySet() ) {
      final StepMeta stepMeta = entry.getKey();
      final StepDebugMeta stepDebugMeta = entry.getValue();

      // What is the transformation thread to attach a listener to?
      //
      for ( StepInterface baseStep : trans.findBaseSteps( stepMeta.getName() ) ) {
        baseStep.addRowListener( new RowAdapter() {
          public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException {
            rowWrittenEventHandler( rowMeta, row, stepDebugMeta, trans, self );
          }
        } );
      }
    }
  }