Skip to content

Instantly share code, notes, and snippets.

@juareznjunior
Created October 30, 2014 17:07
Show Gist options
  • Save juareznjunior/8d9952e6113dbf66fecf to your computer and use it in GitHub Desktop.
Save juareznjunior/8d9952e6113dbf66fecf to your computer and use it in GitHub Desktop.
Pentaho Kettle - User defined Java Class
import java.text.Normalizer;
public static String removeAccents(String s)
{
s = Normalizer.normalize(s, Normalizer.Form.NFD);
s = s.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
return s.toUpperCase();
}
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
if (first){
first = false;
}
r = createOutputRow(r, data.outputRowMeta.size());
// Get the value from an input field
String nome_crm = get(Fields.In, "nome_crm").getString(r);
String descricao_alta = get(Fields.In, "descricao_alta").getString(r);
get(Fields.Out, "nome_crm").setValue(r, removeAccents(nome_crm));
get(Fields.Out, "descricao_alta").setValue(r, removeAccents(descricao_alta));
// Send the row on to the next step.
putRow(data.outputRowMeta, r);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment