Java Code Examples for org.pentaho.di.trans.TransMeta#listParameters()

The following examples show how to use org.pentaho.di.trans.TransMeta#listParameters() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KettleBeamPipelineExecutor.java    From kettle-beam with Apache License 2.0 6 votes vote down vote up
private void setVariablesInTransformation( BeamJobConfig config, TransMeta transMeta ) {
  String[] parameters = transMeta.listParameters();
  for ( JobParameter parameter : config.getParameters() ) {
    if ( StringUtils.isNotEmpty( parameter.getVariable() ) ) {
      if ( Const.indexOfString( parameter.getVariable(), parameters ) >= 0 ) {
        try {
          transMeta.setParameterValue( parameter.getVariable(), parameter.getValue() );
        } catch ( UnknownParamException e ) {
          transMeta.setVariable( parameter.getVariable(), parameter.getValue() );
        }
      } else {
        transMeta.setVariable( parameter.getVariable(), parameter.getValue() );
      }
    }
  }
  transMeta.activateParameters();
}
 
Example 2
Source File: TransformationParameterHelper.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public KettleParameterInfo[] getDeclaredParameter() throws KettleException, ReportDataFactoryException {
  if ( parameters == null ) {
    TransMeta transMeta = transformationProducer.loadTransformation( dataFactoryContext );
    String[] parameterNames = transMeta.listParameters();
    ArrayList<KettleParameterInfo> infos = new ArrayList<KettleParameterInfo>();
    for ( String parameterName : parameterNames ) {
      String defaultValue = transMeta.getParameterDefault( parameterName );
      String description = transMeta.getParameterDescription( parameterName );
      infos.add( new KettleParameterInfo( parameterName, description, defaultValue ) );
    }
    parameters = infos.toArray( new KettleParameterInfo[ infos.size() ] );
  }
  return parameters;
}
 
Example 3
Source File: JobEntryTransDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void getParameters( TransMeta inputTransMeta ) {
  try {
    if ( inputTransMeta == null ) {
      JobEntryTrans jet = new JobEntryTrans();
      getInfo( jet );
      inputTransMeta = jet.getTransMeta( rep, metaStore, jobMeta );
    }
    String[] parameters = inputTransMeta.listParameters();

    String[] existing = wParameters.getItems( 1 );

    for ( int i = 0; i < parameters.length; i++ ) {
      if ( Const.indexOfString( parameters[ i ], existing ) < 0 ) {
        TableItem item = new TableItem( wParameters.table, SWT.NONE );
        item.setText( 1, parameters[ i ] );
      }
    }
    wParameters.removeEmptyRows();
    wParameters.setRowNums();
    wParameters.optWidth( true );
  } catch ( Exception e ) {
    new ErrorDialog( shell,
      BaseMessages.getString( PKG, "JobEntryTransDialog.Exception.UnableToLoadTransformation.Title" ),
      BaseMessages.getString( PKG, "JobEntryTransDialog.Exception.UnableToLoadTransformation.Message" ), e );
  }

}
 
Example 4
Source File: TransExecutorDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void getParametersFromTrans( TransMeta inputTransMeta ) {
  try {
    // Load the job in executorTransMeta
    //
    if ( inputTransMeta == null ) {
      loadTransformation();
      inputTransMeta = executorTransMeta;
    }

    String[] parameters = inputTransMeta.listParameters();
    for ( int i = 0; i < parameters.length; i++ ) {
      String name = parameters[ i ];
      String desc = inputTransMeta.getParameterDescription( name );

      TableItem item = new TableItem( wTransExecutorParameters.table, SWT.NONE );
      item.setText( 1, Const.NVL( name, "" ) );
      String str = inputTransMeta.getParameterDefault( name );
      str = ( str != null ? str : ( desc != null ? desc : "" ) );
      item.setText( 3, Const.NVL( str, "" ) );
    }
    wTransExecutorParameters.removeEmptyRows();
    wTransExecutorParameters.setRowNums();
    wTransExecutorParameters.optWidth( true );

  } catch ( Exception e ) {
    new ErrorDialog( shell, BaseMessages.getString( PKG, "TransExecutorDialog.ErrorLoadingSpecifiedTrans.Title" ),
      BaseMessages.getString( PKG, "TransExecutorDialog.ErrorLoadingSpecifiedTrans.Message" ), e );
  }

}
 
Example 5
Source File: SingleThreaderDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void getParameters( TransMeta mappingTransMeta ) {
  try {
    if ( mappingTransMeta == null ) {
      SingleThreaderMeta jet = new SingleThreaderMeta();
      getInfo( jet );
      mappingTransMeta = SingleThreaderMeta.loadSingleThreadedTransMeta( jet, repository, transMeta );
    }
    String[] parameters = mappingTransMeta.listParameters();

    String[] existing = wParameters.getItems( 1 );

    for ( int i = 0; i < parameters.length; i++ ) {
      if ( Const.indexOfString( parameters[i], existing ) < 0 ) {
        TableItem item = new TableItem( wParameters.table, SWT.NONE );
        item.setText( 1, parameters[i] );
      }
    }
    wParameters.removeEmptyRows();
    wParameters.setRowNums();
    wParameters.optWidth( true );
  } catch ( Exception e ) {
    new ErrorDialog( shell, BaseMessages.getString(
      PKG, "SingleThreaderDialog.Exception.UnableToLoadTransformation.Title" ), BaseMessages.getString(
      PKG, "SingleThreaderDialog.Exception.UnableToLoadTransformation.Message" ), e );
  }

}
 
Example 6
Source File: KettleDatabaseRepositoryTransDelegate.java    From pentaho-kettle with Apache License 2.0 3 votes vote down vote up
/**
 * Save the parameters of this transformation to the repository.
 *
 *
 * @throws KettleException
 *           Upon any error.
 *
 *
 *           TODO: Move this code over to the Repository class for refactoring...
 */
public void saveTransParameters( TransMeta transMeta ) throws KettleException {
  String[] paramKeys = transMeta.listParameters();
  for ( int idx = 0; idx < paramKeys.length; idx++ ) {
    String desc = transMeta.getParameterDescription( paramKeys[idx] );
    String defaultValue = transMeta.getParameterDefault( paramKeys[idx] );
    insertTransParameter( transMeta.getObjectId(), idx, paramKeys[idx], defaultValue, desc );
  }
}