Java Code Examples for org.pentaho.di.core.row.RowMetaInterface

The following examples show how to use org.pentaho.di.core.row.RowMetaInterface. These examples are extracted from open source projects. 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 Project: pentaho-kettle   Source File: TransformClassBase.java    License: 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 2
Source Project: pentaho-kettle   Source File: UniqueRowsMeta.java    License: Apache License 2.0 6 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 {
  // change the case insensitive flag too
  for ( int i = 0; i < compareFields.length; i++ ) {
    int idx = row.indexOfValue( compareFields[i] );
    if ( idx >= 0 ) {
      row.getValueMeta( idx ).setCaseInsensitive( caseInsensitive[i] );
    }
  }
  if ( countRows ) {
    ValueMetaInterface v = new ValueMetaInteger( countField );
    v.setLength( ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0 );
    v.setOrigin( name );
    row.addValueMeta( v );
  }
}
 
Example 3
Source Project: pentaho-kettle   Source File: InsertUpdateDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          tableItem.setText( 2, "=" );
          return true;
        }
      };
      BaseStepDialog.getFieldsFromPrevious( r, wKey, 1, new int[] { 1, 3 }, new int[] {}, -1, -1, listener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "InsertUpdateDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "InsertUpdateDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 4
Source Project: pentaho-kettle   Source File: SyslogMessageDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void get() {
  if ( !gotPreviousFields ) {
    gotPreviousFields = true;
    try {
      String source = wMessageField.getText();

      wMessageField.removeAll();
      RowMetaInterface r = transMeta.getPrevStepFields( stepname );
      if ( r != null ) {
        wMessageField.setItems( r.getFieldNames() );
        if ( source != null ) {
          wMessageField.setText( source );
        }
      }
    } catch ( KettleException ke ) {
      new ErrorDialog(
        shell, BaseMessages.getString( PKG, "SyslogMessageDialog.FailedToGetFields.DialogTitle" ),
        BaseMessages.getString( PKG, "SyslogMessageDialog.FailedToGetFields.DialogMessage" ), ke );
    }
  }
}
 
Example 5
Source Project: pentaho-kettle   Source File: DetectLastRowStepIT.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create data rows.
 *
 * @param nrRows
 *          nr of rows to insert (from 0 to 3 for the moment)
 *
 * @return List of row and meta data
 */
public List<RowMetaAndData> createData( int nrRows ) {
  List<RowMetaAndData> list = new ArrayList<RowMetaAndData>();

  RowMetaInterface rm = createRowMetaInterface();

  Object[] r1 =
    new Object[] { "KETTLE1", new Long( 123L ), new Double( 10.5D ), Boolean.TRUE, BigDecimal.valueOf( 123.45 ) };
  Object[] r2 =
    new Object[] {
      "KETTLE2", new Long( 500L ), new Double( 20.0D ), Boolean.FALSE, BigDecimal.valueOf( 123.45 ) };
  Object[] r3 =
    new Object[] {
      "KETTLE3", new Long( 501L ), new Double( 21.0D ), Boolean.FALSE, BigDecimal.valueOf( 123.45 ) };

  list.add( new RowMetaAndData( rm, r1 ) );
  list.add( new RowMetaAndData( rm, r2 ) );
  list.add( new RowMetaAndData( rm, r3 ) );

  return list.subList( 0, nrRows );
}
 
Example 6
@Override public boolean validateTestObject( RowMetaInterface testObject, Object other ) {
  if ( other == null || !( other instanceof RowMetaInterface ) ) {
    return false;
  }
  RowMetaInterface otherRow = (RowMetaInterface) other;
  if ( testObject.size() != otherRow.size() ) {
    return false;
  }
  for ( int i = 0; i < testObject.size(); i++ ) {
    ValueMetaInterface testVmi = testObject.getValueMeta( i );
    ValueMetaInterface otherVmi = otherRow.getValueMeta( i );
    if ( !testVmi.getName().equals( otherVmi.getName() ) ) {
      return false;
    }
    if ( !testVmi.getTypeDesc().equals( otherVmi.getTypeDesc() ) ) {
      return false;
    }
  }
  return true;
}
 
Example 7
Source Project: pentaho-kettle   Source File: JoinRowsMeta.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  if ( space instanceof TransMeta ) {
    TransMeta transMeta = (TransMeta) space;
    StepMeta[] steps = transMeta.getPrevSteps( transMeta.findStep( origin ) );
    StepMeta mainStep = transMeta.findStep( getMainStepname() );
    rowMeta.clear();
    if ( mainStep != null ) {
      rowMeta.addRowMeta( transMeta.getStepFields( mainStep ) );
    }
    for ( StepMeta step : steps ) {
      if ( mainStep == null || !step.equals( mainStep ) ) {
        rowMeta.addRowMeta( transMeta.getStepFields( step ) );
      }
    }
  }
}
 
Example 8
Source Project: pentaho-kettle   Source File: GetTableNamesDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void setSchemaField() {
  if ( !gotpreviousfields ) {
    try {
      String value = wSchemaField.getText();
      wSchemaField.removeAll();

      RowMetaInterface r = transMeta.getPrevStepFields( stepname );
      if ( r != null ) {
        wSchemaField.setItems( r.getFieldNames() );
      }
      if ( value != null ) {
        wSchemaField.setText( value );
      }
    } catch ( KettleException ke ) {
      new ErrorDialog(
        shell, BaseMessages.getString( PKG, "GetTableNamesDialog.FailedToGetFields.DialogTitle" ),
        BaseMessages.getString( PKG, "GetTableNamesDialog.FailedToGetFields.DialogMessage" ), ke );
    }
    gotpreviousfields = true;
  }
}
 
Example 9
Source Project: pentaho-kettle   Source File: SasInputMeta.java    License: Apache License 2.0 6 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 {

  for ( SasInputField field : outputFields ) {
    try {
      ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( field.getRename(), field.getType() );
      valueMeta.setLength( field.getLength(), field.getPrecision() );
      valueMeta.setDecimalSymbol( field.getDecimalSymbol() );
      valueMeta.setGroupingSymbol( field.getGroupingSymbol() );
      valueMeta.setConversionMask( field.getConversionMask() );
      valueMeta.setTrimType( field.getTrimType() );
      valueMeta.setOrigin( name );

      row.addValueMeta( valueMeta );
    } catch ( Exception e ) {
      throw new KettleStepException( e );
    }
  }
}
 
Example 10
Source Project: pentaho-kettle   Source File: UniqueRowsIT.java    License: Apache License 2.0 6 votes vote down vote up
public List<RowMetaAndData> createResultDataSortCaseInsensitiveUniqueCaseSensitive() {
  List<RowMetaAndData> list = new ArrayList<RowMetaAndData>();

  RowMetaInterface rm = createRowMetaInterface();

  Object[] r1 = new Object[] { "abc" };
  Object[] r2 = new Object[] { "ABC" };
  Object[] r3 = new Object[] { "abc" };
  Object[] r4 = new Object[] { "ABC" };

  list.add( new RowMetaAndData( rm, r1 ) );
  list.add( new RowMetaAndData( rm, r2 ) );
  list.add( new RowMetaAndData( rm, r3 ) );
  list.add( new RowMetaAndData( rm, r4 ) );

  return list;
}
 
Example 11
Source Project: pentaho-kettle   Source File: SetVariableDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious(
        r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, new TableItemInsertListener() {
          public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
            tableItem.setText( 2, v.getName().toUpperCase() );
            tableItem.setText( 3, SetVariableMeta
              .getVariableTypeDescription( SetVariableMeta.VARIABLE_TYPE_ROOT_JOB ) );
            return true;
          }
        } );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "SetVariableDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "Set.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 12
Source Project: pentaho-kettle   Source File: UniqueRowsIT.java    License: Apache License 2.0 6 votes vote down vote up
public List<RowMetaAndData> createResultDataAllUnique() {
  List<RowMetaAndData> list = new ArrayList<RowMetaAndData>();

  RowMetaInterface rm = createRowMetaInterface();

  Object[] r1 = new Object[] { "A" };
  Object[] r2 = new Object[] { "B" };
  Object[] r3 = new Object[] { "C" };
  Object[] r4 = new Object[] { "D" };

  list.add( new RowMetaAndData( rm, r1 ) );
  list.add( new RowMetaAndData( rm, r2 ) );
  list.add( new RowMetaAndData( rm, r3 ) );
  list.add( new RowMetaAndData( rm, r4 ) );

  return list;
}
 
Example 13
@Test( expected = KettleException.class )
public void testVerifyTransMetaNoKeyOrdinal() throws KettleException {
  String inputStepName = "inputStepName";
  StepMeta inputStepMeta = mock( StepMeta.class );
  when( transMeta.findStep( inputStepName ) ).thenReturn( inputStepMeta );
  RowMetaInterface rowMetaInterface = mock( RowMetaInterface.class );
  when( rowMetaInterface.getFieldNames() ).thenReturn( new String[] {} );
  when( transMeta.getStepFields( inputStepMeta ) ).thenReturn( rowMetaInterface );
  try {
    pentahoMapReduceJobBuilder.verifyTransMeta( transMeta, inputStepName, null );
  } catch ( KettleException e ) {
    assertEquals( BaseMessages.getString( PentahoMapReduceJobBuilderImpl.PKG,
      PentahoMapReduceJobBuilderImpl.PENTAHO_MAP_REDUCE_JOB_BUILDER_IMPL_NO_KEY_ORDINAL, inputStepName ),
      e.getMessage().trim() );
    throw e;
  }
}
 
Example 14
Source Project: pentaho-kettle   Source File: TransDebugMeta.java    License: 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 15
Source Project: pentaho-kettle   Source File: StringCutDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          if ( v.getType() == ValueMetaInterface.TYPE_STRING ) {
            // Only process strings
            return true;
          } else {
            return false;
          }
        }
      };

      BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, listener );

    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "StringCutDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "StringCutDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 16
Source Project: pentaho-kettle   Source File: TextFileOutputDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void getFields() {
  if ( !gotPreviousFields ) {
    try {
      String field = wFileNameField.getText();
      RowMetaInterface r = transMeta.getPrevStepFields( stepname );
      if ( r != null ) {
        wFileNameField.setItems( r.getFieldNames() );
      }
      if ( field != null ) {
        wFileNameField.setText( field );
      }
    } catch ( KettleException ke ) {
      new ErrorDialog(
        shell, BaseMessages.getString( PKG, "TextFileOutputDialog.FailedToGetFields.DialogTitle" ),
        BaseMessages.getString( PKG, "TextFileOutputDialog.FailedToGetFields.DialogMessage" ), ke );
    }
    gotPreviousFields = true;
  }
}
 
Example 17
Source Project: pentaho-kettle   Source File: FuzzyMatchDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void setMainStreamField() {
  if ( !gotPreviousFields ) {
    String field = wMainStreamField.getText();
    try {
      wMainStreamField.removeAll();

      RowMetaInterface r = transMeta.getPrevStepFields( stepname );
      if ( r != null ) {
        wMainStreamField.setItems( r.getFieldNames() );
      }
    } catch ( KettleException ke ) {
      new ErrorDialog(
        shell, BaseMessages.getString( PKG, "FuzzyMatchDialog.FailedToGetFields.DialogTitle" ), BaseMessages
          .getString( PKG, "FuzzyMatchDialog.FailedToGetFields.DialogMessage" ), ke );
    }
    if ( field != null ) {
      wMainStreamField.setText( field );
    }
    gotPreviousFields = true;
  }
}
 
Example 18
Source Project: pentaho-kettle   Source File: TeraFastDialog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * ...
 */
public void getUpdate() {
  try {
    final RowMetaInterface row = this.transMeta.getPrevStepFields( this.stepname );
    if ( row != null ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( final TableItem tableItem, final ValueMetaInterface value ) {
          // possible to check format of input fields
          return true;
        }
      };
      BaseStepDialog.getFieldsFromPrevious(
        row, this.wReturn, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, listener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      this.shell, BaseMessages.getString( PKG, "TeraFastDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "TeraFastDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 19
Source Project: pentaho-kettle   Source File: SingleThreaderMeta.java    License: Apache License 2.0 6 votes vote down vote up
public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {

  // First load some interesting data...
  //
  // Then see which fields get added to the row.
  //
  TransMeta mappingTransMeta = null;
  try {
    mappingTransMeta = loadSingleThreadedTransMeta( this, repository, space );
  } catch ( KettleException e ) {
    throw new KettleStepException( BaseMessages.getString(
      PKG, "SingleThreaderMeta.Exception.UnableToLoadMappingTransformation" ), e );
  }

  row.clear();

  // Let's keep it simple!
  //
  if ( !Utils.isEmpty( space.environmentSubstitute( retrieveStep ) ) ) {
    RowMetaInterface stepFields = mappingTransMeta.getStepFields( retrieveStep );
    row.addRowMeta( stepFields );
  }
}
 
Example 20
Source Project: pentaho-kettle   Source File: ExcelInputMeta.java    License: Apache License 2.0 6 votes vote down vote up
public RowMetaInterface getEmptyFields() {
  RowMetaInterface row = new RowMeta();
  if ( field != null ) {
    for ( int i = 0; i < field.length; i++ ) {
      ValueMetaInterface v;
      try {
        v = ValueMetaFactory.createValueMeta( field[ i ].getName(), field[ i ].getType() );
      } catch ( KettlePluginException e ) {
        v = new ValueMetaNone( field[ i ].getName() );
      }
      row.addValueMeta( v );
    }
  }

  return row;
}
 
Example 21
Source Project: pentaho-kettle   Source File: YamlInputDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void setXMLStreamField() {
  try {

    wYAMLLField.removeAll();

    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null ) {
      r.getFieldNames();

      for ( int i = 0; i < r.getFieldNames().length; i++ ) {
        wYAMLLField.add( r.getFieldNames()[i] );

      }
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "YamlInputDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "YamlInputDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 22
Source Project: pentaho-kettle   Source File: DatabaseLookupDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          tableItem.setText( 2, "=" );
          return true;
        }
      };
      BaseStepDialog.getFieldsFromPrevious( r, wKey, 1, new int[] { 1, 3 }, new int[] {}, -1, -1, listener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "DatabaseLookupDialog.GetFieldsFailed.DialogTitle" ), BaseMessages
        .getString( PKG, "DatabaseLookupDialog.GetFieldsFailed.DialogMessage" ), ke );
  }

}
 
Example 23
Source Project: pentaho-kettle   Source File: KettleRecordPopulator.java    License: Apache License 2.0 5 votes vote down vote up
public void populate( BrighthouseRecord record, Object[] row, RowMetaInterface rowMeta ) throws KettleException {

    // assume row metadata is same for all rows
    if ( conv == null ) {
      if ( record.size() != rowMeta.size() ) {
        throw new KettleException( "Number of columns passed to Infobright "
          + "doesn't match the table definition!" );
      }
      init( rowMeta );
    }

    for ( int colidx = 0; colidx < record.size(); colidx++ ) {
      Object value = row[colidx];
      try {
        record.setData( colidx, value, conv[colidx] );
      } catch ( ValueConverterException e ) {
        Throwable cause = e.getCause();
        if ( cause instanceof KettleException ) {
          throw (KettleException) cause;
        } else if ( cause instanceof RuntimeException ) {
          throw (RuntimeException) cause;
        } else if ( cause instanceof Error ) {
          throw (Error) cause;
        } else {
          throw e;
        }
      }
    }
  }
 
Example 24
Source Project: pentaho-kettle   Source File: CsvInput1IT.java    License: Apache License 2.0 5 votes vote down vote up
public RowMetaInterface createResultRowMetaInterface() {
  RowMetaInterface rm = new RowMeta();

  ValueMetaInterface[] valuesMeta =
  {
    new ValueMetaInteger( "a" ), new ValueMetaString( "b" ),
    new ValueMetaString( "c" ), new ValueMetaString( "d" ),
    new ValueMetaString( "e" ), new ValueMetaString( "filename" ), };

  for ( int i = 0; i < valuesMeta.length; i++ ) {
    rm.addValueMeta( valuesMeta[i] );
  }

  return rm;
}
 
Example 25
Source Project: kettle-beam   Source File: BeamOutputStepHandler.java    License: Apache License 2.0 5 votes vote down vote up
private void addAllFieldsToEmptyFileDefinition( RowMetaInterface rowMeta, FileDefinition fileDefinition ) throws KettleStepException {
  if ( fileDefinition.getFieldDefinitions().isEmpty() ) {
    for ( ValueMetaInterface valueMeta : rowMeta.getValueMetaList() ) {
      fileDefinition.getFieldDefinitions().add( new FieldDefinition(
          valueMeta.getName(),
          valueMeta.getTypeDesc(),
          valueMeta.getLength(),
          valueMeta.getPrecision(),
          valueMeta.getConversionMask()
        )
      );
    }
  }
}
 
Example 26
Source Project: pentaho-kettle   Source File: TextFileInput.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated Use {@link #convertLineToRow(LogChannelInterface, TextFileLine,
 * InputFileMetaInterface, Object[], int, RowMetaInterface,RowMetaInterface,
 * String, long, String, String, String, FileErrorHandler, boolean, boolean,
 * boolean, boolean, boolean, boolean, boolean, boolean, String, String, boolean,
 * Date, String, String, String, long)} instead.
 */
@Deprecated
public static final Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,
    InputFileMetaInterface info, RowMetaInterface outputRowMeta, RowMetaInterface convertRowMeta, String fname,
    long rowNr, String delimiter, FileErrorHandler errorHandler, boolean addShortFilename, boolean addExtension,
    boolean addPath, boolean addSize, boolean addIsHidden, boolean addLastModificationDate, boolean addUri,
    boolean addRootUri, String shortFilename, String path, boolean hidden, Date modificationDateTime, String uri,
    String rooturi, String extension, long size ) throws KettleException {
  return convertLineToRow( log, textFileLine, info, null, 0, outputRowMeta, convertRowMeta, fname, rowNr, delimiter,
      StringUtil.substituteHex( info.getEnclosure() ), StringUtil.substituteHex( info.getEscapeCharacter() ),
      errorHandler, addShortFilename, addExtension, addPath, addSize, addIsHidden, addLastModificationDate, addUri,
      addRootUri, shortFilename, path, hidden, modificationDateTime, uri, rooturi, extension, size );
}
 
Example 27
Source Project: pentaho-kettle   Source File: RowDataInputMapper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Attempts to put the <code>row</code> onto the underlying <code>rowProducer</code> during its timeout period.
 * Returns <code>true</code> if the operation completed successfully and <code>false</code> otherwise.
 *
 * @param rowMeta input row's meta data
 * @param row     input row
 * @return <code>true</code> if the <code>row</code> was put successfully
 */
public boolean putRow( RowMetaInterface rowMeta, Object[] row ) {
  if ( first ) {
    first = false;
    renamedRowMeta = rowMeta.clone();

    for ( MappingValueRename valueRename : inputDefinition.getValueRenames() ) {
      ValueMetaInterface valueMeta = renamedRowMeta.searchValueMeta( valueRename.getSourceValueName() );
      if ( valueMeta != null ) {
        valueMeta.setName( valueRename.getTargetValueName() );
      }
    }
  }
  return rowProducer.putRow( renamedRowMeta, row, false );
}
 
Example 28
Source Project: pentaho-kettle   Source File: Database.java    License: Apache License 2.0 5 votes vote down vote up
public void insertRow( String schemaName, String tableName, RowMetaInterface fields, Object[] data )
  throws KettleDatabaseException {
  prepareInsert( fields, schemaName, tableName );
  setValuesInsert( fields, data );
  insertRow();
  closeInsert();
}
 
Example 29
Source Project: pentaho-kettle   Source File: DatabaseJoinDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious( r, wParam, 1, new int[] { 1 }, new int[] { 2 }, -1, -1, null );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "DatabaseJoinDialog.GetFieldsFailed.DialogTitle" ), BaseMessages
        .getString( PKG, "DatabaseJoinDialog.GetFieldsFailed.DialogMessage" ), ke );
  }

}
 
Example 30
Source Project: pentaho-kettle   Source File: SalesforceUpsertMeta.java    License: Apache License 2.0 5 votes vote down vote up
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  String realfieldname = space.environmentSubstitute( getSalesforceIDFieldName() );
  if ( !Utils.isEmpty( realfieldname ) ) {
    ValueMetaInterface v = new ValueMetaString( realfieldname );
    v.setLength( 18 );
    v.setOrigin( name );
    r.addValueMeta( v );
  }
}