@Override public Object clone() { GetVariableMeta retval = (GetVariableMeta) super.clone(); int count = fieldDefinitions.length; retval.allocate( count ); for ( int i = 0; i < count; i++ ) { retval.getFieldDefinitions()[i] = fieldDefinitions[i].clone(); } return retval; }
@Override public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { readData( stepnode ); }
public void modifyText( ModifyEvent e ) { input.setChanged(); } };
public int get() { return meta.getFieldDefinitions()[0].getFieldPrecision(); } } );
@Test public void testGetValueMetaPlugin() throws KettleStepException { GetVariableMeta meta = new GetVariableMeta(); meta.setDefault(); FieldDefinition field = new FieldDefinition(); field.setFieldName( "outputField" ); field.setVariableString( String.valueOf( 2000000L ) ); field.setFieldType( ValueMetaInterface.TYPE_TIMESTAMP ); meta.setFieldDefinitions( new FieldDefinition[]{ field } ); RowMetaInterface rowMeta = new RowMeta(); meta.getFields( rowMeta, "stepName", null, null, new Variables(), null, null ); assertNotNull( rowMeta ); assertEquals( 1, rowMeta.size() ); assertEquals( "outputField", rowMeta.getFieldNames()[0] ); assertEquals( ValueMetaInterface.TYPE_TIMESTAMP, rowMeta.getValueMeta( 0 ).getType() ); assertTrue( rowMeta.getValueMeta( 0 ) instanceof ValueMetaTimestamp ); }
@Override public void modify( GetVariableMeta someMeta ) { someMeta.allocate( 5 ); }
meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); int fieldsLength = meta.getFieldDefinitions().length; data.extraData = new Object[fieldsLength]; for ( int i = 0; i < fieldsLength; i++ ) { String newValue = environmentSubstitute( meta.getFieldDefinitions()[i].getVariableString() ); if ( log.isDetailed() ) { logDetailed( "field [" + meta.getFieldDefinitions()[i].getFieldName() + "] has value [" + newValue + "]" );
changed = input.hasChanged(); wlFields.setLayoutData( fdlFields ); final int fieldsRows = input.getFieldDefinitions().length; input.setChanged( changed );
@Before public void setup() { setup( new GetVariableMeta() ); }
public String get() { return meta.getFieldDefinitions()[0].getCurrency(); } } );
@Override public void setDefault() { int count = 0; allocate( count ); for ( int i = 0; i < count; i++ ) { fieldDefinitions[i].setFieldName( "field" + i ); fieldDefinitions[i].setVariableString( "" ); } }
private void preview() { try { GetVariableMeta oneMeta = new GetVariableMeta(); getInfo( oneMeta );
public int get() { return meta.getFieldDefinitions()[0].getTrimType(); } } );
private void getInfo( GetVariableMeta input ) throws KettleException { stepname = wStepname.getText(); // return value // Table table = wFields.table; int count = wFields.nrNonEmpty(); input.allocate( count ); //CHECKSTYLE:Indentation:OFF for ( int i = 0; i < count; i++ ) { TableItem item = wFields.getNonEmpty( i ); FieldDefinition currentField = input.getFieldDefinitions()[i]; int index = 1; currentField.setFieldName( item.getText( index++ ) ); currentField.setVariableString( item.getText( index++ ) ); currentField.setFieldType( ValueMetaFactory.getIdForValueMeta( item.getText( index++ ) ) ); currentField.setFieldFormat( item.getText( index++ ) ); currentField.setFieldLength( Const.toInt( item.getText( index++ ), -1 ) ); currentField.setFieldPrecision( Const.toInt( item.getText( index++ ), -1 ) ); currentField.setCurrency( item.getText( index++ ) ); currentField.setDecimal( item.getText( index++ ) ); currentField.setGroup( item.getText( index++ ) ); currentField.setTrimType( ValueMetaString.getTrimTypeByDesc( item.getText( index++ ) ) ); } }
@Override public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { try { int nrfields = rep.countNrStepAttributes( id_step, "field_name" ); allocate( nrfields ); for ( int i = 0; i < nrfields; i++ ) { fieldDefinitions[i].setFieldName( rep.getStepAttributeString( id_step, i, "field_name" ) ); fieldDefinitions[i].setVariableString( rep.getStepAttributeString( id_step, i, "field_variable" ) ); fieldDefinitions[i].setFieldType( ValueMetaFactory.getIdForValueMeta( rep.getStepAttributeString( id_step, i, "field_type" ) ) ); fieldDefinitions[i].setFieldFormat( rep.getStepAttributeString( id_step, i, "field_format" ) ); fieldDefinitions[i].setCurrency( rep.getStepAttributeString( id_step, i, "field_currency" ) ); fieldDefinitions[i].setDecimal( rep.getStepAttributeString( id_step, i, "field_decimal" ) ); fieldDefinitions[i].setGroup( rep.getStepAttributeString( id_step, i, "field_group" ) ); fieldDefinitions[i].setFieldLength( (int) rep.getStepAttributeInteger( id_step, i, "field_length" ) ); fieldDefinitions[i].setFieldPrecision( (int) rep.getStepAttributeInteger( id_step, i, "field_precision" ) ); fieldDefinitions[i].setTrimType( ValueMetaString.getTrimTypeByCode( rep.getStepAttributeString( id_step, i, "field_trim_type" ) ) ); // Backward compatibility // int fieldType = fieldDefinitions[i].getFieldType(); if ( fieldType == ValueMetaInterface.TYPE_NONE ) { fieldDefinitions[i].setFieldType( ValueMetaInterface.TYPE_STRING ); } } } catch ( Exception e ) { throw new KettleException( "Unexpected error reading step information from the repository", e ); } }
private void cancel() { stepname = null; input.setChanged( changed ); dispose(); }
public String get() { return meta.getFieldDefinitions()[0].getFieldName(); } } );
private void readData( Node stepnode ) throws KettleXMLException { try { Node fields = XMLHandler.getSubNode( stepnode, "fields" ); int count = XMLHandler.countNodes( fields, "field" ); allocate( count ); for ( int i = 0; i < count; i++ ) { Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i ); fieldDefinitions[i].setFieldName( XMLHandler.getTagValue( fnode, "name" ) ); fieldDefinitions[i].setVariableString( XMLHandler.getTagValue( fnode, "variable" ) ); fieldDefinitions[i].setFieldType( ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( fnode, "type" ) ) ); fieldDefinitions[i].setFieldFormat( XMLHandler.getTagValue( fnode, "format" ) ); fieldDefinitions[i].setCurrency( XMLHandler.getTagValue( fnode, "currency" ) ); fieldDefinitions[i].setDecimal( XMLHandler.getTagValue( fnode, "decimal" ) ); fieldDefinitions[i].setGroup( XMLHandler.getTagValue( fnode, "group" ) ); fieldDefinitions[i].setFieldLength( Const.toInt( XMLHandler.getTagValue( fnode, "length" ), -1 ) ); fieldDefinitions[i].setFieldPrecision( Const.toInt( XMLHandler.getTagValue( fnode, "precision" ), -1 ) ); fieldDefinitions[i].setTrimType( ValueMetaString.getTrimTypeByCode( XMLHandler.getTagValue( fnode, "trim_type" ) ) ); // Backward compatibility // if ( fieldDefinitions[i].getFieldType() == ValueMetaInterface.TYPE_NONE ) { fieldDefinitions[i].setFieldType( ValueMetaInterface.TYPE_STRING ); } } } catch ( Exception e ) { throw new KettleXMLException( "Unable to read step information from XML", e ); } }
public String get() { return meta.getFieldDefinitions()[0].getGroup(); } } );
public String get() { return meta.getFieldDefinitions()[0].getVariableString(); } } );