...
Code Block |
---|
try { for (String key : parameterMap.keySet()) { transMeta.setParameterValue(key, parameterMap.get(key)); } for (String key : variableMap.keySet()) { transMeta.setVariable(key, variableMap.get(key)); } } catch (UnknownParamException e) { error(e.getMessage()); } transMeta.setArguments(arguments); |
Retrieving data from a step
To retrieve rows of data from any Kettle step copy you can attach a row listener to the step.
Code Block |
---|
Trans Trans = new Trans(transMeta);
// prepare the execution of the transformation (instead of simply execute)
//
trans.prepareExecution(arguments);
// Attach a row listener to a step copy
//
StepInterface step = trans.findRunThread("Your Step Name");
step.addRowListener(new RowAdapter() {
public void rowReadEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
// Here you get the rows as they are read by the step }
public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
// Here you get the rows as they are written by the step
}public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
}
}
);
// Now start the transformation threads...
//
trans.startThreads();
// If you want to wait until the transformation is finished...
//
trans.waitUntilFinished(); //
// If you want to know about the execution result.
//
Result result = trans.getResult();
|