Java Code Examples for org.pentaho.di.core.row.ValueMetaInterface#setGroupingSymbol()
The following examples show how to use
org.pentaho.di.core.row.ValueMetaInterface#setGroupingSymbol() .
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: JsonInputField.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public ValueMetaInterface toValueMeta( String fieldOriginStepName, VariableSpace vspace ) throws KettlePluginException { int type = getType(); if ( type == ValueMetaInterface.TYPE_NONE ) { type = ValueMetaInterface.TYPE_STRING; } ValueMetaInterface v = ValueMetaFactory.createValueMeta( vspace != null ? vspace.environmentSubstitute( getName() ) : getName(), type ); v.setLength( getLength() ); v.setPrecision( getPrecision() ); v.setOrigin( fieldOriginStepName ); v.setConversionMask( getFormat() ); v.setDecimalSymbol( getDecimalSymbol() ); v.setGroupingSymbol( getGroupSymbol() ); v.setCurrencySymbol( getCurrencySymbol() ); v.setTrimType( getTrimType() ); return v; }
Example 2
Source File: CalculatorMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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 3
Source File: RegexEvalMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private ValueMetaInterface constructValueMeta( ValueMetaInterface sourceValueMeta, String fieldName, int i, String name ) throws KettlePluginException { int type = fieldType[i]; if ( type == ValueMetaInterface.TYPE_NONE ) { type = ValueMetaInterface.TYPE_STRING; } ValueMetaInterface v; if ( sourceValueMeta == null ) { v = ValueMetaFactory.createValueMeta( fieldName, type ); } else { v = ValueMetaFactory.cloneValueMeta( sourceValueMeta, type ); } v.setLength( fieldLength[i] ); v.setPrecision( fieldPrecision[i] ); v.setOrigin( name ); v.setConversionMask( fieldFormat[i] ); v.setDecimalSymbol( fieldDecimal[i] ); v.setGroupingSymbol( fieldGroup[i] ); v.setCurrencySymbol( fieldCurrency[i] ); v.setTrimType( fieldTrimType[i] ); return v; }
Example 4
Source File: SasInputMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@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 5
Source File: DataGridMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public void getFields( RowMetaInterface rowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( int i = 0; i < fieldName.length; i++ ) { try { if ( !Utils.isEmpty( fieldName[i] ) ) { int type = ValueMetaFactory.getIdForValueMeta( fieldType[i] ); if ( type == ValueMetaInterface.TYPE_NONE ) { type = ValueMetaInterface.TYPE_STRING; } ValueMetaInterface v = ValueMetaFactory.createValueMeta( fieldName[i], type ); v.setLength( fieldLength[i] ); v.setPrecision( fieldPrecision[i] ); v.setOrigin( name ); v.setConversionMask( fieldFormat[i] ); v.setCurrencySymbol( currency[i] ); v.setGroupingSymbol( group[i] ); v.setDecimalSymbol( decimal[i] ); rowMeta.addValueMeta( v ); } } catch ( Exception e ) { throw new KettleStepException( "Unable to create value of type " + fieldType[i], e ); } } }
Example 6
Source File: TextFileOutputMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // No values are added to the row in this type of step // However, in case of Fixed length records, // the field precisions and lengths are altered! for ( int i = 0; i < outputFields.length; i++ ) { TextFileField field = outputFields[i]; ValueMetaInterface v = row.searchValueMeta( field.getName() ); if ( v != null ) { v.setLength( field.getLength() ); v.setPrecision( field.getPrecision() ); if ( field.getFormat() != null ) { v.setConversionMask( field.getFormat() ); } v.setDecimalSymbol( field.getDecimalSymbol() ); v.setGroupingSymbol( field.getGroupingSymbol() ); v.setCurrencySymbol( field.getCurrencySymbol() ); v.setOutputPaddingEnabled( isPadded() ); v.setTrimType( field.getTrimType() ); if ( !Utils.isEmpty( getEncoding() ) ) { v.setStringEncoding( getEncoding() ); } // enable output padding by default to be compatible with v2.5.x // v.setOutputPaddingEnabled( true ); } } }
Example 7
Source File: StringEvaluator.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public StringEvaluationResult build() { ValueMetaInterface meta = new ValueMeta( name, type ); meta.setConversionMask( format ); meta.setTrimType( trimType ); meta.setDecimalSymbol( decimalSymbol ); meta.setGroupingSymbol( groupingSymbol ); meta.setLength( length ); meta.setPrecision( precision ); return new StringEvaluationResult( meta ); }
Example 8
Source File: ValueMetaFactory.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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 9
Source File: GoogleSpreadsheetInputMeta.java From pdi-google-spreadsheet-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void getFields(RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException { try { inputRowMeta.clear(); // Start with a clean slate, eats the input for (TextFileInputField field : inputFields) { ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta(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()); valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING); valueMeta.setDateFormatLenient(true); valueMeta.setStringEncoding("UTF-8"); ValueMetaInterface storageMetadata = ValueMetaFactory.cloneValueMeta(valueMeta, 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(name); inputRowMeta.addValueMeta(valueMeta); } } catch (Exception e) { } }
Example 10
Source File: FieldSplitterMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // Remove the field to split int idx = r.indexOfValue( getSplitField() ); if ( idx < 0 ) { // not found throw new RuntimeException( BaseMessages.getString( PKG, "FieldSplitter.Log.CouldNotFindFieldToSplit", getSplitField() ) ); } // Add the new fields at the place of the index --> replace! int count = getFieldsCount(); for ( int i = 0; i < count; i++ ) { try { final ValueMetaInterface v = ValueMetaFactory.createValueMeta( getFieldName()[i], getFieldType()[i] ); v.setLength( getFieldLength()[i], getFieldPrecision()[i] ); v.setOrigin( name ); v.setConversionMask( getFieldFormat()[i] ); v.setDecimalSymbol( getFieldDecimal()[i] ); v.setGroupingSymbol( getFieldGroup()[i] ); v.setCurrencySymbol( getFieldCurrency()[i] ); v.setTrimType( getFieldTrimType()[i] ); // TODO when implemented in UI // v.setDateFormatLenient(dateFormatLenient); // TODO when implemented in UI // v.setDateFormatLocale(dateFormatLocale); if ( i == 0 && idx >= 0 ) { // the first valueMeta (splitField) will be replaced r.setValueMeta( idx, v ); } else { // other valueMeta will be added if ( idx >= r.size() ) { r.addValueMeta( v ); } r.addValueMeta( idx + i, v ); } } catch ( Exception e ) { throw new KettleStepException( e ); } } }
Example 11
Source File: FixedInputMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { try { for ( int i = 0; i < fieldDefinition.length; i++ ) { FixedFileInputField field = fieldDefinition[i]; ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( field.getName(), field.getType() ); valueMeta.setConversionMask( field.getFormat() ); valueMeta.setTrimType( field.getTrimType() ); valueMeta.setLength( field.getLength() ); valueMeta.setPrecision( field.getPrecision() ); valueMeta.setConversionMask( field.getFormat() ); valueMeta.setDecimalSymbol( field.getDecimal() ); valueMeta.setGroupingSymbol( field.getGrouping() ); valueMeta.setCurrencySymbol( field.getCurrency() ); valueMeta.setStringEncoding( space.environmentSubstitute( encoding ) ); if ( lazyConversionActive ) { valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ); } // In case we want to convert Strings... // ValueMetaInterface storageMetadata = ValueMetaFactory.cloneValueMeta( valueMeta, ValueMetaInterface.TYPE_STRING ); storageMetadata.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); valueMeta.setStorageMetadata( storageMetadata ); valueMeta.setOrigin( origin ); rowMeta.addValueMeta( valueMeta ); } } catch ( Exception e ) { throw new KettleStepException( e ); } }
Example 12
Source File: SelectValues.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Change the meta-data of certain fields. * <p/> * This, we can do VERY fast. * <p/> * * @param row The row to manipulate * @return the altered RowData array * @throws KettleValueException */ @VisibleForTesting synchronized Object[] metadataValues( RowMetaInterface rowMeta, Object[] rowData ) throws KettleException { if ( data.firstmetadata ) { data.firstmetadata = false; data.metanrs = new int[ meta.getMeta().length ]; for ( int i = 0; i < data.metanrs.length; i++ ) { data.metanrs[ i ] = rowMeta.indexOfValue( meta.getMeta()[ i ].getName() ); if ( data.metanrs[ i ] < 0 ) { logError( BaseMessages .getString( PKG, "SelectValues.Log.CouldNotFindField", meta.getMeta()[ i ].getName() ) ); setErrors( 1 ); stopAll(); return null; } } // Check for doubles in the selected fields... int[] cnt = new int[ meta.getMeta().length ]; for ( int i = 0; i < meta.getMeta().length; i++ ) { cnt[ i ] = 0; for ( int j = 0; j < meta.getMeta().length; j++ ) { if ( meta.getMeta()[ i ].getName().equals( meta.getMeta()[ j ].getName() ) ) { cnt[ i ]++; } if ( cnt[ i ] > 1 ) { logError( BaseMessages.getString( PKG, "SelectValues.Log.FieldCouldNotSpecifiedMoreThanTwice2", meta .getMeta()[ i ].getName() ) ); setErrors( 1 ); stopAll(); return null; } } } // Also apply the metadata on the row meta to allow us to convert the data correctly, with the correct mask. // for ( int i = 0; i < data.metanrs.length; i++ ) { SelectMetadataChange change = meta.getMeta()[ i ]; ValueMetaInterface valueMeta = rowMeta.getValueMeta( data.metanrs[ i ] ); if ( !Utils.isEmpty( change.getConversionMask() ) ) { valueMeta.setConversionMask( change.getConversionMask() ); } valueMeta.setDateFormatLenient( change.isDateFormatLenient() ); valueMeta.setDateFormatLocale( EnvUtil.createLocale( change.getDateFormatLocale() ) ); valueMeta.setDateFormatTimeZone( EnvUtil.createTimeZone( change.getDateFormatTimeZone() ) ); valueMeta.setLenientStringToNumber( change.isLenientStringToNumber() ); if ( !Utils.isEmpty( change.getEncoding() ) ) { valueMeta.setStringEncoding( change.getEncoding() ); } if ( !Utils.isEmpty( change.getDecimalSymbol() ) ) { valueMeta.setDecimalSymbol( change.getDecimalSymbol() ); } if ( !Utils.isEmpty( change.getGroupingSymbol() ) ) { valueMeta.setGroupingSymbol( change.getGroupingSymbol() ); } if ( !Utils.isEmpty( change.getCurrencySymbol() ) ) { valueMeta.setCurrencySymbol( change.getCurrencySymbol() ); } } } // // Change the data too // for ( int i = 0; i < data.metanrs.length; i++ ) { int index = data.metanrs[ i ]; ValueMetaInterface fromMeta = rowMeta.getValueMeta( index ); ValueMetaInterface toMeta = data.metadataRowMeta.getValueMeta( index ); // If we need to change from BINARY_STRING storage type to NORMAL... // try { if ( fromMeta.isStorageBinaryString() && meta.getMeta()[ i ].getStorageType() == ValueMetaInterface.STORAGE_TYPE_NORMAL ) { rowData[ index ] = fromMeta.convertBinaryStringToNativeType( (byte[]) rowData[ index ] ); } if ( meta.getMeta()[ i ].getType() != ValueMetaInterface.TYPE_NONE && fromMeta.getType() != toMeta.getType() ) { rowData[ index ] = toMeta.convertData( fromMeta, rowData[ index ] ); } } catch ( KettleValueException e ) { throw new KettleConversionException( e.getMessage(), Collections.<Exception>singletonList( e ), Collections.singletonList( toMeta ), rowData ); } } return rowData; }
Example 13
Source File: SelectValuesMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void getMetadataFields( RowMetaInterface inputRowMeta, String name, VariableSpace space ) throws KettlePluginException { if ( meta != null && meta.length > 0 ) { // METADATA mode: change the meta-data of the values mentioned... for ( int i = 0; i < meta.length; i++ ) { SelectMetadataChange metaChange = meta[i]; int idx = inputRowMeta.indexOfValue( metaChange.getName() ); boolean metaTypeChangeUsesNewTypeDefaults = false; // Normal behavior as of 5.x or so if ( space != null ) { metaTypeChangeUsesNewTypeDefaults = ValueMetaBase.convertStringToBoolean( space.getVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "N" ) ); } if ( idx >= 0 ) { // We found the value // This is the value we need to change: ValueMetaInterface v = inputRowMeta.getValueMeta( idx ); // Do we need to rename ? if ( !v.getName().equals( metaChange.getRename() ) && !Utils.isEmpty( metaChange.getRename() ) ) { v.setName( metaChange.getRename() ); v.setOrigin( name ); // need to reinsert to check name conflicts inputRowMeta.setValueMeta( idx, v ); } // Change the type? if ( metaChange.getType() != ValueMetaInterface.TYPE_NONE && v.getType() != metaChange.getType() ) { // Fix for PDI-16388 - clone copies over the conversion mask instead of using the default for the new type if ( !metaTypeChangeUsesNewTypeDefaults ) { v = ValueMetaFactory.cloneValueMeta( v, metaChange.getType() ); } else { v = ValueMetaFactory.createValueMeta( v.getName(), metaChange.getType() ); } // This is now a copy, replace it in the row! // inputRowMeta.setValueMeta( idx, v ); // This also moves the data to normal storage type // v.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); } if ( metaChange.getLength() != UNDEFINED ) { v.setLength( metaChange.getLength() ); v.setOrigin( name ); } if ( metaChange.getPrecision() != UNDEFINED ) { v.setPrecision( metaChange.getPrecision() ); v.setOrigin( name ); } if ( metaChange.getStorageType() >= 0 ) { v.setStorageType( metaChange.getStorageType() ); v.setOrigin( name ); } if ( !Utils.isEmpty( metaChange.getConversionMask() ) ) { v.setConversionMask( metaChange.getConversionMask() ); v.setOrigin( name ); } v.setDateFormatLenient( metaChange.isDateFormatLenient() ); v.setDateFormatLocale( EnvUtil.createLocale( metaChange.getDateFormatLocale() ) ); v.setDateFormatTimeZone( EnvUtil.createTimeZone( metaChange.getDateFormatTimeZone() ) ); v.setLenientStringToNumber( metaChange.isLenientStringToNumber() ); if ( !Utils.isEmpty( metaChange.getEncoding() ) ) { v.setStringEncoding( metaChange.getEncoding() ); v.setOrigin( name ); } if ( !Utils.isEmpty( metaChange.getDecimalSymbol() ) ) { v.setDecimalSymbol( metaChange.getDecimalSymbol() ); v.setOrigin( name ); } if ( !Utils.isEmpty( metaChange.getGroupingSymbol() ) ) { v.setGroupingSymbol( metaChange.getGroupingSymbol() ); v.setOrigin( name ); } if ( !Utils.isEmpty( metaChange.getCurrencySymbol() ) ) { v.setCurrencySymbol( metaChange.getCurrencySymbol() ); v.setOrigin( name ); } } } } }
Example 14
Source File: IngresVectorwiseLoader.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (IngresVectorwiseLoaderMeta) smi; data = (IngresVectorwiseLoaderData) sdi; try { Object[] r = getRow(); // Get row from input rowset & set row busy! // no more input to be expected... if ( r == null ) { // only close output after the first row was processed // to prevent error (NPE) on empty rows set if ( !first ) { closeOutput(); } if ( logWriter != null ) { logWriteThread.join(); if ( logWriter.isErrorsOccured() ) { throw new SQLException( "The error was gotten from ingres sql process" ); } } if ( vwLoadMonitorThread != null ) { vwLoadMonitorThread.join(); } setOutputDone(); return false; } if ( first ) { first = false; // Cache field indexes. // data.keynrs = new int[meta.getFieldStream().length]; for ( int i = 0; i < data.keynrs.length; i++ ) { data.keynrs[i] = getInputRowMeta().indexOfValue( meta.getFieldStream()[i] ); } data.bulkRowMeta = getInputRowMeta().clone(); if ( meta.isUseStandardConversion() ) { for ( int i = 0; i < data.bulkRowMeta.size(); i++ ) { ValueMetaInterface valueMeta = data.bulkRowMeta.getValueMeta( i ); if ( valueMeta.isStorageNormal() ) { if ( valueMeta.isDate() ) { valueMeta.setConversionMask( "yyyy-MM-dd HH:mm:ss" ); } else if ( valueMeta.isNumeric() ) { valueMeta.setDecimalSymbol( "." ); valueMeta.setGroupingSymbol( "" ); } } } } // execute the client statement... // execute( meta ); // Allocate a buffer // data.fileChannel = data.fifoOpener.getFileChannel(); data.byteBuffer = ByteBuffer.allocate( data.bufferSize ); } // check if SQL process is still running before processing row if ( !checkSqlProcessRunning( data.sqlProcess ) ) { throw new Exception( "Ingres SQL process has stopped" ); } writeRowToBulk( data.bulkRowMeta, r ); putRow( getInputRowMeta(), r ); incrementLinesOutput(); if ( checkFeedback( getLinesOutput() ) ) { logBasic( BaseMessages.getString( PKG, "IngresVectorwiseLoader.Log.LineNumber" ) + getLinesOutput() ); } return true; } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "IngresVectorwiseLoader.Log.ErrorInStep" ), e ); setErrors( 1 ); stopAll(); setOutputDone(); // signal end to receiver(s) return false; } }
Example 15
Source File: ParGzipCsvInputMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { try { rowMeta.clear(); // Start with a clean slate, eats the input for ( int i = 0; i < inputFields.length; i++ ) { TextFileInputField field = inputFields[i]; ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( 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 ); } valueMeta.setStringEncoding( space.environmentSubstitute( encoding ) ); // 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 = ValueMetaFactory.cloneValueMeta( valueMeta, 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 ); } } catch ( Exception e ) { throw new KettleStepException( e ); } }
Example 16
Source File: CsvInputMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { try { rowMeta.clear(); // Start with a clean slate, eats the input for ( int i = 0; i < inputFields.length; i++ ) { TextFileInputField field = inputFields[i]; ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( 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 ); } valueMeta.setStringEncoding( space.environmentSubstitute( encoding ) ); // 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 = ValueMetaFactory.cloneValueMeta( valueMeta, 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 ); } } catch ( Exception e ) { throw new KettleStepException( e ); } }
Example 17
Source File: GetVariableMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // Determine the maximum length... // int length = -1; for ( int i = 0; i < fieldDefinitions.length; i++ ) { String variableString = fieldDefinitions[i].getVariableString(); if ( variableString != null ) { String string = space.environmentSubstitute( variableString ); if ( string.length() > length ) { length = string.length(); } } } RowMetaInterface row = new RowMeta(); for ( int i = 0; i < fieldDefinitions.length; i++ ) { ValueMetaInterface v; try { v = ValueMetaFactory.createValueMeta( fieldDefinitions[i].getFieldName(), fieldDefinitions[i].getFieldType() ); } catch ( KettlePluginException e ) { throw new KettleStepException( e ); } int fieldLength = fieldDefinitions[i].getFieldLength(); if ( fieldLength < 0 ) { v.setLength( length ); } else { v.setLength( fieldLength ); } int fieldPrecision = fieldDefinitions[i].getFieldPrecision(); if ( fieldPrecision >= 0 ) { v.setPrecision( fieldPrecision ); } v.setConversionMask( fieldDefinitions[i].getFieldFormat() ); v.setGroupingSymbol( fieldDefinitions[i].getGroup() ); v.setDecimalSymbol( fieldDefinitions[i].getDecimal() ); v.setCurrencySymbol( fieldDefinitions[i].getCurrency() ); v.setTrimType( fieldDefinitions[i].getTrimType() ); v.setOrigin( name ); row.addValueMeta( v ); } inputRowMeta.mergeRowMeta( row, name ); }
Example 18
Source File: KettleDatabaseRepositoryConditionDelegate.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public synchronized ObjectId insertCondition( ObjectId id_condition_parent, Condition condition ) throws KettleException { ObjectId id = repository.connectionDelegate.getNextConditionID(); String tablename = KettleDatabaseRepository.TABLE_R_CONDITION; RowMetaAndData table = new RowMetaAndData(); table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_CONDITION_ID_CONDITION ), id ); table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_CONDITION_ID_CONDITION_PARENT ), id_condition_parent ); table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_CONDITION_NEGATED ), Boolean .valueOf( condition.isNegated() ) ); table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_CONDITION_OPERATOR ), condition .getOperatorDesc() ); table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_CONDITION_LEFT_NAME ), condition .getLeftValuename() ); table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_CONDITION_CONDITION_FUNCTION ), condition .getFunctionDesc() ); table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_CONDITION_RIGHT_NAME ), condition .getRightValuename() ); ObjectId id_value = null; ValueMetaAndData v = condition.getRightExact(); if ( v != null ) { // We have to make sure that all data is saved irrespective of locale differences. // Here is where we force that // ValueMetaInterface valueMeta = v.getValueMeta(); valueMeta.setDecimalSymbol( ValueMetaAndData.VALUE_REPOSITORY_DECIMAL_SYMBOL ); valueMeta.setGroupingSymbol( ValueMetaAndData.VALUE_REPOSITORY_GROUPING_SYMBOL ); switch ( valueMeta.getType() ) { case ValueMetaInterface.TYPE_NUMBER: valueMeta.setConversionMask( ValueMetaAndData.VALUE_REPOSITORY_NUMBER_CONVERSION_MASK ); break; case ValueMetaInterface.TYPE_INTEGER: valueMeta.setConversionMask( ValueMetaAndData.VALUE_REPOSITORY_INTEGER_CONVERSION_MASK ); break; case ValueMetaInterface.TYPE_DATE: valueMeta.setConversionMask( ValueMetaAndData.VALUE_REPOSITORY_DATE_CONVERSION_MASK ); break; default: break; } String stringValue = valueMeta.getString( v.getValueData() ); id_value = insertValue( valueMeta.getName(), valueMeta.getTypeDesc(), stringValue, valueMeta.isNull( v .getValueData() ), condition.getRightExactID() ); condition.setRightExactID( id_value ); } table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_CONDITION_ID_VALUE_RIGHT ), id_value ); repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), tablename ); repository.connectionDelegate.getDatabase().setValuesInsert( table ); repository.connectionDelegate.getDatabase().insertRow(); repository.connectionDelegate.getDatabase().closeInsert(); return id; }
Example 19
Source File: S3CsvInputMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@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 ); } }
Example 20
Source File: KettleDatabaseRepositoryValueDelegate.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public ValueMetaAndData loadValueMetaAndData( ObjectId id_value ) throws KettleException { ValueMetaAndData valueMetaAndData = new ValueMetaAndData(); try { RowMetaAndData r = getValue( id_value ); if ( r != null ) { String name = r.getString( KettleDatabaseRepository.FIELD_VALUE_NAME, null ); int valtype = ValueMetaFactory.getIdForValueMeta( r.getString( KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE, null ) ); boolean isNull = r.getBoolean( KettleDatabaseRepository.FIELD_VALUE_IS_NULL, false ); ValueMetaInterface v = ValueMetaFactory.createValueMeta( name, valtype ); valueMetaAndData.setValueMeta( v ); if ( isNull ) { valueMetaAndData.setValueData( null ); } else { ValueMetaInterface stringValueMeta = new ValueMetaString( name ); ValueMetaInterface valueMeta = valueMetaAndData.getValueMeta(); stringValueMeta.setConversionMetadata( valueMeta ); valueMeta.setDecimalSymbol( ValueMetaAndData.VALUE_REPOSITORY_DECIMAL_SYMBOL ); valueMeta.setGroupingSymbol( ValueMetaAndData.VALUE_REPOSITORY_GROUPING_SYMBOL ); switch ( valueMeta.getType() ) { case ValueMetaInterface.TYPE_NUMBER: valueMeta.setConversionMask( ValueMetaAndData.VALUE_REPOSITORY_NUMBER_CONVERSION_MASK ); break; case ValueMetaInterface.TYPE_INTEGER: valueMeta.setConversionMask( ValueMetaAndData.VALUE_REPOSITORY_INTEGER_CONVERSION_MASK ); break; default: break; } String string = r.getString( "VALUE_STR", null ); valueMetaAndData.setValueData( stringValueMeta.convertDataUsingConversionMetaData( string ) ); // OK, now comes the dirty part... // We want the defaults back on there... // valueMeta = ValueMetaFactory.createValueMeta( name, valueMeta.getType() ); } } return valueMetaAndData; } catch ( KettleException dbe ) { throw new KettleException( "Unable to load Value from repository with id_value=" + id_value, dbe ); } }