@Override public void setDefault() { value = new ValueMetaAndData( new ValueMetaNumber( "valuename" ), new Double( 123.456 ) ); value.getValueMeta().setLength( 12 ); value.getValueMeta().setPrecision( 4 ); }
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++ ) { if ( fieldName[i] != null && fieldName[i].length() != 0 ) { int type = ValueMetaFactory.getIdForValueMeta( fieldType[i] ); if ( type == ValueMetaInterface.TYPE_NONE ) { type = ValueMetaInterface.TYPE_STRING; } try { ValueMetaInterface v = ValueMetaFactory.createValueMeta( fieldName[i], type ); v.setLength( fieldLength[i] ); v.setPrecision( fieldPrecision[i] ); v.setOrigin( name ); v.setConversionMask( fieldFormat[i] ); rowMeta.addValueMeta( v ); } catch ( Exception e ) { throw new KettleStepException( e ); } } } }
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 ); }
@Override public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { ValueMetaInterface v = new ValueMetaInteger( technicalKeyField ); v.setLength( 10 ); v.setPrecision( 0 ); v.setOrigin( origin ); row.addValueMeta( v ); if ( replaceFields ) { for ( int i = 0; i < keyField.length; i++ ) { int idx = row.indexOfValue( keyField[ i ] ); if ( idx >= 0 ) { row.removeValueMeta( idx ); } } } }
@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 ); } } }
private ValueMetaAndData getValue( String valuename ) throws KettleValueException { try { int valtype = ValueMetaFactory.getIdForValueMeta( wValueType.getText() ); ValueMetaAndData val = new ValueMetaAndData( valuename, wInputString.getText() ); ValueMetaInterface valueMeta = ValueMetaFactory.cloneValueMeta( val.getValueMeta(), valtype ); Object valueData = val.getValueData(); int formatIndex = wFormat.getSelectionIndex(); valueMeta.setConversionMask( formatIndex >= 0 ? wFormat.getItem( formatIndex ) : wFormat.getText() ); valueMeta.setLength( Const.toInt( wLength.getText(), -1 ) ); valueMeta.setPrecision( Const.toInt( wPrecision.getText(), -1 ) ); val.setValueMeta( valueMeta ); ValueMetaInterface stringValueMeta = new ValueMetaString( valuename ); stringValueMeta.setConversionMetadata( valueMeta ); Object targetData = stringValueMeta.convertDataUsingConversionMetaData( valueData ); val.setValueData( targetData ); return val; } catch ( Exception e ) { throw new KettleValueException( e ); } }
ValueMetaInterface v = new ValueMetaString( realtablename ); v.setLength( 500 ); v.setPrecision( -1 ); v.setOrigin( name ); r.addValueMeta( v ); ValueMetaInterface v = new ValueMetaString( realObjectType ); v.setLength( 500 ); v.setPrecision( -1 ); v.setOrigin( name ); r.addValueMeta( v ); ValueMetaInterface v = new ValueMetaString( realSQLCreation ); v.setLength( 500 ); v.setPrecision( -1 ); v.setOrigin( name ); r.addValueMeta( v );
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; }
@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 ); } } }
v.setPrecision( fieldPrecision );
@Override public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // Add new field? for ( int i = 0; i < fieldOutStream.length; i++ ) { if ( !Utils.isEmpty( fieldOutStream[i] ) ) { int index = inputRowMeta.indexOfValue( fieldInStream[i] ); if ( index >= 0 ) { ValueMetaInterface in = inputRowMeta.getValueMeta( index ); try { ValueMetaInterface v = ValueMetaFactory.createValueMeta( space.environmentSubstitute( fieldOutStream[i] ), in.getType() ); v.setName( space.environmentSubstitute( fieldOutStream[i] ) ); v.setLength( in.getLength() ); v.setPrecision( in.getPrecision() ); v.setConversionMask( in.getConversionMask() ); v.setOrigin( name ); inputRowMeta.addValueMeta( v ); } catch ( Exception e ) { throw new KettleStepException( e ); } } } } }
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; }
folderName.setPrecision( -1 ); folderName.setOrigin( name ); row.addValueMeta( folderName ); short_folderName.setPrecision( -1 ); short_folderName.setOrigin( name ); row.addValueMeta( short_folderName ); path.setPrecision( -1 ); path.setOrigin( name ); row.addValueMeta( path );
v.setPrecision( field.getPrecision() ); v.setOrigin( name ); v.setConversionMask( field.getFormat() ); ValueMetaInterface v = new ValueMetaString( space.environmentSubstitute( filenameField ) ); v.setLength( 250 ); v.setPrecision( -1 ); v.setOrigin( name ); r.addValueMeta( v );
v.setPrecision( -1 ); break;
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; }
ValueMetaInterface v = new ValueMetaString( space.environmentSubstitute( filenameField ) ); v.setLength( 250 ); v.setPrecision( -1 ); v.setOrigin( name ); rowMeta.addValueMeta( v );
@Override public void readRep( Repository rep, ObjectId id_step, List<DatabaseMeta> databases, Map<String, Counter> counters ) throws KettleException { try { String name = rep.getStepAttributeString( id_step, 0, "value_name" ); String typedesc = rep.getStepAttributeString( id_step, 0, "value_type" ); String text = rep.getStepAttributeString( id_step, 0, "value_text" ); boolean isnull = rep.getStepAttributeBoolean( id_step, 0, "value_null" ); int length = (int) rep.getStepAttributeInteger( id_step, 0, "value_length" ); int precision = (int) rep.getStepAttributeInteger( id_step, 0, "value_precision" ); int type = ValueMetaFactory.getIdForValueMeta( typedesc ); value = new ValueMetaAndData( new ValueMeta( name, type ), null ); value.getValueMeta().setLength( length ); value.getValueMeta().setPrecision( precision ); if ( isnull ) { value.setValueData( null ); } else { ValueMetaInterface stringMeta = new ValueMetaString( name ); if ( type != ValueMetaInterface.TYPE_STRING ) { text = Const.trim( text ); } value.setValueData( value.getValueMeta().convertData( stringMeta, text ) ); } } catch ( KettleDatabaseException dbe ) { throw new KettleException( "error reading step with id_step=" + id_step + " from the repository", dbe ); } catch ( Exception e ) { throw new KettleException( "Unexpected error reading step with id_step=" + id_step + " from the repository", e ); } }
@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 ); } } }
valueMeta.setTrimType( field.getTrimType() ); valueMeta.setLength( field.getLength() ); valueMeta.setPrecision( field.getPrecision() ); valueMeta.setConversionMask( field.getFormat() ); valueMeta.setDecimalSymbol( field.getDecimal() );