Java Code Examples for org.pentaho.di.trans.TransMeta#setTransformationType()

The following examples show how to use org.pentaho.di.trans.TransMeta#setTransformationType() . 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: ConcatFieldsPDI10856IT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void rowLevelLoggingDoesNotFail() throws Exception {
  KettleEnvironment.init();

  TransMeta transMeta = new TransMeta( "src/it/resources/org/pentaho/di/trans/steps/concatfields/PDI-10856.ktr" );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );

  Trans trans = new Trans( transMeta );
  trans.setLogLevel( LogLevel.ROWLEVEL );

  trans.prepareExecution( null );
  trans.startThreads();
  trans.waitUntilFinished();

  Assert.assertEquals(0, trans.getErrors());
}
 
Example 3
Source File: TestUtilities.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static Trans loadAndRunTransformation( String path, Object... parameters ) throws Exception {
  TransMeta transMeta = new TransMeta( path );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );

  Trans trans = new Trans( transMeta );
  if ( parameters != null ) {
    if ( parameters.length % 2 == 1 ) {
      throw new IllegalArgumentException( "Parameters should be an array of pairs 'parameter'-'value'-..." );
    }

    for ( int i = 0; i < parameters.length; i += 2 ) {
      Object parameter = parameters[ i ];
      Object value = parameters[i + 1];
      trans.setParameterValue( parameter.toString(), value.toString() );
    }
  }

  trans.prepareExecution( null );
  trans.startThreads();
  trans.waitUntilFinished();

  return trans;
}
 
Example 4
Source File: TestUtilities.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static Trans loadAndRunTransformation( String path, Object... parameters ) throws Exception {
  TransMeta transMeta = new TransMeta( path );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );

  Trans trans = new Trans( transMeta );
  if ( parameters != null ) {
    if ( parameters.length % 2 == 1 ) {
      throw new IllegalArgumentException( "Parameters should be an array of pairs 'parameter'-'value'-..." );
    }

    for ( int i = 0; i < parameters.length; i += 2 ) {
      Object parameter = parameters[i];
      Object value = parameters[i + 1];
      trans.setParameterValue( parameter.toString(), value.toString() );
    }
  }

  trans.prepareExecution( null );
  trans.startThreads();
  trans.waitUntilFinished();

  return trans;
}
 
Example 5
Source File: MRUtil.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
public static Trans getTrans( final Configuration conf, final String transXml, boolean singleThreaded )
  throws KettleException {
  initKettleEnvironment( conf );

  TransConfiguration transConfiguration = TransConfiguration.fromXML( transXml );
  TransMeta transMeta = transConfiguration.getTransMeta();
  String carteObjectId = UUID.randomUUID().toString();
  SimpleLoggingObject servletLoggingObject =
    new SimpleLoggingObject( "HADOOP_MAPPER", LoggingObjectType.CARTE, null ); //$NON-NLS-1$
  servletLoggingObject.setContainerObjectId( carteObjectId );
  TransExecutionConfiguration executionConfiguration = transConfiguration.getTransExecutionConfiguration();
  servletLoggingObject.setLogLevel( executionConfiguration.getLogLevel() );

  if ( singleThreaded ) {
    // Set the type to single threaded in case the user forgot...
    //
    transMeta.setTransformationType( TransformationType.SingleThreaded );

    // Disable thread priority management as it will slow things down needlessly.
    // The single threaded engine doesn't use threads and doesn't need row locking.
    //
    transMeta.setUsingThreadPriorityManagment( false );
  } else {
    transMeta.setTransformationType( TransformationType.Normal );
  }

  return new Trans( transMeta, servletLoggingObject );
}
 
Example 6
Source File: MappingIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void testMapping_WhenSharingPreviousStepWithAnother() throws Exception {
  KettleEnvironment.init();

  TransMeta transMeta = new TransMeta( "src/it/resources/org/pentaho/di/trans/steps/mapping/pdi-13435/PDI-13435-main.ktr" );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );

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

  assertEquals( 0, trans.getErrors() );
}
 
Example 7
Source File: MetaDataInjectionIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void metaInjectWithFieldSplitter() throws KettleException {
  TransMeta transMeta = new TransMeta( "src/it/resources/org/pentaho/di/trans/steps/metainject/fieldsplit/PDI-15679-inject.ktr" );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );

  Trans trans = new Trans( transMeta );
  trans.setLogLevel( LogLevel.ERROR );

  trans.prepareExecution( null );
  trans.startThreads();
  trans.waitUntilFinished();

  Assert.assertEquals( 0, trans.getErrors() );
}
 
Example 8
Source File: TextFileOutputSplittingIT.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  transMeta = new TransMeta( "src/it/resources/org/pentaho/di/trans/steps/textfileoutput/pdi-12847.ktr" );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );
}
 
Example 9
Source File: DenormaliserMetaInjectionIT.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  transMeta = new TransMeta( "src/it/resources/org/pentaho/di/trans/steps/denormaliser/pdi-11947.ktr" );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );
  trans = new Trans( transMeta );
}
 
Example 10
Source File: MetaInjectTemplateInFSAndRepoSpecMethodIT.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  transMeta = new TransMeta( "src/it/resources/org/pentaho/di/trans/steps/metainject/pdi-16420.ktr" );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );
  trans = new Trans( transMeta );
}
 
Example 11
Source File: NormaliserMetaInjectionIT.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private static Trans createTransformationFromFile( String fileName ) throws KettleXMLException,
  KettleMissingPluginsException {
  TransMeta transMeta = new TransMeta( fileName );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );
  return new Trans( transMeta );
}