Created
September 14, 2012 19:36
-
-
Save mattyb149/3724213 to your computer and use it in GitHub Desktop.
PDI UDJC code to get Step Plugin info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
{ | |
// First, get a row from the default input hop | |
// | |
Object[] r = getRow(); | |
// If the row object is null, we are done processing. | |
// | |
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. | |
// | |
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(r, numCols); | |
for(int i=0;i<numCols;i++) { | |
ValueMetaInterface v = rmi.getValueMeta(i); | |
outputRow[i] = v.getString(pluginInfoCols[i]); | |
} | |
putRow(data.outputRowMeta, outputRow); | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment