Reputation: 60
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:
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:
I tried searching in Pentaho Wiki & This thread in Forums, But found nothing close.
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
Reputation: 395
Use such method in process row in UserDefinedJavaClass
String[] variables = super.parent.listVariables();
Upvotes: 1