protected void printTransformationParameters( Trans trans ) throws UnknownParamException { if ( trans != null && trans.listParameters() != null ) { for ( String pName : trans.listParameters() ) { printParameter( pName, trans.getParameterValue( pName ), trans.getParameterDefault( pName ), trans.getParameterDescription( pName ) ); } } }
.activateParams( trans, trans, this, trans.listParameters(), parameters.getVariable(), inputFieldValues );
/** * 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(); }
/** * Activates all parameters by setting their values. If no values already exist, the method will attempt to set the * parameter to the default value. If no default value exists, the method will set the value of the parameter to the * empty string (""). * * @see org.pentaho.di.core.parameters.NamedParams#activateParameters() */ @Override public void activateParameters() { String[] keys = listParameters(); for ( String key : keys ) { String value; try { value = getParameterValue( key ); } catch ( UnknownParamException e ) { value = ""; } String defValue; try { defValue = getParameterDefault( key ); } catch ( UnknownParamException e ) { defValue = ""; } if ( Utils.isEmpty( value ) ) { setVariable( key, Const.NVL( defValue, "" ) ); } else { setVariable( key, Const.NVL( value, "" ) ); } } }
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(); }
for ( String param : trans.listParameters() ) { String value = runTimeParameters.getVariable( param ); if ( value != null ) {
.activateParams( getData().mappingTrans, getData().mappingTrans, this, getData().mappingTrans.listParameters(), meta.getParameters(), meta.getParameterValues() ); getData().mappingTrans.activateParameters();