Java Code Examples for org.pentaho.di.core.row.ValueMetaInterface#setType()

The following examples show how to use org.pentaho.di.core.row.ValueMetaInterface#setType() . 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: MongoDbInputMeta.java    From pentaho-mongodb-plugin with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings( "deprecation" )
@Override
public void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep,
    VariableSpace space ) throws KettleStepException {

  if ( m_outputJson || m_fields == null || m_fields.size() == 0 ) {
    ValueMetaInterface jsonValueMeta = new ValueMeta( jsonFieldName, ValueMetaInterface.TYPE_STRING );
    jsonValueMeta.setOrigin( origin );
    rowMeta.addValueMeta( jsonValueMeta );
  } else {
    for ( MongoField f : m_fields ) {
      ValueMetaInterface vm = new ValueMeta();
      vm.setName( f.m_fieldName );
      vm.setOrigin( origin );
      vm.setType( ValueMeta.getType( f.m_kettleType ) );
      if ( f.m_indexedVals != null ) {
        vm.setIndex( f.m_indexedVals.toArray() ); // indexed values
      }
      rowMeta.addValueMeta( vm );
    }
  }
}
 
Example 2
Source File: OrdinalExtractionTest.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
private RowMetaInterface generateRowMeta( String[] fieldNames ) {
  RowMetaInterface rowMeta = new RowMeta();

  for ( String fieldName : fieldNames ) {
    ValueMetaInterface col = new ValueMeta();
    col.setName( fieldName );
    col.setType( ValueMeta.TYPE_STRING );
    rowMeta.addValueMeta( col );
  }
  return rowMeta;
}
 
Example 3
Source File: OrdinalExtractionTest.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
private RowMetaInterface generateRowMeta( String[] fieldNames ) {
  RowMetaInterface rowMeta = new RowMeta();

  for ( String fieldName : fieldNames ) {
    ValueMetaInterface col = new ValueMeta();
    col.setName( fieldName );
    col.setType( ValueMeta.TYPE_STRING );
    rowMeta.addValueMeta( col );
  }
  return rowMeta;
}
 
Example 4
Source File: S3CsvInputMeta.java    From pentaho-kettle with Apache License 2.0 4 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 {
  rowMeta.clear(); // Start with a clean slate, eats the input

  for ( int i = 0; i < inputFields.length; i++ ) {
    TextFileInputField field = inputFields[i];

    ValueMetaInterface valueMeta = new ValueMeta( field.getName(), field.getType() );
    valueMeta.setConversionMask( field.getFormat() );
    valueMeta.setLength( field.getLength() );
    valueMeta.setPrecision( field.getPrecision() );
    valueMeta.setConversionMask( field.getFormat() );
    valueMeta.setDecimalSymbol( field.getDecimalSymbol() );
    valueMeta.setGroupingSymbol( field.getGroupSymbol() );
    valueMeta.setCurrencySymbol( field.getCurrencySymbol() );
    valueMeta.setTrimType( field.getTrimType() );
    if ( lazyConversionActive ) {
      valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING );
    }

    // In case we want to convert Strings...
    // Using a copy of the valueMeta object means that the inner and outer representation format is the same.
    // Preview will show the data the same way as we read it.
    // This layout is then taken further down the road by the metadata through the transformation.
    //
    ValueMetaInterface storageMetadata = valueMeta.clone();
    storageMetadata.setType( ValueMetaInterface.TYPE_STRING );
    storageMetadata.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL );
    storageMetadata.setLength( -1, -1 ); // we don't really know the lengths of the strings read in advance.
    valueMeta.setStorageMetadata( storageMetadata );

    valueMeta.setOrigin( origin );

    rowMeta.addValueMeta( valueMeta );
  }

  if ( !Utils.isEmpty( filenameField ) && includingFilename ) {
    ValueMetaInterface filenameMeta = new ValueMetaString( filenameField );
    filenameMeta.setOrigin( origin );
    if ( lazyConversionActive ) {
      filenameMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING );
      filenameMeta.setStorageMetadata( new ValueMetaString( filenameField ) );
    }
    rowMeta.addValueMeta( filenameMeta );
  }

  if ( !Utils.isEmpty( rowNumField ) ) {
    ValueMetaInterface rowNumMeta = new ValueMetaInteger( rowNumField );
    rowNumMeta.setLength( 10 );
    rowNumMeta.setOrigin( origin );
    rowMeta.addValueMeta( rowNumMeta );
  }
}