本文整理汇总了Java中org.pentaho.di.core.parameters.NamedParams.addParameterDefinition方法的典型用法代码示例。如果您正苦于以下问题:Java NamedParams.addParameterDefinition方法的具体用法?Java NamedParams.addParameterDefinition怎么用?Java NamedParams.addParameterDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.parameters.NamedParams
的用法示例。
在下文中一共展示了NamedParams.addParameterDefinition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setParams
import org.pentaho.di.core.parameters.NamedParams; //导入方法依赖的package包/类
/**
* 将来源对象的参数拷贝到目标对象,并根据要求修改 <br/>
* @author jingma
* @param target 要设置的目标对象
* @param source 来源对象
* @param params 要修改的参数
*/
public static void setParams(NamedParams target,
NamedParams source,Map<String, String> params) {
//修改参数
target.eraseParameters();
try {
for ( String key : source.listParameters() ) {
String defaultVal = source.getParameterDefault( key );
if(params.containsKey(key)){
defaultVal = params.get(key);
}
target.addParameterDefinition( key, defaultVal,
source.getParameterDescription( key ) );
}
} catch (Exception e) {
log.error("保存JOB失败", e);
}
}
示例2: filterUserParameters
import org.pentaho.di.core.parameters.NamedParams; //导入方法依赖的package包/类
private NamedParams filterUserParameters( NamedParams params ) {
NamedParams userParams = new NamedParamsDefault();
if ( !isEmpty( params ) ) {
for ( String paramName : params.listParameters() ) {
if ( isUserParameter( paramName ) ) {
try {
userParams.addParameterDefinition( paramName, StringUtils.EMPTY, StringUtils.EMPTY );
} catch ( DuplicateParamException e ) {
// ignore
}
}
}
}
return userParams;
}
示例3: testConfigureParameters
import org.pentaho.di.core.parameters.NamedParams; //导入方法依赖的package包/类
@Test
public void testConfigureParameters() throws Exception {
TransMeta transMeta = new TransMeta();
transMeta.addParameterDefinition( TEST_PARAM_NAME, DEFAULT_PARAM_VALUE, "This tests a default parameter" );
assertEquals( "Default parameter was not set correctly on TransMeta",
DEFAULT_PARAM_VALUE, transMeta.getParameterDefault( TEST_PARAM_NAME ) );
assertEquals( "Parameter value should be blank in TransMeta", "", transMeta.getParameterValue( TEST_PARAM_NAME ) );
Trans trans = new Trans( transMeta );
assertEquals( "Default parameter was not set correctly on Trans",
DEFAULT_PARAM_VALUE, trans.getParameterDefault( TEST_PARAM_NAME ) );
assertEquals( "Parameter value should be blank in Trans", "", trans.getParameterValue( TEST_PARAM_NAME ) );
NamedParams params = new NamedParamsDefault();
params.addParameterDefinition( TEST_PARAM_NAME, NOT_DEFAULT_PARAM_VALUE, "This tests a non-default parameter" );
params.setParameterValue( TEST_PARAM_NAME, NOT_DEFAULT_PARAM_VALUE );
Pan.configureParameters( trans, params, transMeta );
assertEquals( "Parameter was not set correctly in Trans",
NOT_DEFAULT_PARAM_VALUE, trans.getParameterValue( TEST_PARAM_NAME ) );
assertEquals( "Parameter was not set correctly in TransMeta",
NOT_DEFAULT_PARAM_VALUE, transMeta.getParameterValue( TEST_PARAM_NAME ) );
}
示例4: testGetSetParameterValue
import org.pentaho.di.core.parameters.NamedParams; //导入方法依赖的package包/类
@Test
public void testGetSetParameterValue() throws Exception {
assertNull( meta.getParameterValue( "var1" ) );
assertNull( meta.getParameterDefault( "var1" ) );
assertNull( meta.getParameterDescription( "var1" ) );
meta.setParameterValue( "var1", "y" );
// Values for new parameters must be added by addParameterDefinition
assertNull( meta.getParameterValue( "var1" ) );
assertNull( meta.getParameterDefault( "var1" ) );
assertNull( meta.getParameterDescription( "var1" ) );
meta.addParameterDefinition( "var2", "z", "My Description" );
assertEquals( "", meta.getParameterValue( "var2" ) );
assertEquals( "z", meta.getParameterDefault( "var2" ) );
assertEquals( "My Description", meta.getParameterDescription( "var2" ) );
meta.setParameterValue( "var2", "y" );
assertEquals( "y", meta.getParameterValue( "var2" ) );
assertEquals( "z", meta.getParameterDefault( "var2" ) );
String[] params = meta.listParameters();
assertNotNull( params );
// clearParameters() just clears their values, not their presence
meta.clearParameters();
assertEquals( "", meta.getParameterValue( "var2" ) );
// eraseParameters() clears the list of parameters
meta.eraseParameters();
assertNull( meta.getParameterValue( "var1" ) );
NamedParams newParams = new NamedParamsDefault();
newParams.addParameterDefinition( "var3", "default", "description" );
newParams.setParameterValue( "var3", "a" );
meta.copyParametersFrom( newParams );
meta.activateParameters();
assertEquals( "default", meta.getParameterDefault( "var3" ) );
}