/** * Returns the fields that are emitted by a step. * * @param stepMeta * : The StepMeta object that's being queried * @param nextStep * : if non-null this is the next step that's call back to ask what's being sent * @param row * : A row containing the input fields or an empty row if no input is required. * @return A Row containing the output fields. * @throws KettleStepException * the kettle step exception */ public RowMetaInterface getThisStepFields( StepMeta stepMeta, StepMeta nextStep, RowMetaInterface row ) throws KettleStepException { return getThisStepFields( stepMeta, nextStep, row, null ); }
/** * Return the fields that are emitted by a step with a certain name. * * @param stepname * The name of the step that's being queried. * @param row * A row containing the input fields or an empty row if no input is required. * @return A Row containing the output fields. * @throws KettleStepException * the kettle step exception */ public RowMetaInterface getThisStepFields( String stepname, RowMetaInterface row ) throws KettleStepException { return getThisStepFields( findStep( stepname ), null, row ); }
@Test public void getThisStepFieldsPassesClonedInfoRowMeta() throws Exception { // given StepMetaInterface smi = mock( StepMetaInterface.class ); StepIOMeta ioMeta = mock( StepIOMeta.class ); when( smi.getStepIOMeta() ).thenReturn( ioMeta ); StepMeta thisStep = mockStepMeta( "thisStep" ); StepMeta nextStep = mockStepMeta( "nextStep" ); when( thisStep.getStepMetaInterface() ).thenReturn( smi ); RowMeta row = new RowMeta(); when( smi.getTableFields() ).thenReturn( row ); // when transMeta.getThisStepFields( thisStep, nextStep, row ); // then verify( smi, never() ).getFields( any(), any(), eq( new RowMetaInterface[] { row } ), any(), any(), any(), any() ); }
public Object[] getRow() throws KettleException { Object[] row = parent.getRowImpl(); if ( updateRowMeta ) { // Update data.inputRowMeta and data.outputRowMeta RowMetaInterface inputRowMeta = parent.getInputRowMeta(); data.inputRowMeta = inputRowMeta; data.outputRowMeta = inputRowMeta == null ? null : getTransMeta().getThisStepFields( getStepMeta(), null, inputRowMeta.clone() ); updateRowMeta = false; } return row; }
public void run() { StepMeta stepMeta = transMeta.findStep( stepname ); if ( stepMeta != null ) { try { inputRowMeta = transMeta.getPrevStepFields( stepMeta ); infoRowMeta = transMeta.getPrevInfoFields( stepMeta ); outputRowMeta = transMeta.getThisStepFields( stepMeta, null, inputRowMeta.clone() ); populateFieldsTree(); } catch ( KettleException e ) { log.logError( BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Message" ), e ); } } } };
data.outputRowMeta = getTransMeta().getThisStepFields( getStepMeta(), null, data.inputRowMeta.clone() );
@Test public void getThisStepFieldsPassesCloneRowMeta() throws Exception { final String overriddenValue = "overridden"; StepMeta nextStep = mockStepMeta( "nextStep" ); StepMetaInterface smi = mock( StepMetaInterface.class ); StepIOMeta ioMeta = mock( StepIOMeta.class ); when( smi.getStepIOMeta() ).thenReturn( ioMeta ); doAnswer( new Answer<Object>() { @Override public Object answer( InvocationOnMock invocation ) throws Throwable { RowMetaInterface rmi = (RowMetaInterface) invocation.getArguments()[ 0 ]; rmi.clear(); rmi.addValueMeta( new ValueMetaString( overriddenValue ) ); return null; } } ).when( smi ).getFields( any( RowMetaInterface.class ), anyString(), any( RowMetaInterface[].class ), eq( nextStep ), any( VariableSpace.class ), any( Repository.class ), any( IMetaStore.class ) ); StepMeta thisStep = mockStepMeta( "thisStep" ); when( thisStep.getStepMetaInterface() ).thenReturn( smi ); RowMeta rowMeta = new RowMeta(); rowMeta.addValueMeta( new ValueMetaString( "value" ) ); RowMetaInterface thisStepsFields = transMeta.getThisStepFields( thisStep, nextStep, rowMeta ); assertEquals( 1, thisStepsFields.size() ); assertEquals( overriddenValue, thisStepsFields.getValueMeta( 0 ).getName() ); }
/** * Find the informational fields coming from an informational step into the step specified. * * @param stepMeta * The receiving step * @return A row containing fields with origin. * @throws KettleStepException * the kettle step exception */ public RowMetaInterface getPrevInfoFields( StepMeta stepMeta ) throws KettleStepException { for ( int i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() && hi.getToStep().equals( stepMeta ) ) { StepMeta infoStep = hi.getFromStep(); if ( isStepInformative( stepMeta, infoStep ) ) { RowMetaInterface row = getPrevStepFields( infoStep ); return getThisStepFields( infoStep, stepMeta, row ); } } } return new RowMeta(); }
rowMeta = getThisStepFields( stepMeta, targetStep, row, monitor );