/** * Gets the value of the specified parameter. * * @param key the name of the parameter * @return the parameter value * @throws UnknownParamException if the parameter does not exist * @see org.pentaho.di.core.parameters.NamedParams#getParameterValue(java.lang.String) */ @Override public String getParameterValue( String key ) throws UnknownParamException { return namedParams.getParameterValue( key ); }
@Override public String getParameterValue( String key ) throws UnknownParamException { return namedParams.getParameterValue( key ); }
@Override public String getParameterValue( String key ) throws UnknownParamException { return namedParams.getParameterValue( key ); }
value = aParam.getParameterValue( key ); } catch ( UnknownParamException e ) { value = "";
value = aParam.getParameterValue( keys[idx] ); } catch ( UnknownParamException e ) { value = "";
public void setParametersAsVariablesInUI( NamedParams namedParameters, VariableSpace space ) { for ( String param : namedParameters.listParameters() ) { try { space.setVariable( param, Const.NVL( namedParameters.getParameterValue( param ), Const.NVL( namedParameters.getParameterDefault( param ), Const.NVL( space.getVariable( param ), "" ) ) ) ); } catch ( Exception e ) { // ignore this } } }
@Test public void testPrepareFieldNamesParameters() throws UnknownParamException { // array of params String[] parameterNames = new String[2]; parameterNames[0] = "param1"; parameterNames[1] = "param2"; // array of fieldNames params String[] parameterFieldNames = new String[1]; parameterFieldNames[0] = "StreamParam1"; // array of parameterValues params String[] parameterValues = new String[2]; parameterValues[1] = "ValueParam2"; JobEntryTrans jet = new JobEntryTrans(); VariableSpace variableSpace = new Variables(); jet.copyVariablesFrom( variableSpace ); //at this point StreamColumnNameParams are already inserted in namedParams NamedParams namedParam = Mockito.mock( NamedParamsDefault.class ); Mockito.doReturn( "value1" ).when( namedParam ).getParameterValue( "param1" ); Mockito.doReturn( "value2" ).when( namedParam ).getParameterValue( "param2" ); jet.prepareFieldNamesParameters( parameterNames, parameterFieldNames, parameterValues, namedParam, jet ); Assert.assertEquals( "value1", jet.getVariable( "param1" ) ); Assert.assertEquals( null, jet.getVariable( "param2" ) ); }
public void prepareFieldNamesParameters( String[] parameters, String[] parameterFieldNames, String[] parameterValues, NamedParams namedParam, JobEntryTrans jobEntryTrans ) throws UnknownParamException { for ( int idx = 0; idx < parameters.length; idx++ ) { // Grab the parameter value set in the Trans job entry // Set fieldNameParameter only if exists and if it is not declared any staticValue( parameterValues array ) // String thisValue = namedParam.getParameterValue( parameters[ idx ] ); // Set value only if is not empty at namedParam and exists in parameterFieldNames if ( !Utils.isEmpty( thisValue ) && idx < parameterFieldNames.length ) { // If exists then ask if is not empty if ( !Utils.isEmpty( Const.trim( parameterFieldNames[ idx ] ) ) ) { // If is not empty then we have to ask if it exists too in parameterValues array, since the values in // parameterValues prevail over parameterFieldNames if ( idx < parameterValues.length ) { // If is empty at parameterValues array, then we can finally add that variable with that value if ( Utils.isEmpty( Const.trim( parameterValues[ idx ] ) ) ) { jobEntryTrans.setVariable( parameters[ idx ], thisValue ); } } else { // Or if not in parameterValues then we can add that variable with that value too jobEntryTrans.setVariable( parameters[ idx ], thisValue ); } } } } }
/** * 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(); }
String value = params.getParameterValue( param ); if ( value != null ) { job.getJobMeta().setParameterValue( param, value ); String optionValue = customParams.getParameterValue( optionName ); if ( optionName != null && optionValue != null ) { job.getExtensionDataMap().put( optionName, optionValue );
String thisValue = namedParam.getParameterValue( parameterNames[idx] ); if ( !Utils.isEmpty( thisValue ) ) { for ( String param : namedParam.listParameters() ) { String defValue = namedParam.getParameterDefault( param ); String value = namedParam.getParameterValue( param ); jobExecutionConfiguration.getParams().put( param, Const.NVL( value, defValue ) );