/** * Returns kettle type from Microsoft Access database * * @param : MS Access column * @return valuemeta */ public static ValueMetaInterface getValueMeta( Column c ) { // get value ValueMetaAndData vmd = getValueMetaAndData( c, null, null ); if ( vmd != null ) { // returns meta return vmd.getValueMeta(); } return null; }
@Override public void setDefault() { value = new ValueMetaAndData( new ValueMetaNumber( "valuename" ), new Double( 123.456 ) ); value.getValueMeta().setLength( 12 ); value.getValueMeta().setPrecision( 4 ); }
private void ok() { stepname = wStepname.getText(); // return value value.getValueMeta().setName( wValName.getText() ); input.setValue( value ); dispose(); } }
@Override public void getFields( RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space ) { if ( value != null ) { ValueMetaInterface v = value.getValueMeta(); v.setOrigin( origin ); r.addValueMeta( v ); } }
public void getData() { wStepname.selectAll(); if ( value != null ) { wValName.setText( value.getValueMeta().getName() ); wValue.setText( value.toString() + " (" + value.toStringMeta() + ")" ); //$NON-NLS-1$ //$NON-NLS-2$ } }
@Override public void saveRep( Repository rep, ObjectId id_transformation, ObjectId id_step ) throws KettleException { try { rep.saveStepAttribute( id_transformation, id_step, "value_name", value.getValueMeta().getName() ); rep.saveStepAttribute( id_transformation, id_step, 0, "value_type", value.getValueMeta().getTypeDesc() ); rep.saveStepAttribute( id_transformation, id_step, 0, "value_text", value.getValueMeta().getString( value.getValueData() ) ); rep.saveStepAttribute( id_transformation, id_step, 0, "value_null", value.getValueMeta().isNull( value.getValueData() ) ); rep.saveStepAttribute( id_transformation, id_step, 0, "value_length", value.getValueMeta().getLength() ); rep.saveStepAttribute( id_transformation, id_step, 0, "value_precision", value.getValueMeta().getPrecision() ); } catch ( KettleDatabaseException dbe ) { throw new KettleException( "Unable to save step information to the repository, id_step=" + id_step, dbe ); } }
@Override public void widgetSelected( SelectionEvent arg0 ) { ValueMetaAndData v = (ValueMetaAndData) value.clone(); EnterValueDialog evd = new EnterValueDialog( shell, SWT.NONE, v.getValueMeta(), v.getValueData() ); ValueMetaAndData newval = evd.open(); if ( newval != null ) { value = newval; getData(); } } } );
private Object convert( Object obj, AccessInputField field, int index ) throws Exception { // Get column Column c = data.t.getColumn( field.getColumn() ); // Find out field type ValueMetaAndData sourceValueMetaAndData = AccessInputMeta.getValueMetaAndData( c, field.getName(), obj ); // DO CONVERSIONS... // ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( data.totalpreviousfields + index ); return targetValueMeta.convertData( sourceValueMetaAndData.getValueMeta(), sourceValueMetaAndData .getValueData() ); } }
@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 ); } }
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 fieldMeta2 = right_exact != null ? right_exact.getValueMeta() : null; Object field2 = right_exact != null ? right_exact.getValueData() : null; if ( field2 == null && right_fieldnr >= 0 ) {
} else { ValueMetaInterface stringValueMeta = new ValueMetaString( name ); ValueMetaInterface valueMeta = valueMetaAndData.getValueMeta(); stringValueMeta.setConversionMetadata( valueMeta );
ValueMetaInterface valueMeta = v.getValueMeta(); valueMeta.setDecimalSymbol( ValueMetaAndData.VALUE_REPOSITORY_DECIMAL_SYMBOL ); valueMeta.setGroupingSymbol( ValueMetaAndData.VALUE_REPOSITORY_GROUPING_SYMBOL );
ValueMetaAndData v = condition.getRightExact(); if ( v != null ) { stype = " (" + v.getValueMeta().getTypeDesc() + ")";
EnterValueDialog evd = new EnterValueDialog( shell, SWT.NONE, v.getValueMeta(), v.getValueData() ); evd.setModalDialog( true ); // To keep the condition editor from being closed with a value dialog still