Apoorv Jain
Apoorv Jain

Reputation: 60

How to Fetch All Parameters in 'User Defined Java Class' Step in Pentaho Data Integration (Kettle)

Scenario: I am creating a Transformation in PDI. This transformation Has a Step 'User Defined Java Class', In which I am calling an external library.
This Transformation have'parameters' and for now, I have to fetch all parameters individually to pass to use them in this step (passing to my external jar)like this:

PgSqlHost = getVariable("PostgresHost"); 
PgSqlPort = getVariable("PgSqlPort"); 
PgSqlLoginUserId = getVariable("PgSqlLoginUserId"); 
PgSqlLoginPassword = getVariable("PgSqlLoginPassword");

There are 50-60 params like these that I have to use in this step. and I have to fetch each of them individually and pass it to external java lib like this.

TransformationParameters tparams= new TransformationParameters();
tparams.PgSqlHost = PgSqlHost;
tparams.PgSqlPort = Integer.parseInt(PgSqlPort);
tparams.PgSqlLoginUserId = PgSqlLoginUserId;
tparams.PgSqlLoginPassword = PgSqlLoginPassword;
Configuration config =  ConfigurationReader.getConfiguration();
config.setParameters(tparams);

The problem with this approach is:

  1. I have to fetch all parameters individually.
  2. When Adding new parameter I have to handle modify this step in all transformations

My question: Is there a way to fetch all parameters something just like this:

HashMap<K,V> params = getAllVariables();
Configuration config =  ConfigurationReader.getConfiguration();
config.setParametersMap(tparams);

What I tried:

  1. I tried searching in Pentaho Wiki & This thread in Forums, But found nothing close.

  2. I could add a step to write those params to a .properties file and read those in my external jar.

Can someone suggest a better idea to achieve this? Thanks.

Upvotes: 1

Views: 1792

Answers (1)

Sedos
Sedos

Reputation: 395

Use such method in process row in UserDefinedJavaClass

String[] variables =    super.parent.listVariables();

Upvotes: 1

Related Questions