Pentaho User defined Java Class - Datatype Conversion Error

1k views Asked by At

I am currently trying to do nothing else, than getting all row values from a some columns and sum them together. That part works fine, it even worked out once :D. But when deleting the data and trying to run the job again I got a Casting error. For your information, my current attempt to this solution is:

Read in data from Excel (casting everything to Integer) => select all important fields (select values) => Add constants (append result field) => UDJC (sum up each row from the data set) => Update Database

I don't really understand why, since I am using all Integers. Maybe someone here can help me, I guess it is something dumb I am missing.

This is my Excel input

recasting them inside select values

My User defined Java Class code looks like this

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
  if (first) {
    first = false;

    }



  Object[] r = getRow();

  if (r == null) {
    setOutputDone();
    return false;
  }

  // It is always safest to call createOutputRow() to ensure that your output row's Object[] is large
  // enough to handle any new fields you are creating in this step.
  r = createOutputRow(r, data.outputRowMeta.size());

  /* TODO: Your code here. (See Sample)

  // Get the value from an input field
  String foobar = get(Fields.In, "a_fieldname").getString(r);

  foobar += "bar";

  // Set a value in a new output field
  get(Fields.Out, "output_fieldname").setValue(r, foobar);

  */
  int result_value = 0;

  int value10  = get(Fields.In, "int_10").getInteger(r).intValue();
  int value20  = get(Fields.In, "int_20").getInteger(r).intValue();
  int value30  = get(Fields.In, "int_30").getInteger(r).intValue();
  int value40  = get(Fields.In, "int_40").getInteger(r).intValue();
  int value50  = get(Fields.In, "int_50").getInteger(r).intValue();
  int value60  = get(Fields.In, "int_60").getInteger(r).intValue();
  int value70  = get(Fields.In, "int_70").getInteger(r).intValue();
  int value80  = get(Fields.In, "int_80").getInteger(r).intValue();
  int value90  = get(Fields.In, "int_90").getInteger(r).intValue();
  int value100 = get(Fields.In, "int_100").getInteger(r).intValue();
  int value110 = get(Fields.In, "int_110").getInteger(r).intValue();
  int value120 = get(Fields.In, "int_120").getInteger(r).intValue();
  int value130 = get(Fields.In, "int_130").getInteger(r).intValue();
  int value140 = get(Fields.In, "int_140").getInteger(r).intValue();
  int value150 = get(Fields.In, "int_150").getInteger(r).intValue();
  int value160 = get(Fields.In, "int_160").getInteger(r).intValue();
  int value170 = get(Fields.In, "int_170").getInteger(r).intValue();
  int value180 = get(Fields.In, "int_180").getInteger(r).intValue();
  int value190 = get(Fields.In, "int_190").getInteger(r).intValue();
  int value200 = get(Fields.In, "int_200").getInteger(r).intValue();
  int value210 = get(Fields.In, "int_210").getInteger(r).intValue();
  int value220 = get(Fields.In, "int_220").getInteger(r).intValue();

  result_value = (value10 + value20 + value30 + value40 + value50 + value60 +
                 value70 + value80 + value90 + value100 + value110 + value120 +
                 value130 + value140 + value150 + value160 + value170 + value180 +
                 value190 + value200 + value210 + value220);


  get(Fields.Out, "neutral_or_personal").setValue(r, result_value);

  // Send the row on to the next step.
  putRow(data.outputRowMeta, r);

  return true;
}
0

There are 0 answers