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

The following examples show how to use org.pentaho.di.core.row.ValueMetaInterface#setComments() . 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: CalculatorMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private ValueMetaInterface getValueMeta( CalculatorMetaFunction fn, String origin ) {
  ValueMetaInterface v;
  // What if the user didn't specify a data type?
  // In that case we look for the default data type
  //
  int defaultResultType = fn.getValueType();
  if ( defaultResultType == ValueMetaInterface.TYPE_NONE ) {
    defaultResultType = CalculatorMetaFunction.getCalcFunctionDefaultResultType( fn.getCalcType() );
  }
  try {
    v = ValueMetaFactory.createValueMeta( fn.getFieldName(), defaultResultType );
  } catch ( Exception ex ) {
    return null;
  }
  v.setLength( fn.getValueLength() );
  v.setPrecision( fn.getValuePrecision() );
  v.setOrigin( origin );
  v.setComments( fn.getCalcTypeDesc() );
  v.setConversionMask( fn.getConversionMask() );
  v.setDecimalSymbol( fn.getDecimalSymbol() );
  v.setGroupingSymbol( fn.getGroupingSymbol() );
  v.setCurrencySymbol( fn.getCurrencySymbol() );

  return v;
}
 
Example 2
Source File: DataSet.java    From pentaho-pdi-dataset with Apache License 2.0 5 votes vote down vote up
/**
 * Get standard Kettle row metadata from the defined data set fields
 *
 * @param columnName true if you want the field names to be called after the columns, false if you prefer the field names in the result.
 * @return The row metadata
 * @throws KettlePluginException
 */
public RowMetaInterface getSetRowMeta( boolean columnName ) throws KettlePluginException {
  RowMetaInterface rowMeta = new RowMeta();
  for ( DataSetField field : getFields() ) {
    ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta(
      columnName ? field.getColumnName() : field.getFieldName(),
      field.getType(),
      field.getLength(),
      field.getPrecision() );
    valueMeta.setComments( field.getComment() );
    valueMeta.setConversionMask( field.getFormat() );
    rowMeta.addValueMeta( valueMeta );
  }
  return rowMeta;
}
 
Example 3
Source File: ValueMetaFactory.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static void cloneInfo( ValueMetaInterface source, ValueMetaInterface target ) throws KettlePluginException {
  target.setConversionMask( source.getConversionMask() );
  target.setDecimalSymbol( source.getDecimalSymbol() );
  target.setGroupingSymbol( source.getGroupingSymbol() );
  target.setStorageType( source.getStorageType() );
  if ( source.getStorageMetadata() != null ) {
    target.setStorageMetadata( cloneValueMeta( source.getStorageMetadata(), source
      .getStorageMetadata().getType() ) );
  }
  target.setStringEncoding( source.getStringEncoding() );
  target.setTrimType( source.getTrimType() );
  target.setDateFormatLenient( source.isDateFormatLenient() );
  target.setDateFormatLocale( source.getDateFormatLocale() );
  target.setDateFormatTimeZone( source.getDateFormatTimeZone() );
  target.setLenientStringToNumber( source.isLenientStringToNumber() );
  target.setLargeTextField( source.isLargeTextField() );
  target.setComments( source.getComments() );
  target.setCaseInsensitive( source.isCaseInsensitive() );
  target.setCollatorDisabled( source.isCollatorDisabled() );
  target.setCollatorStrength( source.getCollatorStrength() );
  target.setIndex( source.getIndex() );

  target.setOrigin( source.getOrigin() );

  target.setOriginalAutoIncrement( source.isOriginalAutoIncrement() );
  target.setOriginalColumnType( source.getOriginalColumnType() );
  target.setOriginalColumnTypeName( source.getOriginalColumnTypeName() );
  target.setOriginalNullable( source.isOriginalNullable() );
  target.setOriginalPrecision( source.getOriginalPrecision() );
  target.setOriginalScale( source.getOriginalScale() );
  target.setOriginalSigned( source.isOriginalSigned() );
}
 
Example 4
Source File: ValueMetaBase.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected void getOriginalColumnMetadata( ValueMetaInterface v, ResultSetMetaData rm, int index, boolean ignoreLength )
  throws SQLException {
  // Grab the comment as a description to the field as well.
  String comments = rm.getColumnLabel( index );
  v.setComments( comments );

  // get & store more result set meta data for later use
  int originalColumnType = rm.getColumnType( index );
  v.setOriginalColumnType( originalColumnType );

  String originalColumnTypeName = rm.getColumnTypeName( index );
  v.setOriginalColumnTypeName( originalColumnTypeName );

  int originalPrecision = -1;
  if ( !ignoreLength ) {
    // Throws exception on MySQL
    originalPrecision = rm.getPrecision( index );
  }
  v.setOriginalPrecision( originalPrecision );

  int originalScale = rm.getScale( index );
  v.setOriginalScale( originalScale );

  // DISABLED FOR PERFORMANCE REASONS : PDI-1788
  //
  // boolean originalAutoIncrement=rm.isAutoIncrement(index); DISABLED FOR
  // PERFORMANCE REASONS : PDI-1788
  // v.setOriginalAutoIncrement(originalAutoIncrement);

  // int originalNullable=rm.isNullable(index); DISABLED FOR PERFORMANCE
  // REASONS : PDI-1788
  // v.setOriginalNullable(originalNullable);
  //

  boolean originalSigned = false;
  try {
    originalSigned = rm.isSigned( index );
  } catch ( Exception ignored ) {
    // This JDBC Driver doesn't support the isSigned method.
    // Nothing more we can do here.
  }
  v.setOriginalSigned( originalSigned );
}