Java Code Examples for org.pentaho.di.core.row.ValueMetaInterface#setTrimType()
The following examples show how to use
org.pentaho.di.core.row.ValueMetaInterface#setTrimType() .
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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: YamlInput.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (YamlInputMeta) smi; data = (YamlInputData) sdi; if ( super.init( smi, sdi ) ) { data.rownr = 1L; data.nrInputFields = meta.getInputFields().length; data.rowMeta = new RowMeta(); for ( int i = 0; i < data.nrInputFields; i++ ) { YamlInputField field = meta.getInputFields()[i]; String path = environmentSubstitute( field.getPath() ); try { ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( path, field.getType() ); valueMeta.setTrimType( field.getTrimType() ); data.rowMeta.addValueMeta( valueMeta ); } catch ( Exception e ) { log.logError( "Unable to create value meta", e ); return false; } } return true; } return false; }
Example 8
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 9
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 10
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 11
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 12
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 13
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 14
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 ); } }