Some things to note about using Java code modules in kettle in case you forget.
First you need to inherit the Processrow method, similar to the Java Main method, where the code starts and reads and saves variables inside.
public boolean Processrow (Stepmetainterface SMI, Stepdatainterface SDI) throws Exception
{
object[] r = GetRow () ;
if (r = = null) {
setoutputdone ();
return false;
}
R = Createoutputrow (R, Data.outputRowMeta.size ());
String AppID = Get (fields.in, "AppID"). GetString (R);
String Appkey = Get (fields.in, "Appkey"). GetString (R);
String City_code = Get (fields.in, "City_code"). GetString (R);
String date = Get (fields.in, "date"). GetString (R);
Map BODY = new HashMap ();
Body.put ("City_code", City_code);
Body.put ("date", date);
String sign = signrequest (AppID, body, appkey);
Get (Fields.out, "sign"). SetValue (r,sign);
Logbasic ("sign:" +sign);
Putrow (Data.outputrowmeta, R);
return true;
}
As above, the first few lines of code do not change read variables using get (fields.in, "AppID");
Save variables using get (fields.out, "sign"). SetValue (R,sign);
Finally, don't forget Putrow (Data.outputrowmeta, R); and return true;
Input log can use Logbasic ("sign:" +sign);
Above import java.util.*;
The jar package required is placed in the Lib directory of the Kettle installation directory
The bottom variable name is the same as the save variable name, as shown in the following figure