org.pentaho.di.trans.step.StepMeta Java Examples

The following examples show how to use org.pentaho.di.trans.step.StepMeta. 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: MetaInjectTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testMetastoreIsSet() throws Exception {
  doReturn( new String[] { } ).when( transMeta ).getPrevStepNames( any( StepMeta.class ) );
  data.stepInjectionMetasMap = new HashMap<>();
  data.stepInjectionMap = new HashMap<>();

  data.transMeta = new TransMeta();

  meta.setNoExecution( false );
  doReturn( LogLevel.ERROR ).when( metaInject ).getLogLevel();
  // don't need to actually run anything to verify this. force it to "stopped"
  doReturn( true ).when( metaInject ).isStopped();
  doNothing().when( metaInject ).waitUntilFinished( any( Trans.class ) );
  // make sure the injected tranformation doesn't have a metastore first
  assertNull( data.transMeta.getMetaStore() );

  metaInject.processRow( meta, data );

  // now it should be set
  assertEquals( metaStore, data.transMeta.getMetaStore() );
}
 
Example #2
Source File: TransformClassBase.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings( "unchecked" )
public static void getFields( boolean clearResultFields, RowMetaInterface row, String originStepname,
  RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, List<?> fields ) throws KettleStepException {
  if ( clearResultFields ) {
    row.clear();
  }
  for ( FieldInfo fi : (List<FieldInfo>) fields ) {
    try {
      ValueMetaInterface v = ValueMetaFactory.createValueMeta( fi.name, fi.type );
      v.setLength( fi.length );
      v.setPrecision( fi.precision );
      v.setOrigin( originStepname );
      row.addValueMeta( v );
    } catch ( Exception e ) {
      throw new KettleStepException( e );
    }
  }
}
 
Example #3
Source File: GPLoadIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a transformation with a row generator step and hopped to a GPLoadStep with the passed name.
 * 
 * @param gpLoadStepname
 *          The name of the GPLoad step.
 * 
 * @throws KettleException
 */
public TransMeta createTransformationMeta( String gpLoadStepname ) throws Exception {

  // Create a new transformation...
  TransMeta transMeta = new TransMeta();
  transMeta.setName( "row generatortest" );

  // Add a database connection to the trans meta
  transMeta.addDatabase( new DatabaseMeta( GREENPLUM_DATABASE_CONNECTION ) );

  // get a reference to the plugin registry
  PluginRegistry registry = PluginRegistry.getInstance();
  if ( registry == null ) {
    throw new Exception( "Plugin registry is null.  Make sure that the Kettle environment was initialized." );
  }

  // create the GPLoad step
  GPLoadMeta gpLoadMeta = new GPLoadMeta();
  String dummyPid = registry.getPluginId( StepPluginType.class, gpLoadMeta );
  StepMeta gpLoadStepMeta = new StepMeta( dummyPid, gpLoadStepname, gpLoadMeta );
  transMeta.addStep( gpLoadStepMeta );

  return transMeta;
}
 
Example #4
Source File: TransPartitioningTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * 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() );
  }
}
 
Example #5
Source File: TransMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddStepWithChangeListenerInterface() {
  StepMeta stepMeta = mock( StepMeta.class );
  StepMetaChangeListenerInterfaceMock metaInterface = mock( StepMetaChangeListenerInterfaceMock.class );
  when( stepMeta.getStepMetaInterface() ).thenReturn( metaInterface );
  assertEquals( 0, transMeta.steps.size() );
  assertEquals( 0, transMeta.stepChangeListeners.size() );
  // should not throw exception if there are no steps in step meta
  transMeta.addStep( 0, stepMeta );
  assertEquals( 1, transMeta.steps.size() );
  assertEquals( 1, transMeta.stepChangeListeners.size() );

  transMeta.addStep( 0, stepMeta );
  assertEquals( 2, transMeta.steps.size() );
  assertEquals( 2, transMeta.stepChangeListeners.size() );
}
 
Example #6
Source File: MappingDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Enables or disables the mapping button. We can only enable it if the target steps allows a mapping to be made
 * against it.
 *
 * @param button         The button to disable or enable
 * @param input          input or output. If it's true, we keep the button enabled all the time.
 * @param sourceStepname The mapping output step
 * @param targetStepname The target step to verify
 * @throws KettleException
 */
private void enableMappingButton( final Button button, boolean input, String sourceStepname, String targetStepname ) throws KettleException {
  if ( input ) {
    return; // nothing to do
  }

  boolean enabled = false;

  if ( mappingTransMeta != null ) {
    StepMeta mappingInputStep = mappingTransMeta.findMappingInputStep( sourceStepname );
    if ( mappingInputStep != null ) {
      StepMeta mappingOutputStep = transMeta.findMappingOutputStep( targetStepname );
      RowMetaInterface requiredFields = mappingOutputStep.getStepMetaInterface().getRequiredFields( transMeta );
      if ( requiredFields != null && requiredFields.size() > 0 ) {
        enabled = true;
      }
    }
  }

  button.setEnabled( enabled );
}
 
Example #7
Source File: TransMetaConverterTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testResolveStepMetaResources() throws KettleException, MetaStoreException {
  Variables variables = new Variables();
  TransMeta transMeta = spy( new TransMeta() );
  transMeta.setParentVariableSpace( variables );

  doReturn( transMeta ).when( transMeta ).realClone( false );

  TestMetaResolvableResource testMetaResolvableResource = spy( new TestMetaResolvableResource() );
  TestMetaResolvableResource testMetaResolvableResourceTwo = spy( new TestMetaResolvableResource() );

  StepMeta testMeta = new StepMeta( "TestMeta", testMetaResolvableResource );
  StepMeta testMetaTwo = new StepMeta( "TestMeta2", testMetaResolvableResourceTwo );

  transMeta.addStep( testMeta );
  transMeta.addStep( testMetaTwo );
  transMeta.addTransHop( new TransHopMeta( testMeta, testMetaTwo ) );
  TransMetaConverter.convert( transMeta );

  verify( testMetaResolvableResource ).resolve();
  verify( testMetaResolvableResourceTwo ).resolve();
}
 
Example #8
Source File: ShowUnitTestMenuExtensionPoint.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
private void editLocation( TransUnitTestSetLocation location, Spoon spoon, TransMeta transMeta ) {
  try {
    FactoriesHierarchy hierarchy = new FactoriesHierarchy( spoon.getMetaStore(), spoon.getActiveDatabases() );

    Map<String, RowMetaInterface> stepFieldsMap = new HashMap<>();
    for ( StepMeta stepMeta : transMeta.getSteps() ) {
      stepFieldsMap.put( stepMeta.getName(), transMeta.getStepFields( stepMeta ) );
    }
    TransUnitTestSetLocationDialog dialog = new TransUnitTestSetLocationDialog( spoon.getShell(), location, hierarchy.getSetFactory().getElements(), stepFieldsMap );
    if ( dialog.open() ) {
      spoon.refreshGraph();
    }
  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error editing dataset location", e );
  }
}
 
Example #9
Source File: RestInputIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public StepMeta createRestInputStep( TransMeta transMeta, PluginRegistry registry ) throws Exception {
  String inputName = "rest input step";
  RestMeta meta = new RestMeta();

  String inputPid = registry.getPluginId( StepPluginType.class, meta );
  StepMeta inputStep = new StepMeta( inputPid, inputName, meta );
  transMeta.addStep( inputStep );

  meta.setDefault();
  meta.setUrl( tester.createSocketConnector( true ) + "/context/simple/join" );
  meta.setMethod( "POST" );
  meta.setMatrixParameterField( new String[] { "pageSize" } );
  meta.setMatrixParameterName( new String[] { "limit" } );

  meta.setParameterField( new String[] { "name" } );
  meta.setParameterName( new String[] { "name" } );

  meta.setApplicationType( RestMeta.APPLICATION_TYPE_TEXT_PLAIN );
  meta.setFieldName( "result" );

  return inputStep;
}
 
Example #10
Source File: DatabaseLookupUTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testIncrementLinesClusteredNotRunningClustered() {

  DatabaseLookup dbLookup = mock( DatabaseLookup.class );
  StepMeta stepMeta = mock( StepMeta.class );
  Trans trans = mock( Trans.class );

  doCallRealMethod().when( dbLookup ).incrementLines();
  doReturn( stepMeta ).when( dbLookup ).getStepMeta();
  doReturn( trans ).when( dbLookup ).getTrans();
  doReturn( true ).when( stepMeta ).isClustered();
  doReturn( false ).when( trans ).isExecutingClustered();

  dbLookup.incrementLines();

  verify( dbLookup, times( 1 ) ).incrementLinesInput();
}
 
Example #11
Source File: KafkaConsumerTest.java    From pentaho-kafka-consumer with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    data = new KafkaConsumerData();
    meta = new KafkaConsumerMeta();
    meta.setKafkaProperties(getDefaultKafkaProperties());
    meta.setLimit(STEP_LIMIT);

    stepMeta = new StepMeta("KafkaConsumer", meta);
    transMeta = new TransMeta();
    transMeta.addStep(stepMeta);
    trans = new Trans(transMeta);

    PowerMockito.mockStatic(Consumer.class);

    when(Consumer.createJavaConsumerConnector(any(ConsumerConfig.class))).thenReturn(zookeeperConsumerConnector);
    when(zookeeperConsumerConnector.createMessageStreams(anyMapOf(String.class, Integer.class))).thenReturn(streamsMap);
    when(streamsMap.get(anyObject())).thenReturn(stream);
    when(stream.get(anyInt())).thenReturn(kafkaStream);
    when(kafkaStream.iterator()).thenReturn(streamIterator);
    when(streamIterator.next()).thenReturn(generateKafkaMessage());
}
 
Example #12
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 );
          }
        } );
      }
    }
  }
 
Example #13
Source File: SingleThreaderMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ) {
  List<ResourceReference> references = new ArrayList<ResourceReference>( 5 );
  String realFilename = transMeta.environmentSubstitute( fileName );
  String realTransname = transMeta.environmentSubstitute( transName );
  ResourceReference reference = new ResourceReference( stepInfo );
  references.add( reference );

  if ( !Utils.isEmpty( realFilename ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realFilename, ResourceType.ACTIONFILE ) );
  } else if ( !Utils.isEmpty( realTransname ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realTransname, ResourceType.ACTIONFILE ) );
    references.add( reference );
  }
  return references;
}
 
Example #14
Source File: SparkTuningStepHandler.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings( "squid:S1181" )
public void openSparkTuning() {
  TransGraph transGraph = Spoon.getInstance().getActiveTransGraph();
  StepMeta stepMeta = transGraph.getCurrentStep();
  String title = BaseMessages.getString( PKG, "TransGraph.Dialog.SparkTuning.Title" )
    + " - " + stepMeta.getName();

  List<String> tuningProperties = SparkTunableProperties.getProperties( stepMeta.getStepID() );

  PropertiesComboDialog dialog = new PropertiesComboDialog(
    transGraph.getParent().getShell(),
    transGraph.getTransMeta(),
    stepMeta.getAttributes( SPARK_TUNING_PROPERTIES ),
    title,
    Const.getDocUrl( BaseMessages.getString( PKG, "SparkTuning.Help.Url" ) ),
    BaseMessages.getString( PKG, "SparkTuning.Help.Title" ),
    BaseMessages.getString( PKG, "SparkTuning.Help.Header" )
  );
  dialog.setComboOptions( tuningProperties );
  try {
    Map<String, String> properties = dialog.open();

    // null means the cancel button was clicked otherwise ok was clicked
    if ( null != properties ) {
      stepMeta.setAttributes( SPARK_TUNING_PROPERTIES, properties );
      stepMeta.setChanged();
      transGraph.getSpoon().setShellText();
    }
  } catch ( Throwable e ) {
    new ErrorDialog(
      Spoon.getInstance().getShell(), BaseMessages.getString( PKG, "SparkTuning.UnexpectedError" ), BaseMessages
      .getString( PKG, "SparkTuning.UnexpectedError" ), e );
  }
}
 
Example #15
Source File: BeamInputStepHandler.java    From kettle-beam with Apache License 2.0 5 votes vote down vote up
@Override public void handleStep( LogChannelInterface log, StepMeta stepMeta, Map<String, PCollection<KettleRow>> stepCollectionMap,
                                  Pipeline pipeline, RowMetaInterface rowMeta, List<StepMeta> previousSteps,
                                  PCollection<KettleRow> input ) throws KettleException {

  // Input handling
  //
  BeamInputMeta beamInputMeta = (BeamInputMeta) stepMeta.getStepMetaInterface();
  FileDefinition inputFileDefinition = beamInputMeta.loadFileDefinition( metaStore );
  RowMetaInterface fileRowMeta = inputFileDefinition.getRowMeta();

  // Apply the PBegin to KettleRow transform:
  //
  if ( inputFileDefinition == null ) {
    throw new KettleException( "We couldn't find or load the Beam Input step file definition" );
  }
  String fileInputLocation = transMeta.environmentSubstitute( beamInputMeta.getInputLocation() );

  BeamInputTransform beamInputTransform = new BeamInputTransform(
    stepMeta.getName(),
    stepMeta.getName(),
    fileInputLocation,
    transMeta.environmentSubstitute( inputFileDefinition.getSeparator() ),
    JsonRowMeta.toJson( fileRowMeta ),
    stepPluginClasses,
    xpPluginClasses
  );
  PCollection<KettleRow> afterInput = pipeline.apply( beamInputTransform );
  stepCollectionMap.put( stepMeta.getName(), afterInput );
  log.logBasic( "Handled step (INPUT) : " + stepMeta.getName() );

}
 
Example #16
Source File: TransGraph.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * See if location (x,y) is on a line between two steps: the hop!
 *
 * @param x
 * @param y
 * @param exclude the step to exclude from the hops (from or to location). Specify null if no step is to be excluded.
 * @return the transformation hop on the specified location, otherwise: null
 */
private TransHopMeta findHop( int x, int y, StepMeta exclude ) {
  int i;
  TransHopMeta online = null;
  for ( i = 0; i < transMeta.nrTransHops(); i++ ) {
    TransHopMeta hi = transMeta.getTransHop( i );
    StepMeta fs = hi.getFromStep();
    StepMeta ts = hi.getToStep();

    if ( fs == null || ts == null ) {
      return null;
    }

    // If either the "from" or "to" step is excluded, skip this hop.
    //
    if ( exclude != null && ( exclude.equals( fs ) || exclude.equals( ts ) ) ) {
      continue;
    }

    int[] line = getLine( fs, ts );

    if ( pointOnLine( x, y, line ) ) {
      online = hi;
    }
  }
  return online;
}
 
Example #17
Source File: AppendMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public void searchInfoAndTargetSteps( List<StepMeta> steps ) {
  StepIOMetaInterface ioMeta = getStepIOMeta();
  List<StreamInterface> infoStreams = ioMeta.getInfoStreams();
  for ( StreamInterface stream : infoStreams ) {
    stream.setStepMeta( StepMeta.findStep( steps, (String) stream.getSubject() ) );
  }
}
 
Example #18
Source File: SortedMergeMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  // Set the sorted properties: ascending/descending
  for ( int i = 0; i < fieldName.length; i++ ) {
    int idx = inputRowMeta.indexOfValue( fieldName[i] );
    if ( idx >= 0 ) {
      ValueMetaInterface valueMeta = inputRowMeta.getValueMeta( idx );
      valueMeta.setSortedDescending( !ascending[i] );

      // TODO: add case insensivity
    }
  }

}
 
Example #19
Source File: TransGraph.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the last active transformation in the running job to the opened transMeta
 *
 * @param transGraph
 * @param stepMeta
 */
private void attachActiveTrans( TransGraph transGraph, StepMeta stepMeta ) {
  if ( trans != null && transGraph != null ) {
    Trans subTransformation = trans.getActiveSubTransformation( stepMeta.getName() );
    transGraph.setTrans( subTransformation );
    if ( !transGraph.isExecutionResultsPaneVisible() ) {
      transGraph.showExecutionResults();
    }
    transGraph.setControlStates();
  }
}
 
Example #20
Source File: TransPartitioningTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * one 'step running in 2 copies' to 'step running in 2 copies'
 */
private void prepareStepMetas_x2_x2() {
  StepMeta dummy1 = new StepMeta( ONE, null );
  StepMeta dummy2 = new StepMeta( TWO, null );
  dummy1.setCopies( 2 );
  dummy2.setCopies( 2 );
  chain.add( dummy1 );
  chain.add( dummy2 );

  for ( StepMeta item : chain ) {
    item.setStepMetaInterface( new DummyTransMeta() );
  }
}
 
Example #21
Source File: CiviInputMeta.java    From civicrm-data-integration with GNU General Public License v3.0 5 votes vote down vote up
public void getFields(RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space) {
    super.getFields(r, origin, info, nextStep, space);

    if (civiCrmResultField != null && !civiCrmResultField.equals("")) {
        ValueMetaInterface v = new ValueMeta(civiCrmResultField, ValueMetaInterface.TYPE_STRING);
        v.setOrigin(origin);
        r.addValueMeta(v);
    }
}
 
Example #22
Source File: MetricsLogTable.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void loadXML( Node node, List<DatabaseMeta> databases, List<StepMeta> steps ) {
  connectionName = XMLHandler.getTagValue( node, "connection" );
  schemaName = XMLHandler.getTagValue( node, "schema" );
  tableName = XMLHandler.getTagValue( node, "table" );
  timeoutInDays = XMLHandler.getTagValue( node, "timeout_days" );

  super.loadFieldsXML( node );
}
 
Example #23
Source File: OlapInputMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
  RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  // TODO: perform tests to see if connection is valid
  // CheckResult cr;
  // cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Please select or create a connection to use",
  // stepMeta);
  // remarks.add(cr);
}
 
Example #24
Source File: MappingIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a {@link org.pentaho.di.trans.steps.rowgenerator.RowGenerator} Step 
 * with a single String field.
 *
 * @param registry
 *          Plugin Registry.
 * @param stepName
 *          Name to use for step
 * @return {@link StepMeta} for a Row Generator step.
 */
private StepMeta buildRowGeneratorStep( PluginRegistry registry, String stepName ) {
  RowGeneratorMeta rm = new RowGeneratorMeta();

  // Set the information of the row generator.
  String rowGeneratorPid = registry.getPluginId( StepPluginType.class, rm );
  StepMeta rowGeneratorStep = new StepMeta( rowGeneratorPid, stepName, rm );

  String[] fieldName = { "string" };
  String[] type = { "String" };
  String[] value = { "string_value" };
  String[] fieldFormat = { "" };
  String[] group = { "" };
  String[] decimal = { "" };
  String[] currency = { "", };
  int[] intDummies = { -1, -1, -1 };
  boolean[] setEmptystring = { false, false, false };

  rm.setDefault();
  rm.setFieldName( fieldName );
  rm.setFieldType( type );
  rm.setValue( value );
  rm.setFieldLength( intDummies );
  rm.setFieldPrecision( intDummies );
  rm.setRowLimit( "1" );
  rm.setFieldFormat( fieldFormat );
  rm.setGroup( group );
  rm.setDecimal( decimal );
  rm.setCurrency( currency );
  rm.setEmptyString( setEmptystring );

  return rowGeneratorStep;
}
 
Example #25
Source File: FilterRowsMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private Optional<CheckResult> checkTarget( StepMeta stepMeta, String target, String targetStepName,
                                           String[] output ) {
  if ( targetStepName != null ) {
    int trueTargetIdx = Const.indexOfString( targetStepName, output );
    if ( trueTargetIdx < 0 ) {
      return Optional.of( new CheckResult(
        CheckResultInterface.TYPE_RESULT_ERROR,
        BaseMessages.getString( PKG, "FilterRowsMeta.CheckResult.TargetStepInvalid", target, targetStepName ),
        stepMeta
      ) );
    }
  }
  return Optional.empty();
}
 
Example #26
Source File: TransGraph.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * The longer the hop, the higher the force
 *
 * @param hopMeta
 * @param locations
 * @return
 */
private Force getHookeAttraction( TransHopMeta hopMeta, Map<StepMeta, StepLocation> locations ) {
  StepLocation loc1 = locations.get( hopMeta.getFromStep() );
  StepLocation loc2 = locations.get( hopMeta.getToStep() );
  double springConstant = 0.01;

  double fx = springConstant * Math.abs( loc1.x - loc2.x );
  double fy = springConstant * Math.abs( loc1.y - loc2.y );

  return new Force( fx * fx, fy * fy );
}
 
Example #27
Source File: TableCompare.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public TableCompare( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
  Trans trans ) {
  super( stepMeta, stepDataInterface, copyNr, transMeta, trans );

  meta = (TableCompareMeta) getStepMeta().getStepMetaInterface();
  data = (TableCompareData) stepDataInterface;
}
 
Example #28
Source File: ConcatFieldsMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep,
                       VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  // do not call the super class from TextFileOutputMeta since it modifies the source meta data
  // see getFieldsModifyInput() instead

  // remove selected fields from the stream when true
  if ( removeSelectedFields ) {
    if ( getOutputFields().length > 0 ) {
      for ( int i = 0; i < getOutputFields().length; i++ ) {
        TextFileField field = getOutputFields()[ i ];
        try {
          row.removeValueMeta( field.getName() );
        } catch ( KettleValueException e ) {
          // just ignore exceptions since missing fields are handled in the ConcatFields class
        }
      }
    } else { // no output fields selected, take them all, remove them all
      row.clear();
    }
  }

  // Check Target Field Name
  if ( Utils.isEmpty( targetFieldName ) ) {
    throw new KettleStepException( BaseMessages.getString(
      PKG, "ConcatFieldsMeta.CheckResult.TargetFieldNameMissing" ) );
  }
  // add targetFieldName
  ValueMetaInterface vValue = new ValueMetaString( targetFieldName );
  vValue.setLength( targetFieldLength, 0 );
  vValue.setOrigin( name );
  if ( !Utils.isEmpty( getEncoding() ) ) {
    vValue.setStringEncoding( getEncoding() );
  }
  row.addValueMeta( vValue );
}
 
Example #29
Source File: PerformanceLogTable.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void loadXML( Node node, List<DatabaseMeta> databases, List<StepMeta> steps ) {
  connectionName = XMLHandler.getTagValue( node, "connection" );
  schemaName = XMLHandler.getTagValue( node, "schema" );
  tableName = XMLHandler.getTagValue( node, "table" );
  logInterval = XMLHandler.getTagValue( node, "interval" );
  timeoutInDays = XMLHandler.getTagValue( node, "timeout_days" );

  super.loadFieldsXML( node );
}
 
Example #30
Source File: TransMetaModifier.java    From pentaho-pdi-dataset with Apache License 2.0 5 votes vote down vote up
private void handleTweakBypassStep( LogChannelInterface log, StepMeta stepMeta ) {
  if ( log.isDetailed() ) {
    log.logDetailed( "Replacing step '" + stepMeta.getName() + "' with an Dummy for Bypass step tweak" );
  }

  replaceStepWithDummy( log, stepMeta );
}