@Test public void testPDI16368() throws Exception { StepMockHelper<SelectValuesMeta, StepDataInterface> helper = StepMockUtil.getStepMockHelper( SelectValuesMeta.class, "SelectValuesTest2" ); SelectValuesHandler step2 = null; Object[] inputRow2 = null; RowMeta inputRowMeta = null; SelectValuesMeta stepMeta = null; SelectValuesData stepData = null; ValueMetaInterface vmi = null; step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2 = spy( step2 ); inputRow2 = new Object[] { new BigDecimal( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_INTEGER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2 = spy( step2 ); doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_NUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2 = spy( step2 ); inputRow2 = new Object[] { new Long( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaInteger( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_BIGNUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_INTEGER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2.setVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y" ); step2 = spy( step2 ); inputRow2 = new Object[] { new BigDecimal( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_INTEGER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_INTEGER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2.setVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y" ); step2 = spy( step2 ); doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_NUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2.setVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y" ); step2 = spy( step2 ); inputRow2 = new Object[] { new Long( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaInteger( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_BIGNUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); }
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SelectValuesMeta) smi; data = (SelectValuesData) sdi; Object[] rowData = getRow(); if ( rowData == null ) { setOutputDone(); return false; } Object[] rowCopy = null; if ( getStepMeta().isDoingErrorHandling() ) { rowCopy = getInputRowMeta().cloneRow( rowData ); } if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.GotRowFromPreviousStep" ) + getInputRowMeta().getString( rowData ) ); } if ( first ) { first = false; data.selectRowMeta = getInputRowMeta().clone(); meta.getSelectFields( data.selectRowMeta, getStepname() ); data.deselectRowMeta = data.selectRowMeta.clone(); meta.getDeleteFields( data.deselectRowMeta ); data.metadataRowMeta = data.deselectRowMeta.clone(); meta.getMetadataFields( data.metadataRowMeta, getStepname(), this ); } try { Object[] outputData = rowData; if ( data.select ) { outputData = selectValues( getInputRowMeta(), outputData ); } if ( data.deselect ) { outputData = removeValues( data.selectRowMeta, outputData ); } if ( data.metadata ) { outputData = metadataValues( data.deselectRowMeta, outputData ); } if ( outputData == null ) { setOutputDone(); return false; } putRow( data.metadataRowMeta, outputData ); if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.WroteRowToNextStep" ) + data.metadataRowMeta.getString( outputData ) ); } } catch ( KettleException e ) { if ( getStepMeta().isDoingErrorHandling() ) { String field; if ( e instanceof KettleConversionException ) { List<ValueMetaInterface> fields = ( (KettleConversionException) e ).getFields(); field = fields.isEmpty() ? null : fields.get( 0 ).getName(); } else { field = null; } putError( getInputRowMeta(), rowCopy, 1, e.getMessage(), field, "SELECT001" ); } else { throw e; } } if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "SelectValues.Log.LineNumber" ) + getLinesRead() ); } return true; }
SelectValues extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SelectValuesMeta) smi; data = (SelectValuesData) sdi; Object[] rowData = getRow(); if ( rowData == null ) { setOutputDone(); return false; } Object[] rowCopy = null; if ( getStepMeta().isDoingErrorHandling() ) { rowCopy = getInputRowMeta().cloneRow( rowData ); } if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.GotRowFromPreviousStep" ) + getInputRowMeta().getString( rowData ) ); } if ( first ) { first = false; data.selectRowMeta = getInputRowMeta().clone(); meta.getSelectFields( data.selectRowMeta, getStepname() ); data.deselectRowMeta = data.selectRowMeta.clone(); meta.getDeleteFields( data.deselectRowMeta ); data.metadataRowMeta = data.deselectRowMeta.clone(); meta.getMetadataFields( data.metadataRowMeta, getStepname(), this ); } try { Object[] outputData = rowData; if ( data.select ) { outputData = selectValues( getInputRowMeta(), outputData ); } if ( data.deselect ) { outputData = removeValues( data.selectRowMeta, outputData ); } if ( data.metadata ) { outputData = metadataValues( data.deselectRowMeta, outputData ); } if ( outputData == null ) { setOutputDone(); return false; } putRow( data.metadataRowMeta, outputData ); if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.WroteRowToNextStep" ) + data.metadataRowMeta.getString( outputData ) ); } } catch ( KettleException e ) { if ( getStepMeta().isDoingErrorHandling() ) { String field; if ( e instanceof KettleConversionException ) { List<ValueMetaInterface> fields = ( (KettleConversionException) e ).getFields(); field = fields.isEmpty() ? null : fields.get( 0 ).getName(); } else { field = null; } putError( getInputRowMeta(), rowCopy, 1, e.getMessage(), field, "SELECT001" ); } else { throw e; } } if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "SelectValues.Log.LineNumber" ) + getLinesRead() ); } return true; } }
SelectValues extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SelectValuesMeta) smi; data = (SelectValuesData) sdi; Object[] rowData = getRow(); if ( rowData == null ) { setOutputDone(); return false; } Object[] rowCopy = null; if ( getStepMeta().isDoingErrorHandling() ) { rowCopy = getInputRowMeta().cloneRow( rowData ); } if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.GotRowFromPreviousStep" ) + getInputRowMeta().getString( rowData ) ); } if ( first ) { first = false; data.selectRowMeta = getInputRowMeta().clone(); meta.getSelectFields( data.selectRowMeta, getStepname() ); data.deselectRowMeta = data.selectRowMeta.clone(); meta.getDeleteFields( data.deselectRowMeta ); data.metadataRowMeta = data.deselectRowMeta.clone(); meta.getMetadataFields( data.metadataRowMeta, getStepname(), this ); } try { Object[] outputData = rowData; if ( data.select ) { outputData = selectValues( getInputRowMeta(), outputData ); } if ( data.deselect ) { outputData = removeValues( data.selectRowMeta, outputData ); } if ( data.metadata ) { outputData = metadataValues( data.deselectRowMeta, outputData ); } if ( outputData == null ) { setOutputDone(); return false; } putRow( data.metadataRowMeta, outputData ); if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.WroteRowToNextStep" ) + data.metadataRowMeta.getString( outputData ) ); } } catch ( KettleException e ) { if ( getStepMeta().isDoingErrorHandling() ) { String field; if ( e instanceof KettleConversionException ) { List<ValueMetaInterface> fields = ( (KettleConversionException) e ).getFields(); field = fields.isEmpty() ? null : fields.get( 0 ).getName(); } else { field = null; } putError( getInputRowMeta(), rowCopy, 1, e.getMessage(), field, "SELECT001" ); } else { throw e; } } if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "SelectValues.Log.LineNumber" ) + getLinesRead() ); } return true; } SelectValues( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
                       Trans trans ); }
SelectValues extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SelectValuesMeta) smi; data = (SelectValuesData) sdi; Object[] rowData = getRow(); if ( rowData == null ) { setOutputDone(); return false; } Object[] rowCopy = null; if ( getStepMeta().isDoingErrorHandling() ) { rowCopy = getInputRowMeta().cloneRow( rowData ); } if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.GotRowFromPreviousStep" ) + getInputRowMeta().getString( rowData ) ); } if ( first ) { first = false; data.selectRowMeta = getInputRowMeta().clone(); meta.getSelectFields( data.selectRowMeta, getStepname() ); data.deselectRowMeta = data.selectRowMeta.clone(); meta.getDeleteFields( data.deselectRowMeta ); data.metadataRowMeta = data.deselectRowMeta.clone(); meta.getMetadataFields( data.metadataRowMeta, getStepname(), this ); } try { Object[] outputData = rowData; if ( data.select ) { outputData = selectValues( getInputRowMeta(), outputData ); } if ( data.deselect ) { outputData = removeValues( data.selectRowMeta, outputData ); } if ( data.metadata ) { outputData = metadataValues( data.deselectRowMeta, outputData ); } if ( outputData == null ) { setOutputDone(); return false; } putRow( data.metadataRowMeta, outputData ); if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.WroteRowToNextStep" ) + data.metadataRowMeta.getString( outputData ) ); } } catch ( KettleException e ) { if ( getStepMeta().isDoingErrorHandling() ) { String field; if ( e instanceof KettleConversionException ) { List<ValueMetaInterface> fields = ( (KettleConversionException) e ).getFields(); field = fields.isEmpty() ? null : fields.get( 0 ).getName(); } else { field = null; } putError( getInputRowMeta(), rowCopy, 1, e.getMessage(), field, "SELECT001" ); } else { throw e; } } if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "SelectValues.Log.LineNumber" ) + getLinesRead() ); } return true; } SelectValues( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
                       Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); }
SelectValues extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SelectValuesMeta) smi; data = (SelectValuesData) sdi; Object[] rowData = getRow(); if ( rowData == null ) { setOutputDone(); return false; } Object[] rowCopy = null; if ( getStepMeta().isDoingErrorHandling() ) { rowCopy = getInputRowMeta().cloneRow( rowData ); } if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.GotRowFromPreviousStep" ) + getInputRowMeta().getString( rowData ) ); } if ( first ) { first = false; data.selectRowMeta = getInputRowMeta().clone(); meta.getSelectFields( data.selectRowMeta, getStepname() ); data.deselectRowMeta = data.selectRowMeta.clone(); meta.getDeleteFields( data.deselectRowMeta ); data.metadataRowMeta = data.deselectRowMeta.clone(); meta.getMetadataFields( data.metadataRowMeta, getStepname(), this ); } try { Object[] outputData = rowData; if ( data.select ) { outputData = selectValues( getInputRowMeta(), outputData ); } if ( data.deselect ) { outputData = removeValues( data.selectRowMeta, outputData ); } if ( data.metadata ) { outputData = metadataValues( data.deselectRowMeta, outputData ); } if ( outputData == null ) { setOutputDone(); return false; } putRow( data.metadataRowMeta, outputData ); if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.WroteRowToNextStep" ) + data.metadataRowMeta.getString( outputData ) ); } } catch ( KettleException e ) { if ( getStepMeta().isDoingErrorHandling() ) { String field; if ( e instanceof KettleConversionException ) { List<ValueMetaInterface> fields = ( (KettleConversionException) e ).getFields(); field = fields.isEmpty() ? null : fields.get( 0 ).getName(); } else { field = null; } putError( getInputRowMeta(), rowCopy, 1, e.getMessage(), field, "SELECT001" ); } else { throw e; } } if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "SelectValues.Log.LineNumber" ) + getLinesRead() ); } return true; } SelectValues( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
                       Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi );  }