Skip to content

Instantly share code, notes, and snippets.

@mattyb149
Created September 15, 2012 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyb149/3726209 to your computer and use it in GitHub Desktop.
Save mattyb149/3726209 to your computer and use it in GitHub Desktop.
UDJC PDI step acting as Input generator
import org.pentaho.di.core.plugins.*;
import org.pentaho.di.core.row.*;
import java.util.List;
String type;
String id;
String name;
String description;
String libraries;
String imagefile;
String classname;
String category;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
RowBuffer rowBuffer = PluginRegistry.getInstance().getPluginInformation(StepPluginType.class);
RowMetaInterface rmi = rowBuffer.getRowMeta();
int numCols = rmi.size();
List pluginInfo = rowBuffer.getBuffer();
int numRows = pluginInfo.size();
for(int rowNum=0;rowNum<numRows;rowNum++) {
Object[] pluginInfoCols = (Object[])pluginInfo.get(rowNum);
Object[] outputRow = createOutputRow(pluginInfoCols, numCols);
for(int i=0;i<numCols;i++) {
ValueMetaInterface v = rmi.getValueMeta(i);
try {
outputRow[i] = v.getString(pluginInfoCols[i]);
}
catch(Exception e){}
}
putRow(data.outputRowMeta, outputRow);
}
setOutputDone();
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment