Java Code Examples for org.pentaho.di.trans.step.StepMeta#setStepID()

The following examples show how to use org.pentaho.di.trans.step.StepMeta#setStepID() . 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: RunBeamTransExecutionPoint.java    From kettle-beam with Apache License 2.0 6 votes vote down vote up
private TransMeta copyCleanTransMeta( TransMeta transMeta, Repository repository, IMetaStore metaStore, VariableSpace space ) throws KettleException {

    try {
      String transMetaXml = transMeta.getXML();
      TransMeta copy = new TransMeta();
      copy.setMetaStore( metaStore );
      copy.loadXML( XMLHandler.loadXMLString( transMetaXml, TransMeta.XML_TAG ), null, metaStore, repository, true, space, null );

      for ( StepMeta stepMeta : copy.getSteps() ) {
        stepMeta.setCopies( 1 );

        DummyTransMeta dummyTransMeta = new DummyTransMeta();

        // Replace all stepMeta with a Dummy with the same name
        //
        stepMeta.setStepID( "Dummy" );
        stepMeta.setStepMetaInterface( dummyTransMeta );
      }

      return copy;

    } catch ( Exception e ) {
      throw new KettleException( "Error copying/cleaning transformation metadata", e );
    }
  }
 
Example 2
Source File: BaseStreamStepMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetResourceDependencies() {
  String stepId = "KafkConsumerInput";
  String path = "/home/bgroves/fake.ktr";

  StepMeta stepMeta = new StepMeta();
  stepMeta.setStepID( stepId );
  StuffStreamMeta inputMeta = new StuffStreamMeta();
  List<ResourceReference> resourceDependencies = inputMeta.getResourceDependencies( new TransMeta(), stepMeta );
  assertEquals( 0, resourceDependencies.get( 0 ).getEntries().size() );

  inputMeta.setTransformationPath( path );
  resourceDependencies = inputMeta.getResourceDependencies( new TransMeta(), stepMeta );
  assertEquals( 1, resourceDependencies.get( 0 ).getEntries().size() );
  assertEquals( path, resourceDependencies.get( 0 ).getEntries().get( 0 ).getResource() );
  assertEquals( ResourceEntry.ResourceType.ACTIONFILE,
    resourceDependencies.get( 0 ).getEntries().get( 0 ).getResourcetype() );
  testRoundTrip( inputMeta );
}
 
Example 3
Source File: TransMetaModifier.java    From pentaho-pdi-dataset with Apache License 2.0 5 votes vote down vote up
private void handleInputDataSet( LogChannelInterface log, TransUnitTestSetLocation inputLocation, TransUnitTest unitTest, TransMeta transMeta, StepMeta stepMeta,
                                 FactoriesHierarchy factoriesHierarchy ) throws KettleException {

  String inputSetName = inputLocation.getDataSetName();

  if ( log.isDetailed() ) {
    log.logDetailed( "Replacing step '" + stepMeta.getName() + "' with an Injector for dataset '" + inputSetName + "'" );
  }

  DataSet dataSet;
  try {
    dataSet = factoriesHierarchy.getSetFactory().loadElement( inputSetName );
  } catch ( MetaStoreException e ) {
    throw new KettleException( "Unable to load data set '" + inputSetName + "'" );
  }

  // OK, this step needs to be replaced by an Injector step...
  // Which fields do we need to use?
  //
  final RowMetaInterface stepFields = DataSetConst.getStepOutputFields( log, dataSet, inputLocation );

  if ( log.isDetailed() ) {
    log.logDetailed( "Input Data Set '" + inputSetName + "' Injector fields : '" + stepFields.toString() );
  }

  InjectorMeta injectorMeta = new InjectorMeta();
  injectorMeta.allocate( stepFields.size() );
  for ( int x = 0; x < stepFields.size(); x++ ) {
    injectorMeta.getFieldname()[ x ] = stepFields.getValueMeta( x ).getName();
    injectorMeta.getType()[ x ] = stepFields.getValueMeta( x ).getType();
    injectorMeta.getLength()[ x ] = stepFields.getValueMeta( x ).getLength();
    injectorMeta.getPrecision()[ x ] = stepFields.getValueMeta( x ).getPrecision();

    // Only the step metadata, type...
    stepMeta.setStepMetaInterface( injectorMeta );
    stepMeta.setStepID( PluginRegistry.getInstance().getPluginId( StepPluginType.class, injectorMeta ) );
  }
}
 
Example 4
Source File: BeamTransMetaUtil.java    From kettle-beam with Apache License 2.0 4 votes vote down vote up
public static final TransMeta generateBeamInputOutputTransMeta( String transname, String inputStepname, String outputStepname, IMetaStore metaStore ) throws Exception {

    MetaStoreFactory<FileDefinition> factory = new MetaStoreFactory<>( FileDefinition.class, metaStore, PentahoDefaults.NAMESPACE );
    FileDefinition customerFileDefinition = createCustomersInputFileDefinition();
    factory.saveElement( customerFileDefinition );

    TransMeta transMeta = new TransMeta(  );
    transMeta.setName( transname );
    transMeta.setMetaStore( metaStore );

    // Add the io step
    //
    BeamInputMeta beamInputMeta = new BeamInputMeta();
    beamInputMeta.setInputLocation( "/tmp/customers/io/customers-100.txt" );
    beamInputMeta.setFileDescriptionName( customerFileDefinition.getName() );
    StepMeta beamInputStepMeta = new StepMeta(inputStepname, beamInputMeta);
    beamInputStepMeta.setStepID( "BeamInput" );
    transMeta.addStep( beamInputStepMeta );


    // Add a dummy in between to get started...
    //
    DummyTransMeta dummyTransMeta = new DummyTransMeta();
    StepMeta dummyStepMeta = new StepMeta("Dummy", dummyTransMeta);
    transMeta.addStep( dummyStepMeta );
    transMeta.addTransHop(new TransHopMeta( beamInputStepMeta, dummyStepMeta ) );


    // Add the output step
    //
    BeamOutputMeta beamOutputMeta = new BeamOutputMeta();
    beamOutputMeta.setOutputLocation( "/tmp/customers/output/" );
    beamOutputMeta.setFileDescriptionName( null );
    beamOutputMeta.setFilePrefix( "customers" );
    beamOutputMeta.setFileSuffix( ".csv" );
    beamOutputMeta.setWindowed( false ); // Not yet supported
    StepMeta beamOutputStepMeta = new StepMeta(outputStepname, beamOutputMeta);
    beamOutputStepMeta.setStepID( "BeamOutput" );
    transMeta.addStep( beamOutputStepMeta );
    transMeta.addTransHop(new TransHopMeta( dummyStepMeta, beamOutputStepMeta ) );

    return transMeta;
  }
 
Example 5
Source File: BeamTransMetaUtil.java    From kettle-beam with Apache License 2.0 4 votes vote down vote up
public static final TransMeta generateBeamGroupByTransMeta( String transname, String inputStepname, String outputStepname, IMetaStore metaStore ) throws Exception {

    MetaStoreFactory<FileDefinition> factory = new MetaStoreFactory<>( FileDefinition.class, metaStore, PentahoDefaults.NAMESPACE );
    FileDefinition customerFileDefinition = createCustomersInputFileDefinition();
    factory.saveElement( customerFileDefinition );

    TransMeta transMeta = new TransMeta(  );
    transMeta.setName( transname );
    transMeta.setMetaStore( metaStore );

    // Add the io step
    //
    BeamInputMeta beamInputMeta = new BeamInputMeta();
    beamInputMeta.setInputLocation( "/tmp/customers/io/customers-100.txt" );
    beamInputMeta.setFileDescriptionName( customerFileDefinition.getName() );
    StepMeta beamInputStepMeta = new StepMeta(inputStepname, beamInputMeta);
    beamInputStepMeta.setStepID( BeamConst.STRING_BEAM_INPUT_PLUGIN_ID );
    transMeta.addStep( beamInputStepMeta );


    // Add a dummy in between to get started...
    //
    MemoryGroupByMeta memoryGroupByMeta = new MemoryGroupByMeta();
    memoryGroupByMeta.allocate(1, 2 );
    memoryGroupByMeta.getGroupField()[0] = "state";
    // count(id)
    memoryGroupByMeta.getAggregateField()[0] = "nrIds";
    memoryGroupByMeta.getSubjectField()[0] = "id";
    memoryGroupByMeta.getAggregateType()[0] = MemoryGroupByMeta.TYPE_GROUP_COUNT_ALL;
    // sum(id)
    memoryGroupByMeta.getAggregateField()[1] = "sumIds";
    memoryGroupByMeta.getSubjectField()[1] = "id";
    memoryGroupByMeta.getAggregateType()[1] = MemoryGroupByMeta.TYPE_GROUP_SUM;

    StepMeta memoryGroupByStepMeta = new StepMeta("Group By", memoryGroupByMeta);
    transMeta.addStep( memoryGroupByStepMeta );
    transMeta.addTransHop(new TransHopMeta( beamInputStepMeta, memoryGroupByStepMeta ) );

    // Add the output step
    //
    BeamOutputMeta beamOutputMeta = new BeamOutputMeta();
    beamOutputMeta.setOutputLocation( "/tmp/customers/output/" );
    beamOutputMeta.setFileDescriptionName( null );
    beamOutputMeta.setFilePrefix( "grouped" );
    beamOutputMeta.setFileSuffix( ".csv" );
    beamOutputMeta.setWindowed( false ); // Not yet supported
    StepMeta beamOutputStepMeta = new StepMeta(outputStepname, beamOutputMeta);
    beamOutputStepMeta.setStepID( "BeamOutput" );
    transMeta.addStep( beamOutputStepMeta );
    transMeta.addTransHop(new TransHopMeta( memoryGroupByStepMeta, beamOutputStepMeta ) );

    return transMeta;
  }
 
Example 6
Source File: BeamTransMetaUtil.java    From kettle-beam with Apache License 2.0 4 votes vote down vote up
public static final TransMeta generateFilterRowsTransMeta( String transname, String inputStepname, String outputStepname, IMetaStore metaStore ) throws Exception {

    MetaStoreFactory<FileDefinition> factory = new MetaStoreFactory<>( FileDefinition.class, metaStore, PentahoDefaults.NAMESPACE );
    FileDefinition customerFileDefinition = createCustomersInputFileDefinition();
    factory.saveElement( customerFileDefinition );

    TransMeta transMeta = new TransMeta(  );
    transMeta.setName( transname );
    transMeta.setMetaStore( metaStore );

    // Add the io step
    //
    BeamInputMeta beamInputMeta = new BeamInputMeta();
    beamInputMeta.setInputLocation( "/tmp/customers/io/customers-100.txt" );
    beamInputMeta.setFileDescriptionName( customerFileDefinition.getName() );
    StepMeta beamInputStepMeta = new StepMeta(inputStepname, beamInputMeta);
    beamInputStepMeta.setStepID( BeamConst.STRING_BEAM_INPUT_PLUGIN_ID );
    transMeta.addStep( beamInputStepMeta );


    // Add 2 add constants steps A and B
    //
    ConstantMeta constantA = new ConstantMeta();
    constantA.allocate( 1 );
    constantA.getFieldName()[0]="label";
    constantA.getFieldType()[0]="String";
    constantA.getValue()[0]="< 'k'";
    StepMeta constantAMeta = new StepMeta("A", constantA);
    transMeta.addStep(constantAMeta);

    ConstantMeta constantB = new ConstantMeta();
    constantB.allocate( 1 );
    constantB.getFieldName()[0]="label";
    constantB.getFieldType()[0]="String";
    constantB.getValue()[0]=">= 'k'";
    StepMeta constantBMeta = new StepMeta("B", constantB);
    transMeta.addStep(constantBMeta);


    // Add Filter rows step looking for customers name > "k"
    // Send rows to A (true) and B (false)
    //
    FilterRowsMeta filter = new FilterRowsMeta();
    filter.getCondition().setLeftValuename( "name" );
    filter.getCondition().setFunction( Condition.FUNC_SMALLER );
    filter.getCondition().setRightExact( new ValueMetaAndData( "value", "k" ) );
    filter.setTrueStepname( "A" );
    filter.setFalseStepname( "B" );
    StepMeta filterMeta = new StepMeta("Filter", filter);
    transMeta.addStep( filterMeta );
    transMeta.addTransHop( new TransHopMeta( beamInputStepMeta, filterMeta ) );
    transMeta.addTransHop( new TransHopMeta( filterMeta, constantAMeta ) );
    transMeta.addTransHop( new TransHopMeta( filterMeta, constantBMeta ) );

    // Add a dummy behind it all to flatten/merge the data again...
    //
    DummyTransMeta dummyTransMeta = new DummyTransMeta();
    StepMeta dummyStepMeta = new StepMeta("Flatten", dummyTransMeta);
    transMeta.addStep( dummyStepMeta );
    transMeta.addTransHop(new TransHopMeta( constantAMeta, dummyStepMeta ) );
    transMeta.addTransHop(new TransHopMeta( constantBMeta, dummyStepMeta ) );

    // Add the output step
    //
    BeamOutputMeta beamOutputMeta = new BeamOutputMeta();
    beamOutputMeta.setOutputLocation( "/tmp/customers/output/" );
    beamOutputMeta.setFileDescriptionName( null );
    beamOutputMeta.setFilePrefix( "filter-test" );
    beamOutputMeta.setFileSuffix( ".csv" );
    beamOutputMeta.setWindowed( false ); // Not yet supported
    StepMeta beamOutputStepMeta = new StepMeta(outputStepname, beamOutputMeta);
    beamOutputStepMeta.setStepID( "BeamOutput" );
    transMeta.addStep( beamOutputStepMeta );
    transMeta.addTransHop(new TransHopMeta( dummyStepMeta, beamOutputStepMeta ) );

    return transMeta;
  }
 
Example 7
Source File: BeamTransMetaUtil.java    From kettle-beam with Apache License 2.0 4 votes vote down vote up
public static final TransMeta generateStreamLookupTransMeta( String transname, String inputStepname, String outputStepname, IMetaStore metaStore ) throws Exception {

    MetaStoreFactory<FileDefinition> factory = new MetaStoreFactory<>( FileDefinition.class, metaStore, PentahoDefaults.NAMESPACE );
    FileDefinition customerFileDefinition = createCustomersInputFileDefinition();
    factory.saveElement( customerFileDefinition );

    TransMeta transMeta = new TransMeta(  );
    transMeta.setName( transname );
    transMeta.setMetaStore( metaStore );

    // Add the main io step
    //
    BeamInputMeta beamInputMeta = new BeamInputMeta();
    beamInputMeta.setInputLocation( "/tmp/customers/io/customers-100.txt" );
    beamInputMeta.setFileDescriptionName( customerFileDefinition.getName() );
    StepMeta beamInputStepMeta = new StepMeta(inputStepname, beamInputMeta);
    beamInputStepMeta.setStepID( BeamConst.STRING_BEAM_INPUT_PLUGIN_ID );
    transMeta.addStep( beamInputStepMeta );

    StepMeta lookupBeamInputStepMeta = beamInputStepMeta;

    // Add a Memory Group By step which will
    MemoryGroupByMeta memoryGroupByMeta = new MemoryGroupByMeta();
    memoryGroupByMeta.allocate( 1, 1 );
    memoryGroupByMeta.getGroupField()[0] = "stateCode";
    memoryGroupByMeta.getAggregateType()[0] = MemoryGroupByMeta.TYPE_GROUP_COUNT_ALL;
    memoryGroupByMeta.getAggregateField()[0] = "rowsPerState";
    memoryGroupByMeta.getSubjectField()[0] = "id";
    StepMeta memoryGroupByStepMeta = new StepMeta("rowsPerState", memoryGroupByMeta);
    transMeta.addStep( memoryGroupByStepMeta );
    transMeta.addTransHop( new TransHopMeta( lookupBeamInputStepMeta, memoryGroupByStepMeta ) );

    // Add a Stream Lookup step ...
    //
    StreamLookupMeta streamLookupMeta = new StreamLookupMeta();
    streamLookupMeta.allocate( 1, 1 );
    streamLookupMeta.getKeystream()[0] = "stateCode";
    streamLookupMeta.getKeylookup()[0] = "stateCode";
    streamLookupMeta.getValue()[0] = "rowsPerState";
    streamLookupMeta.getValueName()[0] = "nrPerState";
    streamLookupMeta.getValueDefault()[0] = null;
    streamLookupMeta.getValueDefaultType()[0] = ValueMetaInterface.TYPE_INTEGER;
    streamLookupMeta.setMemoryPreservationActive( false );
    streamLookupMeta.getStepIOMeta().getInfoStreams().get(0).setStepMeta( memoryGroupByStepMeta ); // Read from Mem.GroupBy
    StepMeta streamLookupStepMeta = new StepMeta("Stream Lookup", streamLookupMeta);
    transMeta.addStep(streamLookupStepMeta);
    transMeta.addTransHop( new TransHopMeta( beamInputStepMeta, streamLookupStepMeta ) ); // Main io
    transMeta.addTransHop( new TransHopMeta( memoryGroupByStepMeta, streamLookupStepMeta ) ); // info stream

    // Add the output step to write results
    //
    BeamOutputMeta beamOutputMeta = new BeamOutputMeta();
    beamOutputMeta.setOutputLocation( "/tmp/customers/output/" );
    beamOutputMeta.setFileDescriptionName( null );
    beamOutputMeta.setFilePrefix( "stream-lookup" );
    beamOutputMeta.setFileSuffix( ".csv" );
    beamOutputMeta.setWindowed( false ); // Not yet supported
    StepMeta beamOutputStepMeta = new StepMeta(outputStepname, beamOutputMeta);
    beamOutputStepMeta.setStepID( "BeamOutput" );
    transMeta.addStep( beamOutputStepMeta );
    transMeta.addTransHop(new TransHopMeta( streamLookupStepMeta, beamOutputStepMeta ) );

    return transMeta;
  }
 
Example 8
Source File: BeamTransMetaUtil.java    From kettle-beam with Apache License 2.0 4 votes vote down vote up
public static final TransMeta generateMergeJoinTransMeta( String transname, String inputStepname, String outputStepname, IMetaStore metaStore ) throws Exception {

    MetaStoreFactory<FileDefinition> factory = new MetaStoreFactory<>( FileDefinition.class, metaStore, PentahoDefaults.NAMESPACE );
    FileDefinition customerFileDefinition = createCustomersInputFileDefinition();
    factory.saveElement( customerFileDefinition );
    FileDefinition statePopulationFileDefinition = createStatePopulationInputFileDefinition();
    factory.saveElement( statePopulationFileDefinition );

    TransMeta transMeta = new TransMeta(  );
    transMeta.setName( transname );
    transMeta.setMetaStore( metaStore );

    // Add the left io step
    //
    BeamInputMeta leftInputMeta = new BeamInputMeta();
    leftInputMeta.setInputLocation( "/tmp/customers/io/customers-100.txt" );
    leftInputMeta.setFileDescriptionName( customerFileDefinition.getName() );
    StepMeta leftInputStepMeta = new StepMeta(inputStepname+" Left", leftInputMeta);
    leftInputStepMeta.setStepID( BeamConst.STRING_BEAM_INPUT_PLUGIN_ID );
    transMeta.addStep( leftInputStepMeta );

    BeamInputMeta rightInputMeta = new BeamInputMeta();
    rightInputMeta.setInputLocation( "/tmp/customers/io/state-data.txt" );
    rightInputMeta.setFileDescriptionName( statePopulationFileDefinition.getName() );
    StepMeta rightInputStepMeta = new StepMeta(inputStepname+" Right", rightInputMeta);
    rightInputStepMeta.setStepID( BeamConst.STRING_BEAM_INPUT_PLUGIN_ID );
    transMeta.addStep( rightInputStepMeta );


    // Add a Merge Join step
    //
    MergeJoinMeta mergeJoin = new MergeJoinMeta();
    mergeJoin.allocate( 1, 1 );
    mergeJoin.getKeyFields1()[0] = "state";
    mergeJoin.getKeyFields2()[0] = "state";
    mergeJoin.setJoinType(MergeJoinMeta.join_types[3] ); // FULL OUTER
    mergeJoin.getStepIOMeta().getInfoStreams().get(0).setStepMeta( leftInputStepMeta );
    mergeJoin.getStepIOMeta().getInfoStreams().get(1).setStepMeta( rightInputStepMeta );
    StepMeta mergeJoinStepMeta = new StepMeta("Merge Join", mergeJoin);
    transMeta.addStep( mergeJoinStepMeta );
    transMeta.addTransHop( new TransHopMeta( leftInputStepMeta, mergeJoinStepMeta ) );
    transMeta.addTransHop( new TransHopMeta( rightInputStepMeta, mergeJoinStepMeta ) );

    // Add the output step to write results
    //
    BeamOutputMeta beamOutputMeta = new BeamOutputMeta();
    beamOutputMeta.setOutputLocation( "/tmp/customers/output/" );
    beamOutputMeta.setFileDescriptionName( null );
    beamOutputMeta.setFilePrefix( "merge-join" );
    beamOutputMeta.setFileSuffix( ".csv" );
    beamOutputMeta.setWindowed( false ); // Not yet supported
    StepMeta beamOutputStepMeta = new StepMeta(outputStepname, beamOutputMeta);
    beamOutputStepMeta.setStepID( "BeamOutput" );
    transMeta.addStep( beamOutputStepMeta );
    transMeta.addTransHop(new TransHopMeta( mergeJoinStepMeta, beamOutputStepMeta ) );

    return transMeta;
  }
 
Example 9
Source File: TransMetaModifier.java    From pentaho-pdi-dataset with Apache License 2.0 4 votes vote down vote up
private void replaceStepWithDummy( LogChannelInterface log, StepMeta stepMeta ) {
  DummyTransMeta dummyTransMeta = new DummyTransMeta();
  stepMeta.setStepMetaInterface( dummyTransMeta );
  stepMeta.setStepID( PluginRegistry.getInstance().getPluginId( StepPluginType.class, dummyTransMeta ) );
}
 
Example 10
Source File: KettleDatabaseRepositoryStepDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new step by loading the metadata from the specified repository.
 *
 * @param rep
 * @param stepId
 * @param databases
 * @param counters
 * @param partitionSchemas
 * @throws KettleException
 */
public StepMeta loadStepMeta( ObjectId stepId, List<DatabaseMeta> databases,
  List<PartitionSchema> partitionSchemas ) throws KettleException {
  StepMeta stepMeta = new StepMeta();
  PluginRegistry registry = PluginRegistry.getInstance();

  try {
    RowMetaAndData r = getStep( stepId );
    if ( r != null ) {
      stepMeta.setObjectId( stepId );

      stepMeta.setName( r.getString( KettleDatabaseRepository.FIELD_STEP_NAME, null ) );
      stepMeta.setDescription( r.getString( KettleDatabaseRepository.FIELD_STEP_DESCRIPTION, null ) );

      long id_step_type = r.getInteger( KettleDatabaseRepository.FIELD_STEP_ID_STEP_TYPE, -1L );
      RowMetaAndData steptyperow = getStepType( new LongObjectId( id_step_type ) );

      stepMeta.setStepID( steptyperow.getString( KettleDatabaseRepository.FIELD_STEP_TYPE_CODE, null ) );
      stepMeta.setDistributes( r.getBoolean( KettleDatabaseRepository.FIELD_STEP_DISTRIBUTE, true ) );
      int copies = (int) r.getInteger( KettleDatabaseRepository.FIELD_STEP_COPIES, 1 );
      String copiesString = r.getString( KettleDatabaseRepository.FIELD_STEP_COPIES_STRING, null );
      if ( !Utils.isEmpty( copiesString ) ) {
        stepMeta.setCopiesString( copiesString );
      } else {
        stepMeta.setCopies( copies );
      }

      int x = (int) r.getInteger( KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_X, 0 );
      int y = (int) r.getInteger( KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_Y, 0 );
      stepMeta.setLocation( new Point( x, y ) );
      stepMeta.setDraw( r.getBoolean( KettleDatabaseRepository.FIELD_STEP_GUI_DRAW, false ) );

      // Generate the appropriate class...
      PluginInterface sp = registry.findPluginWithId( StepPluginType.class, stepMeta.getStepID() );
      if ( sp == null ) {
        stepMeta.setStepMetaInterface( new MissingTrans( stepMeta.getName(), stepMeta.getStepID() ) );
      } else {
        stepMeta.setStepMetaInterface( (StepMetaInterface) registry.loadClass( sp ) );
      }
      if ( stepMeta.getStepMetaInterface() != null ) {
        // Read the step info from the repository!
        readRepCompatibleStepMeta(
          stepMeta.getStepMetaInterface(), repository, stepMeta.getObjectId(), databases );
        stepMeta.getStepMetaInterface().readRep(
          repository, repository.metaStore, stepMeta.getObjectId(), databases );
      }

      // Get the partitioning as well...
      //
      stepMeta.setStepPartitioningMeta( loadStepPartitioningMeta( stepMeta.getObjectId() ) );
      stepMeta.getStepPartitioningMeta().setPartitionSchemaAfterLoading( partitionSchemas );

      // Get the cluster schema name
      //
      stepMeta.setClusterSchemaName( repository.getStepAttributeString( stepId, "cluster_schema" ) );

      // Are we using a custom row distribution plugin?
      //
      String rowDistributionCode = repository.getStepAttributeString( stepId, 0, "row_distribution_code" );
      RowDistributionInterface rowDistribution =
        PluginRegistry.getInstance().loadClass(
          RowDistributionPluginType.class, rowDistributionCode, RowDistributionInterface.class );
      stepMeta.setRowDistribution( rowDistribution );

      // Load the attribute groups map
      //
      stepMeta.setAttributesMap( loadStepAttributesMap( stepId ) );

      // Done!
      //
      return stepMeta;
    } else {
      throw new KettleException( BaseMessages.getString(
        PKG, "StepMeta.Exception.StepInfoCouldNotBeFound", String.valueOf( stepId ) ) );
    }
  } catch ( KettleDatabaseException dbe ) {
    throw new KettleException( BaseMessages.getString( PKG, "StepMeta.Exception.StepCouldNotBeLoaded", String
      .valueOf( stepMeta.getObjectId() ) ), dbe );
  }
}
 
Example 11
Source File: TransMetaTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetCacheVersionWithIrrelevantParameters() throws Exception {
  TransMeta transMeta = new TransMeta( getClass().getResource( "one-step-trans.ktr" ).getPath() );
  int oldCacheVersion = transMeta.getCacheVersion();
  int currCacheVersion;

  transMeta.setSizeRowset( 1000 );
  currCacheVersion = transMeta.getCacheVersion();
  assertNotEquals( oldCacheVersion, currCacheVersion );

  oldCacheVersion = currCacheVersion;

  // scenarios that should not impact the cache version

  // transformation description
  transMeta.setDescription( "transformation description" );

  // transformation status
  transMeta.setTransstatus( 100 );

  // transformation log table
  transMeta.setTransLogTable( mock( TransLogTable.class ) );

  // transformation created user
  transMeta.setCreatedUser( "user" );

  // transformation modified user
  transMeta.setModifiedUser( "user" );

  // transformation created date
  transMeta.setCreatedDate( new Date() );

  // transformation modified date
  transMeta.setModifiedDate( new Date() );

  // transformation is key private flag
  transMeta.setPrivateKey( false );

  // transformation attributes
  Map<String, String> attributes = new HashMap<>();
  attributes.put( "key", "value" );
  transMeta.setAttributes( "group", attributes );

  // step description
  StepMeta stepMeta = transMeta.getStep( 0 );
  stepMeta.setDescription( "stepDescription" );

  // step position
  stepMeta.setLocation( 10, 20 );
  stepMeta.setLocation( new Point( 30, 40 ) );

  // step type id
  stepMeta.setStepID( "Dummy" );

  // step is distributed flag
  stepMeta.setDistributes( false );

  // step copies
  stepMeta.setCopies( 5 );

  // step partitioning meta
  stepMeta.setStepPartitioningMeta( mock( StepPartitioningMeta.class ) );

  // assert that nothing impacted the cache version
  assertEquals( oldCacheVersion, transMeta.getCacheVersion() );
}