当前位置: 首页>>代码示例>>Java>>正文


Java NamedParams类代码示例

本文整理汇总了Java中org.pentaho.di.core.parameters.NamedParams的典型用法代码示例。如果您正苦于以下问题:Java NamedParams类的具体用法?Java NamedParams怎么用?Java NamedParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NamedParams类属于org.pentaho.di.core.parameters包,在下文中一共展示了NamedParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
}
 
开发者ID:majinju,项目名称:KettleEasyExpand,代码行数:25,代码来源:KettleUtils.java

示例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;
  }
 
开发者ID:pentaho,项目名称:pdi-platform-plugin,代码行数:21,代码来源:PdiContentProvider.java

示例3: populateInputs

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
private void populateInputs( NamedParams paramHolder, VariableSpace varSpace ) {
  if ( parameters != null ) {
    for ( String paramKey : parameters.keySet() ) {
      try {
        paramHolder.setParameterValue( paramKey, parameters.get( paramKey ) );
      } catch ( UnknownParamException upe ) {
        log.warn( upe );
      }
    }
  }

  if ( variables != null ) {
    for ( String variableKey : variables.keySet() ) {
      varSpace.setVariable( variableKey, variables.get( variableKey ) );
    }
  }

  for ( Map.Entry<String, Object> entry : varArgs.entrySet() ) {
    varSpace.setVariable( entry.getKey(), ( entry.getValue() != null ) ? entry.getValue().toString() : null );
  }
}
 
开发者ID:pentaho,项目名称:pdi-platform-plugin,代码行数:22,代码来源:PdiAction.java

示例4: configureParameters

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:30,代码来源:Pan.java

示例5: 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 ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:27,代码来源:PanTest.java

示例6: CommandLineOption

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
/**
 * Creates a new "array" command line option.
 *  
 * @param option The option string
 * @param description the description of the option
 * @param argument the StringBuffer that will contain the argument later
 * @param hiddenOption true if this option should not be shown in the usage list. 
 */
public CommandLineOption(String option, String description, NamedParams argument, boolean hiddenOption)
{
	this.option = option;
	this.description = description;
	this.arrayParams = argument;
	this.argument = null;
	this.yesNo = false;
	this.array = true;
	this.hiddenOption = hiddenOption;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:19,代码来源:CommandLineOption.java

示例7: setParametersAsVariablesInUI

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
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
    	  }
      }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:11,代码来源:Spoon.java

示例8: setParametersAsVariablesInUI

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
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
    }
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:11,代码来源:Spoon.java

示例9: testTransformationUserParameters

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
@Test
public void testTransformationUserParameters() throws Exception {

  PdiAction action = new PdiAction();
  action.setRepositoryName( KettleFileRepositoryMeta.REPOSITORY_TYPE_ID );
  action.setArguments( new String[] { "dummyArg" } );
  action.setDirectory( SOLUTION_REPOSITORY );
  action.setTransformation( SAMPLE_TRANS );

  action.execute();

  Assert.isTrue( action.localTrans != null && action.localTrans.getTransMeta() != null );

  NamedParams np = action.localTrans.getTransMeta();

  boolean protectedParameterNameExistsInKtr = false;

  for ( String param : np.listParameters() ) {
    protectedParameterNameExistsInKtr |= param != null && param.equals( SAMPLE_PROTECTED_PARAMETER_NAME );
  }

  // we make sure: this ktr does indeed have a system/hidden parameter
  Assert.isTrue( protectedParameterNameExistsInKtr );

  // reset attribute
  protectedParameterNameExistsInKtr = false;

  // we now call IPdiContentProvider.getUserParameters( kjb ), that should filter out protected parameters
  IPdiContentProvider pdiContentProvider = new PdiContentProvider( PentahoSystem.get( IUnifiedRepository.class ) );
  String[] userParams = pdiContentProvider.getUserParameters( SOLUTION_REPOSITORY + SAMPLE_TRANS + ".ktr" );

  for ( String userParam : userParams ) {
    protectedParameterNameExistsInKtr |= userParam != null && userParam.equals( SAMPLE_PROTECTED_PARAMETER_NAME );
  }

  // we make sure: IPdiContentProvider has filtered it out
  Assert.isTrue( !protectedParameterNameExistsInKtr );
}
 
开发者ID:pentaho,项目名称:pdi-platform-plugin,代码行数:39,代码来源:UserParametersTest.java

示例10: testJobUserParameters

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
@Test
public void testJobUserParameters() throws Exception {

  PdiAction action = new PdiAction();
  action.setRepositoryName( KettleFileRepositoryMeta.REPOSITORY_TYPE_ID );
  action.setArguments( new String[] { "dummyArg" } );
  action.setDirectory( SOLUTION_REPOSITORY );
  action.setJob( SAMPLE_JOB );

  action.execute();

  Assert.isTrue( action.localJob != null && action.localJob.getJobMeta() != null );

  NamedParams np = action.localJob.getJobMeta();

  boolean protectedParameterNameExistsInKjb = false;

  for ( String param : np.listParameters() ) {
    protectedParameterNameExistsInKjb |= param != null && param.equals( SAMPLE_PROTECTED_PARAMETER_NAME );
  }

  // we make sure: this kjb does indeed have a system/hidden parameter
  Assert.isTrue( protectedParameterNameExistsInKjb );

  // reset attribute
  protectedParameterNameExistsInKjb = false;

  // we now call IPdiContentProvider.getUserParameters( kjb ), that should filter out protected parameters
  IPdiContentProvider pdiContentProvider = new PdiContentProvider( PentahoSystem.get( IUnifiedRepository.class ) );
  String[] userParams = pdiContentProvider.getUserParameters( SOLUTION_REPOSITORY + SAMPLE_JOB + ".kjb" );

  for ( String userParam : userParams ) {
    protectedParameterNameExistsInKjb |= userParam != null && userParam.equals( SAMPLE_PROTECTED_PARAMETER_NAME );
  }

  // we make sure: IPdiContentProvider has filtered it out
  Assert.isTrue( !protectedParameterNameExistsInKjb );
}
 
开发者ID:pentaho,项目名称:pdi-platform-plugin,代码行数:39,代码来源:UserParametersTest.java

示例11: Trans

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
/**
 * Instantiates a new transformation using any of the provided parameters including the variable bindings, a
 * repository, a name, a repository directory name, and a filename. This is a multi-purpose method that supports
 * loading a transformation from a file (if the filename is provided but not a repository object) or from a repository
 * (if the repository object, repository directory name, and transformation name are specified).
 *
 * @param parent
 *          the parent variable space and named params
 * @param rep
 *          the repository
 * @param name
 *          the name of the transformation
 * @param dirname
 *          the dirname the repository directory name
 * @param filename
 *          the filename containing the transformation definition
 * @throws KettleException
 *           if any error occurs during loading, parsing, or creation of the transformation
 */
public <Parent extends VariableSpace & NamedParams> Trans( Parent parent, Repository rep, String name, String dirname,
    String filename ) throws KettleException {
  this();
  try {
    if ( rep != null ) {
      RepositoryDirectoryInterface repdir = rep.findDirectory( dirname );
      if ( repdir != null ) {
        this.transMeta = rep.loadTransformation( name, repdir, null, false, null ); // reads last version
      } else {
        throw new KettleException( BaseMessages.getString( PKG, "Trans.Exception.UnableToLoadTransformation", name,
            dirname ) );
      }
    } else {
      transMeta = new TransMeta( filename, false );
    }

    this.log = LogChannel.GENERAL;

    transMeta.initializeVariablesFrom( parent );
    initializeVariablesFrom( parent );
    // PDI-3064 do not erase parameters from meta!
    // instead of this - copy parameters to actual transformation
    this.copyParametersFrom( parent );
    this.activateParameters();

    this.setDefaultLogCommitSize();

    // Get a valid transactionId in case we run database transactional.
    transactionId = calculateTransactionId();
    threadName = transactionId; // / backward compatibility but deprecated!
  } catch ( KettleException e ) {
    throw new KettleException( BaseMessages.getString( PKG, "Trans.Exception.UnableToOpenTransformation", name ), e );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:54,代码来源:Trans.java

示例12: activateParams

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
public static void activateParams( VariableSpace childVariableSpace, NamedParams childNamedParams, VariableSpace parent, String[] listParameters,
                                   String[] mappingVariables, String[] inputFields ) {
  Map<String, String> parameters = new HashMap<>();
  Set<String> subTransParameters = new HashSet<>( Arrays.asList( listParameters ) );

  for ( int i = 0; i < mappingVariables.length; i++ ) {
    parameters.put( mappingVariables[ i ], parent.environmentSubstitute( inputFields[ i ] ) );
  }

  for ( String variableName : parent.listVariables() ) {
    // When the child parameter does exist in the parent parameters, overwrite the child parameter by the
    // parent parameter.
    if ( parameters.containsKey( variableName ) ) {
      parameters.put( variableName, parent.getVariable( variableName ) );
    } else if ( ArrayUtils.contains( listParameters, variableName ) ) {
      // there is a definition only in Transformation properties - params tab
      parameters.put( variableName, parent.getVariable( variableName ) );
    }
  }

  for ( Map.Entry<String, String> entry : parameters.entrySet() ) {
    String key = entry.getKey();
    String value = Const.NVL( entry.getValue(), "" );
    if ( subTransParameters.contains( key ) ) {
      try {
        childNamedParams.setParameterValue( key, Const.NVL( entry.getValue(), "" ) );
      } catch ( UnknownParamException e ) {
        // this is explicitly checked for up front
      }
    } else {
      childVariableSpace.setVariable( key, value );
    }
  }

  childNamedParams.activateParameters();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:37,代码来源:StepWithMappingMeta.java

示例13: 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" ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:39,代码来源:AbstractMetaTest.java

示例14: setParametersAsVariablesInUI

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
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
    }
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:11,代码来源:Spoon.java

示例15: copyParametersFrom

import org.pentaho.di.core.parameters.NamedParams; //导入依赖的package包/类
public void copyParametersFrom(NamedParams params) {
	namedParams.copyParametersFrom(params);
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:4,代码来源:Job.java


注:本文中的org.pentaho.di.core.parameters.NamedParams类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。