use of org.pentaho.commons.connection.memory.MemoryResultSet in project pdi-platform-plugin by pentaho.
the class PdiAction method registerAsStepListener.
/**
* Registers this component as a step listener of a transformation. This allows this component to receive rows of data
* from the transformation when it executes. These rows are made available to other components in the action sequence
* as a result set.
*
* @param stepName
* @param trans
* @return
* @throws KettleStepException
*/
protected void registerAsStepListener(String stepName, Trans trans) throws KettleStepException {
if (trans != null) {
List<StepMetaDataCombi> stepList = trans.getSteps();
// find the specified step
for (StepMetaDataCombi step : stepList) {
if (step.stepname.equals(stepName)) {
if (log.isDebugEnabled()) {
// $NON-NLS-1$
log.debug(Messages.getInstance().getString("Kettle.DEBUG_FOUND_STEP_IMPORTER"));
}
// this is the step we are looking for
if (log.isDebugEnabled()) {
// $NON-NLS-1$
log.debug(Messages.getInstance().getString("Kettle.DEBUG_GETTING_STEP_METADATA"));
}
RowMetaInterface row = trans.getTransMeta().getStepFields(stepName);
// create the metadata that the Pentaho result sets need
String[] fieldNames = row.getFieldNames();
String[][] columns = new String[1][fieldNames.length];
for (int column = 0; column < fieldNames.length; column++) {
columns[0][column] = fieldNames[column];
}
if (log.isDebugEnabled()) {
// $NON-NLS-1$
log.debug(Messages.getInstance().getString("Kettle.DEBUG_CREATING_RESULTSET_METADATA"));
}
MemoryMetaData metaData = new MemoryMetaData(columns, null);
transformationOutputRows = new MemoryResultSet(metaData);
transformationOutputErrorRows = new MemoryResultSet(metaData);
// add ourself as a row listener
step.step.addRowListener(this);
break;
}
}
}
}
Aggregations