Java Code Examples for org.pentaho.di.core.row.value.ValueMetaFactory#createValueMeta()
The following examples show how to use
org.pentaho.di.core.row.value.ValueMetaFactory#createValueMeta() .
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: SapInputMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { row.clear(); // TODO: add an option to also include the input data... for ( SapOutputField field : outputFields ) { try { ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( field.getNewName(), field.getTargetType() ); valueMeta.setOrigin( origin ); row.addValueMeta( valueMeta ); } catch ( Exception e ) { throw new KettleStepException( e ); } } }
Example 2
Source File: JsonRowMeta.java From kettle-beam with Apache License 2.0 | 6 votes |
public static RowMetaInterface fromJson(String rowMetaJson) throws ParseException, KettlePluginException { JSONParser parser = new JSONParser(); JSONObject jRowMeta = (JSONObject) parser.parse( rowMetaJson ); RowMetaInterface rowMeta = new RowMeta( ); JSONArray jValues = (JSONArray) jRowMeta.get("values"); for (int v=0;v<jValues.size();v++) { JSONObject jValue = (JSONObject) jValues.get( v ); String name = (String) jValue.get("name"); long type = (long)jValue.get("type"); long length = (long)jValue.get("length"); long precision = (long)jValue.get("precision"); String conversionMask = (String) jValue.get("conversionMask"); ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( name, (int)type, (int)length, (int)precision ); valueMeta.setConversionMask( conversionMask ); rowMeta.addValueMeta( valueMeta ); } return rowMeta; }
Example 3
Source File: GetPreviousRowFieldMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@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 ); } } } } }
Example 4
Source File: RulesAccumulatorMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public void readRep( Repository rep, IMetaStore metaStore, ObjectId idStep, List<DatabaseMeta> _databases ) throws KettleException { int nrfields = rep.countNrStepAttributes( idStep, StorageKeys.COLUMN_NAME.toString() ); ValueMetaInterface vm = null; for ( int i = 0; i < nrfields; i++ ) { String name = rep.getStepAttributeString( idStep, i, StorageKeys.COLUMN_NAME.toString() ); int type = ValueMeta.getType( rep.getStepAttributeString( idStep, i, StorageKeys.COLUMN_TYPE.toString() ) ); vm = ValueMetaFactory.createValueMeta( name, type ); getRuleResultColumns().add( vm ); } setRuleFile( rep.getStepAttributeString( idStep, StorageKeys.RULE_FILE.toString() ) ); setRuleDefinition( rep.getStepAttributeString( idStep, StorageKeys.RULE_DEFINITION.toString() ) ); }
Example 5
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 6
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 7
Source File: RowMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void testSwapNames() throws KettlePluginException { ValueMetaInterface string2 = ValueMetaFactory.createValueMeta( "string2", ValueMetaInterface.TYPE_STRING ); rowMeta.addValueMeta( string2 ); assertSame( string, rowMeta.searchValueMeta( "string" ) ); assertSame( string2, rowMeta.searchValueMeta( "string2" ) ); string.setName( "string2" ); string2.setName( "string" ); assertSame( string2, rowMeta.searchValueMeta( "string" ) ); assertSame( string, rowMeta.searchValueMeta( "string2" ) ); }
Example 8
Source File: RowMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { string = ValueMetaFactory.createValueMeta( "string", ValueMetaInterface.TYPE_STRING ); rowMeta.addValueMeta( string ); integer = ValueMetaFactory.createValueMeta( "integer", ValueMetaInterface.TYPE_INTEGER ); rowMeta.addValueMeta( integer ); date = ValueMetaFactory.createValueMeta( "date", ValueMetaInterface.TYPE_DATE ); rowMeta.addValueMeta( date ); charly = ValueMetaFactory.createValueMeta( "charly", ValueMetaInterface.TYPE_SERIALIZABLE ); dup = ValueMetaFactory.createValueMeta( "dup", ValueMetaInterface.TYPE_SERIALIZABLE ); bin = ValueMetaFactory.createValueMeta( "bin", ValueMetaInterface.TYPE_BINARY ); }
Example 9
Source File: SwitchCase.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * @see StepInterface#init(org.pentaho.di.trans.step.StepMetaInterface , org.pentaho.di.trans.step.StepDataInterface) */ public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (SwitchCaseMeta) smi; data = (SwitchCaseData) sdi; if ( !super.init( smi, sdi ) ) { return false; } data.outputMap = meta.isContains() ? new ContainsKeyToRowSetMap() : new KeyToRowSetMap(); if ( Utils.isEmpty( meta.getFieldname() ) ) { logError( BaseMessages.getString( PKG, "SwitchCase.Log.NoFieldSpecifiedToSwitchWith" ) ); return false; } try { data.valueMeta = ValueMetaFactory.createValueMeta( meta.getFieldname(), meta.getCaseValueType() ); data.valueMeta.setConversionMask( meta.getCaseValueFormat() ); data.valueMeta.setGroupingSymbol( meta.getCaseValueGroup() ); data.valueMeta.setDecimalSymbol( meta.getCaseValueDecimal() ); data.stringValueMeta = ValueMetaFactory.cloneValueMeta( data.valueMeta, ValueMetaInterface.TYPE_STRING ); } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "SwitchCase.Log.UnexpectedError", e ) ); } return true; }
Example 10
Source File: TransExecutorMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
protected void addFieldToRow( RowMetaInterface row, String fieldName, int type, int length, int precision ) throws KettleStepException { if ( !Utils.isEmpty( fieldName ) ) { try { ValueMetaInterface value = ValueMetaFactory.createValueMeta( fieldName, type, length, precision ); value.setOrigin( getParentStepMeta().getName() ); row.addValueMeta( value ); } catch ( KettlePluginException e ) { throw new KettleStepException( BaseMessages.getString( PKG, "TransExecutorMeta.ValueMetaInterfaceCreation", fieldName ), e ); } } }
Example 11
Source File: ValueMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public Class<?> getNativeDataTypeClass() throws KettleValueException { if ( nativeType == null ) { try { nativeType = ValueMetaFactory.createValueMeta( getType() ); } catch ( KettlePluginException e ) { throw new KettleValueException( e ); } } return nativeType.getNativeDataTypeClass(); }
Example 12
Source File: DataSet.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
/** * 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 13
Source File: RowMetaAndData.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void addValue( String valueName, int valueType, Object valueData ) { ValueMetaInterface v; try { v = ValueMetaFactory.createValueMeta( valueName, valueType ); } catch ( KettlePluginException e ) { v = new ValueMetaNone( valueName ); } addValue( v, valueData ); }
Example 14
Source File: CypherMeta.java From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 | 5 votes |
@Override public void getFields( RowMetaInterface rowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( usingUnwind ) { // Unwind only outputs results, not input // rowMeta.clear(); } if (returningGraph) { // We send out a single Graph value per input row // ValueMetaInterface valueMetaGraph = new ValueMetaGraph( Const.NVL(returnGraphField, "graph") ); valueMetaGraph.setOrigin( name ); rowMeta.addValueMeta( valueMetaGraph ); } else { // Check return values in the metadata... // for ( ReturnValue returnValue : returnValues ) { try { int type = ValueMetaFactory.getIdForValueMeta( returnValue.getType() ); ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( returnValue.getName(), type ); valueMeta.setOrigin( name ); rowMeta.addValueMeta( valueMeta ); } catch ( KettlePluginException e ) { throw new KettleStepException( "Unknown data type '" + returnValue.getType() + "' for value named '" + returnValue.getName() + "'" ); } } } }
Example 15
Source File: DatabaseJoinMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public RowMetaInterface getTableFields() { // Build a dummy parameter row... // RowMetaInterface param = new RowMeta(); for ( int i = 0; i < parameterField.length; i++ ) { ValueMetaInterface v; try { v = ValueMetaFactory.createValueMeta( parameterField[i], parameterType[i] ); } catch ( KettlePluginException e ) { v = new ValueMetaNone( parameterField[i] ); } param.addValueMeta( v ); } RowMetaInterface fields = null; if ( databaseMeta != null ) { Database db = new Database( loggingObject, databaseMeta ); databases = new Database[] { db }; // Keep track of this one for cancelQuery try { db.connect(); fields = db.getQueryFields( databaseMeta.environmentSubstitute( sql ), true, param, new Object[param.size()] ); } catch ( KettleDatabaseException dbe ) { logError( BaseMessages.getString( PKG, "DatabaseJoinMeta.Log.DatabaseErrorOccurred" ) + dbe.getMessage() ); } finally { db.disconnect(); } } return fields; }
Example 16
Source File: Janino.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (JaninoMeta) smi; data = (JaninoData) sdi; Object[] r = getRow(); // get row, set busy! if ( r == null ) { // no more input to be expected... setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); // Calculate replace indexes... // data.replaceIndex = new int[meta.getFormula().length]; data.returnType = new ValueMetaInterface[meta.getFormula().length]; for ( int i = 0; i < meta.getFormula().length; i++ ) { JaninoMetaFunction fn = meta.getFormula()[i]; data.returnType[i] = ValueMetaFactory.createValueMeta( fn.getValueType() ); if ( !Utils.isEmpty( fn.getReplaceField() ) ) { data.replaceIndex[i] = getInputRowMeta().indexOfValue( fn.getReplaceField() ); if ( data.replaceIndex[i] < 0 ) { throw new KettleException( "Unknown field specified to replace with a formula result: [" + fn.getReplaceField() + "]" ); } } else { data.replaceIndex[i] = -1; } } } if ( log.isRowLevel() ) { logRowlevel( "Read row #" + getLinesRead() + " : " + getInputRowMeta().getString( r ) ); } try { Object[] outputRowData = calcFields( getInputRowMeta(), r ); putRow( data.outputRowMeta, outputRowData ); // copy row to possible alternate rowset(s). if ( log.isRowLevel() ) { logRowlevel( "Wrote row #" + getLinesWritten() + " : " + data.outputRowMeta.getString( outputRowData ) ); } } catch ( Exception e ) { if ( getStepMeta().isDoingErrorHandling() ) { putError( getInputRowMeta(), r, 1L, e.toString(), null, "UJE001" ); } else { throw new KettleException( e ); } } if ( checkFeedback( getLinesRead() ) ) { logBasic( "Linenr " + getLinesRead() ); } return true; }
Example 17
Source File: ScriptValuesMetaMod.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void getFields( RowMetaInterface row, String originStepname, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { try { for ( int i = 0; i < fieldname.length; i++ ) { if ( !Utils.isEmpty( fieldname[i] ) ) { int valueIndex = -1; ValueMetaInterface v; if ( replace[i] ) { valueIndex = row.indexOfValue( fieldname[i] ); if ( valueIndex < 0 ) { // The field was not found using the "name" field if ( Utils.isEmpty( rename[i] ) ) { // There is no "rename" field to try; Therefore we cannot find the // field to replace throw new KettleStepException( BaseMessages.getString( PKG, "ScriptValuesMetaMod.Exception.FieldToReplaceNotFound", fieldname[i] ) ); } else { // Lookup the field to replace using the "rename" field valueIndex = row.indexOfValue( rename[i] ); if ( valueIndex < 0 ) { // The field was not found using the "rename" field"; Therefore // we cannot find the field to replace // throw new KettleStepException( BaseMessages.getString( PKG, "ScriptValuesMetaMod.Exception.FieldToReplaceNotFound", rename[i] ) ); } } } // Change the data type to match what's specified... // ValueMetaInterface source = row.getValueMeta( valueIndex ); v = ValueMetaFactory.cloneValueMeta( source, type[i] ); row.setValueMeta( valueIndex, v ); } else { if ( !Utils.isEmpty( rename[i] ) ) { v = ValueMetaFactory.createValueMeta( rename[i], type[i] ); } else { v = ValueMetaFactory.createValueMeta( fieldname[i], type[i] ); } } v.setLength( length[i] ); v.setPrecision( precision[i] ); v.setOrigin( originStepname ); if ( !replace[i] ) { row.addValueMeta( v ); } } } } catch ( KettleException e ) { throw new KettleStepException( e ); } }
Example 18
Source File: CPythonScriptExecutorMeta.java From pentaho-cpython-plugin with Apache License 2.0 | 4 votes |
@Override public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> dbs ) throws KettleException { String rowsToProcess = rep.getStepAttributeString( id_step, ROWS_TO_PROCESS_TAG ); setRowsToProcess( rowsToProcess == null ? "" : rowsToProcess ); String rowsToProcessSize = rep.getStepAttributeString( id_step, ROWS_TO_PROCESS_SIZE_TAG ); setRowsToProcessSize( rowsToProcess == null ? "" : rowsToProcessSize ); setDoingReservoirSampling( rep.getStepAttributeBoolean( id_step, RESERVOIR_SAMPLING_TAG ) ); String reservoirSamplingSize = rep.getStepAttributeString( id_step, RESERVOIR_SAMPLING_SIZE_TAG ); setReservoirSamplingSize( reservoirSamplingSize == null ? "" : reservoirSamplingSize ); setRandomSeed( rep.getStepAttributeString( id_step, RESERVOIR_SAMPLING_SEED_TAG ) ); setIncludeInputAsOutput( rep.getStepAttributeBoolean( id_step, INCLUDE_INPUT_AS_OUTPUT_TAG ) ); setIncludeFrameRowIndexAsOutputField( rep.getStepAttributeBoolean( id_step, INCLUDE_FRAME_ROW_INDEX_AS_OUTPUT_FIELD_TAG ) ); setScript( rep.getStepAttributeString( id_step, SCRIPT_TAG ) ); setLoadScriptAtRuntime( rep.getStepAttributeBoolean( id_step, LOAD_SCRIPT_AT_RUNTIME_TAG ) ); String scriptToLoad = rep.getStepAttributeString( id_step, SCRIPT_TO_LOAD_TAG ); setScriptToLoad( Const.isEmpty( scriptToLoad ) ? "" : scriptToLoad ); //$NON-NLS-1$ setContinueOnUnsetVars( rep.getStepAttributeBoolean( id_step, CONTINUE_ON_UNSET_VARS_TAG ) ); String pyVars = rep.getStepAttributeString( id_step, PY_VARS_TO_GET_TAG ); if ( !Const.isEmpty( pyVars ) ) { stringToVarList( pyVars ); } // frame names int numFields = rep.countNrStepAttributes( id_step, SINGLE_FRAME_NAME_PREFIX_TAG ); for ( int i = 0; i < numFields; i++ ) { m_frameNames.add( rep.getStepAttributeString( id_step, i, SINGLE_FRAME_NAME_PREFIX_TAG ) ); } // step names List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams(); for ( int i = 0; i < infoStreams.size(); i++ ) { infoStreams.get( i ).setSubject( rep.getStepAttributeString( id_step, i, SINGLE_INCOMING_STEP_NAME_TAG ) ); } // get outgoing fields numFields = rep.countNrStepAttributes( id_step, "field_name" ); //$NON-NLS-1$ if ( numFields > 0 ) { m_outputFields = new RowMeta(); for ( int i = 0; i < numFields; i++ ) { String name = rep.getStepAttributeString( id_step, i, "field_name" ); //$NON-NLS-1$ String type = rep.getStepAttributeString( id_step, i, "type" ); //$NON-NLS-1$ //ValueMetaInterface vm = new ValueMeta( name, ValueMeta.getType( type ) ); ValueMetaInterface vm = ValueMetaFactory.createValueMeta( name, ValueMetaFactory.getIdForValueMeta( type ) ); m_outputFields.addValueMeta( vm ); } } }
Example 19
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 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 ); } }