/** * Configures the transformation with the given parameters and their values * * @param trans the executable transformation object * @param optionParams the list of parameters to set for the transformation * @param transMeta the transformation metadata * @throws UnknownParamException */ protected static void configureParameters( Trans trans, NamedParams optionParams, TransMeta transMeta ) throws UnknownParamException { trans.initializeVariablesFrom( null ); trans.getTransMeta().setInternalKettleVariables( trans ); // Map the command line named parameters to the actual named parameters. // Skip for the moment any extra command line parameter not known in the transformation. String[] transParams = trans.listParameters(); for ( String param : transParams ) { String value = optionParams.getParameterValue( param ); if ( value != null ) { trans.setParameterValue( param, value ); transMeta.setParameterValue( param, value ); } } // Put the parameters over the already defined variable space. Parameters get priority. trans.activateParameters(); }
activateParameters(); transMeta.activateParameters();
private void passParametersToTrans( Trans internalTrans, RowMetaAndData rowMetaAndData ) throws KettleException { internalTrans.clearParameters(); String[] parameterNames = internalTrans.listParameters(); for ( int i = 0; i < this.parameters.getVariable().length; ++i ) { String variable = this.parameters.getVariable()[ i ]; String fieldName = this.parameters.getField()[ i ]; String inputValue = this.parameters.getInput()[ i ]; String value; if ( !Utils.isEmpty( fieldName ) ) { int idx = rowMetaAndData.getRowMeta().indexOfValue( fieldName ); if ( idx < 0 ) { throw new KettleException( BaseMessages.getString( PKG, "TransExecutor.Exception.UnableToFindField", fieldName ) ); } value = rowMetaAndData.getString( idx, "" ); } else { value = this.parentTrans.environmentSubstitute( inputValue ); } if ( Const.indexOfString( variable, parameterNames ) < 0 ) { internalTrans.setVariable( variable, Const.NVL( value, "" ) ); } else { internalTrans.setParameterValue( variable, Const.NVL( value, "" ) ); } } internalTrans.activateParameters(); }
.activateParams( getData().mappingTrans, getData().mappingTrans, this, getData().mappingTrans.listParameters(), meta.getParameters(), meta.getParameterValues() ); getData().mappingTrans.activateParameters();