@Override public void setDefault() { value = new ValueMetaAndData( new ValueMetaNumber( "valuename" ), new Double( 123.456 ) ); value.getValueMeta().setLength( 12 ); value.getValueMeta().setPrecision( 4 ); }
@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 ); } }
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 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(); } } } );
@Override public void loadXML( Node stepnode, List<DatabaseMeta> databases, Map<String, Counter> counters ) throws KettleXMLException { try { value = new ValueMetaAndData(); Node valnode = XMLHandler.getSubNode( stepnode, "values", "value" ); if ( valnode != null ) { System.out.println( "reading value in " + valnode ); value.loadXML( valnode ); } } catch ( Exception e ) { throw new KettleXMLException( "Unable to read step info from XML node", 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 ); } }
@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 ); } }
try { v = new ValueMetaAndData( ValueMetaFactory.createValueMeta( "constant", leftval.getType() ), null ); } catch ( Exception exception ) { v = new ValueMetaAndData( new ValueMetaString( "constant" ), null ); 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
ValueMetaAndData valueMetaData = new ValueMetaAndData(); valueMetaData.setValueMeta( sourceValueMeta ); if ( o != null ) { valueMetaData.setValueData( o );
@Override public Object clone() { ValueMetaAndData vmad = new ValueMetaAndData(); try { vmad.valueData = valueMeta.cloneValueData( valueData ); } catch ( KettleValueException e ) { vmad.valueData = null; // TODO: should we really do this? Is it safe? } vmad.valueMeta = valueMeta.clone(); return vmad; }
/** * 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; }
/** * Test the entered value * */ public void test() { try { ValueMetaAndData v = getValue( valueMeta.getName() ); MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_INFORMATION ); StringBuilder result = new StringBuilder(); result.append( Const.CR ).append( Const.CR ).append( " " ).append( v.toString() ); result.append( Const.CR ).append( " " ).append( v.toStringMeta() ); mb.setMessage( BaseMessages.getString( PKG, "EnterValueDialog.TestResult.Message", result.toString() ) ); mb.setText( BaseMessages.getString( PKG, "EnterValueDialog.TestResult.Title" ) ); mb.open(); } catch ( KettleValueException e ) { new ErrorDialog( shell, "Error", "There was an error during data type conversion: ", e ); } }
@Override public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (DummyPluginMeta) smi; data = (DummyPluginData) sdi; Object[] r = getRow(); // get row, blocks when needed! 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 ); } Object extraValue = meta.getValue().getValueData(); Object[] outputRow = RowDataUtil.addValueData( r, data.outputRowMeta.size() - 1, extraValue ); putRow( data.outputRowMeta, outputRow ); // copy row to possible alternate rowset(s). if ( checkFeedback( getLinesRead() ) ) { logBasic( "Linenr " + getLinesRead() ); // Some basic logging every 5000 rows. } return true; }
public String getRightExactString() { if ( right_exact == null ) { return null; } return right_exact.toString(); }
@Override public String getXML() throws KettleException { String retval = ""; retval += " <values>" + Const.CR; if ( value != null ) { retval += value.getXML(); } retval += " </values>" + Const.CR; return retval; }
/** * Construct a new Value and read the data from XML * * @param valnode * The XML Node to read from. */ public ValueMetaAndData( Node valnode ) { this(); loadXML( valnode ); }
@Override public Object clone() { Condition retval = null; retval = new Condition(); retval.negate = negate; retval.operator = operator; if ( isComposite() ) { for ( int i = 0; i < nrConditions(); i++ ) { Condition c = getCondition( i ); Condition cCopy = (Condition) c.clone(); retval.addCondition( cCopy ); } } else { retval.negate = negate; retval.left_valuename = left_valuename; retval.operator = operator; retval.right_valuename = right_valuename; retval.function = function; if ( right_exact != null ) { retval.right_exact = (ValueMetaAndData) right_exact.clone(); } else { retval.right_exact = null; } } return retval; }
public ValueMetaAndData loadValueMetaAndData( ObjectId id_value ) throws KettleException { ValueMetaAndData valueMetaAndData = new ValueMetaAndData(); try { RowMetaAndData r = getValue( id_value ); boolean isNull = r.getBoolean( KettleDatabaseRepository.FIELD_VALUE_IS_NULL, false ); ValueMetaInterface v = ValueMetaFactory.createValueMeta( name, valtype ); valueMetaAndData.setValueMeta( v ); valueMetaAndData.setValueData( null ); } else { ValueMetaInterface stringValueMeta = new ValueMetaString( name ); ValueMetaInterface valueMeta = valueMetaAndData.getValueMeta(); stringValueMeta.setConversionMetadata( valueMeta ); valueMetaAndData.setValueData( stringValueMeta.convertDataUsingConversionMetaData( string ) );
Node exactnode = XMLHandler.getSubNode( condnode, ValueMetaAndData.XML_TAG ); if ( exactnode != null ) { ValueMetaAndData exact = new ValueMetaAndData( exactnode ); setRightExact( exact );
private void ok() { stepname = wStepname.getText(); // return value value.getValueMeta().setName( wValName.getText() ); input.setValue( value ); dispose(); } }