@Override public int string2intPrimitive( String v ) throws KettleValueException { return ValueMetaFactory.getIdForValueMeta( v ); } }
public ValueMetaInterface createValueMeta() throws KettlePluginException { return ValueMetaFactory.createValueMeta( name, type, length, precision ); }
public static final String getUpdateTypeCode( boolean upd, int t ) { if ( !upd ) { return ValueMetaFactory.getValueMetaName( t ); } else { return typeCodes[t]; } }
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; }
@Before public void setup() throws KettlePluginException { rowMeta = spy( new RowMeta() ); groupByMeta = spy( new GroupByMeta() ); mockStatic( ValueMetaFactory.class ); when( ValueMetaFactory.createValueMeta( anyInt() ) ).thenCallRealMethod(); when( ValueMetaFactory.createValueMeta( anyString(), anyInt() ) ).thenCallRealMethod(); when( ValueMetaFactory.createValueMeta( "maxDate", 3, -1, -1 ) ).thenReturn( new ValueMetaDate( "maxDate" ) ); when( ValueMetaFactory.createValueMeta( "minDate", 3, -1, -1 ) ).thenReturn( new ValueMetaDate( "minDate" ) ); when( ValueMetaFactory.createValueMeta( "countDate", 5, -1, -1 ) ).thenReturn( new ValueMetaInteger( "countDate" ) ); when( ValueMetaFactory.getValueMetaName( 3 ) ).thenReturn( "Date" ); when( ValueMetaFactory.getValueMetaName( 5 ) ).thenReturn( "Integer" ); }
@Override public TextFileField getTestObject() { String name = UUID.randomUUID().toString(); int type = ValueMetaFactory.getIdForValueMeta( ValueMetaFactory.getValueMetaNames()[rand.nextInt( ValueMetaFactory .getValueMetaNames().length )] ); String format = UUID.randomUUID().toString(); int length = Math.abs( rand.nextInt() ); int precision = Math.abs( rand.nextInt() ); String currencySymbol = UUID.randomUUID().toString(); String decimalSymbol = UUID.randomUUID().toString(); String groupSymbol = UUID.randomUUID().toString(); String nullString = UUID.randomUUID().toString(); return new TextFileField( name, type, format, length, precision, currencySymbol, decimalSymbol, groupSymbol, nullString ); }
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 ); } }
public static ValueMetaInterface cloneValueMeta( ValueMetaInterface source, int targetType ) throws KettlePluginException { ValueMetaInterface target = null; // If we're Cloneable and not changing types, call clone() if ( source.getType() == targetType ) { target = source.clone(); } else { target = createValueMeta( source.getName(), targetType, source.getLength(), source.getPrecision() ); } cloneInfo( source, target ); return target; }
protected ValueMetaInterface cloneValueMeta( ValueMetaInterface valueMeta, int type ) throws KettlePluginException { return ValueMetaFactory.cloneValueMeta( valueMeta, type ); }
/** * get an array of String describing the possible types a Value can have. * * @return an array of String describing the possible types a Value can have. */ public static final String[] getTypes() { return ValueMetaFactory.getValueMetaNames(); /* * String retval[] = new String[typeCodes.length - 1]; System.arraycopy(typeCodes, 1, retval, 0, typeCodes.length - * 1); return retval; */ }
/** * Get an array of String describing the possible types a Value can have. * * @return an array of String describing the possible types a Value can have. */ public static final String[] getAllTypes() { return ValueMetaFactory.getAllValueMetaNames(); /* * String retval[] = new String[typeCodes.length]; System.arraycopy(typeCodes, 0, retval, 0, typeCodes.length); * return retval; */ }
/** * @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; }
@Before public void setup() throws KettlePluginException { mockSpace = mock( VariableSpace.class ); doReturn("N" ).when( mockSpace ).getVariable( any(), anyString() ); rowMeta = spy( new RowMeta() ); memoryGroupByMeta = spy( new MemoryGroupByMeta() ); mockStatic( ValueMetaFactory.class ); when( ValueMetaFactory.createValueMeta( anyInt() ) ).thenCallRealMethod(); when( ValueMetaFactory.createValueMeta( anyString(), anyInt() ) ).thenCallRealMethod(); when( ValueMetaFactory.createValueMeta( "maxDate", 3, -1, -1 ) ).thenReturn( new ValueMetaDate( "maxDate" ) ); when( ValueMetaFactory.createValueMeta( "minDate", 3, -1, -1 ) ).thenReturn( new ValueMetaDate( "minDate" ) ); when( ValueMetaFactory.createValueMeta( "countDate", 5, -1, -1 ) ).thenReturn( new ValueMetaInteger( "countDate" ) ); when( ValueMetaFactory.getValueMetaName( 3 ) ).thenReturn( "Date" ); when( ValueMetaFactory.getValueMetaName( 5 ) ).thenReturn( "Integer" ); }
@Override public TextFileField getTestObject() { String name = UUID.randomUUID().toString(); int type = ValueMetaFactory.getIdForValueMeta( ValueMetaFactory.getValueMetaNames()[rand.nextInt( ValueMetaFactory .getValueMetaNames().length )] ); String format = UUID.randomUUID().toString(); int length = Math.abs( rand.nextInt() ); int precision = Math.abs( rand.nextInt() ); String currencySymbol = UUID.randomUUID().toString(); String decimalSymbol = UUID.randomUUID().toString(); String groupSymbol = UUID.randomUUID().toString(); String nullString = UUID.randomUUID().toString(); return new TextFileField( name, type, format, length, precision, currencySymbol, decimalSymbol, groupSymbol, nullString ); }
/** * Create a new row metadata object from XML * * @param node the XML node to deserialize from * @throws IOException Thrown in case there is an (Base64/GZip) decoding problem */ public RowMeta( Node node ) throws KettleException { this(); int nrValues = XMLHandler.countNodes( node, ValueMeta.XML_META_TAG ); for ( int i = 0; i < nrValues; i++ ) { ValueMeta valueMetaSource = new ValueMeta( XMLHandler.getSubNodeByNr( node, ValueMeta.XML_META_TAG, i ) ); ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( valueMetaSource.getName(), valueMetaSource.getType(), valueMetaSource.getLength(), valueMetaSource.getPrecision() ); ValueMetaFactory.cloneInfo( valueMetaSource, valueMeta ); addValueMeta( valueMeta ); } }
public static ValueMetaInterface cloneValueMeta( ValueMetaInterface source ) throws KettlePluginException { return cloneValueMeta( source, source.getType() ); }
@Override public JaninoMetaFunction getTestObject() { Random random = new Random(); return new JaninoMetaFunction( UUID.randomUUID().toString(), UUID.randomUUID().toString(), random.nextInt( ValueMetaFactory.getAllValueMetaNames().length ), random.nextInt( Integer.MAX_VALUE ), random.nextInt( Integer.MAX_VALUE ), UUID.randomUUID().toString() ); }
@Override public int string2intPrimitive( String v ) throws KettleValueException { return ValueMetaFactory.getIdForValueMeta( v ); } }
public static ValueMetaInterface createValueMeta( int type ) throws KettlePluginException { return createValueMeta( null, type, -1, -1 ); }
/** * TODO: change Desc to Code all over the place. Make sure we can localise this stuff later on. * * @param type * the type * @return the description (code) of the type */ public static final String getTypeDesc( int type ) { return ValueMetaFactory.getValueMetaName( type ); // return typeCodes[type]; }