本文整理匯總了Java中org.pentaho.di.trans.step.StepInterface.addRowListener方法的典型用法代碼示例。如果您正苦於以下問題:Java StepInterface.addRowListener方法的具體用法?Java StepInterface.addRowListener怎麽用?Java StepInterface.addRowListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.pentaho.di.trans.step.StepInterface
的用法示例。
在下文中一共展示了StepInterface.addRowListener方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test
import org.pentaho.di.trans.step.StepInterface; //導入方法依賴的package包/類
/**
* Runs the transformation with the below input parameters
* @param inputData JSON string
* @param ignoreMissingPath boolean
* @param defaultPathLeafToNull boolean
* @return Transformation Results
*/
private List<RowMetaAndData> test(String inputData, boolean ignoreMissingPath, boolean defaultPathLeafToNull)
throws Exception {
KettleEnvironment.init();
// Create a new transformation
TransMeta transMeta = new TransMeta();
transMeta.setName("testFastJsonInput");
PluginRegistry registry = PluginRegistry.getInstance();
// Create Injector
String injectorStepName = "injector step";
StepMeta injectorStep = TestUtilities.createInjectorStep(injectorStepName, registry);
transMeta.addStep(injectorStep);
// Create a FastJsonInput step
String fastJsonInputName = "FastJsonInput step";
StepMeta fastJsonInputStep = createFastJsonInputStep(fastJsonInputName, registry, ignoreMissingPath,
defaultPathLeafToNull);
transMeta.addStep(fastJsonInputStep);
// TransHopMeta between injector step and FastJsonInput
TransHopMeta injector_hop_fjis = new TransHopMeta(injectorStep, fastJsonInputStep);
transMeta.addTransHop(injector_hop_fjis);
// Create a dummy step
String dummyStepName = "dummy step";
StepMeta dummyStep = TestUtilities.createDummyStep(dummyStepName, registry);
transMeta.addStep(dummyStep);
// TransHopMeta between FastJsonInput and Dummy
TransHopMeta fjis_hop_dummy = new TransHopMeta(fastJsonInputStep, dummyStep);
transMeta.addTransHop(fjis_hop_dummy);
// Execute the transformation
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
// Create a row collector and add it to the dummy step interface
StepInterface si = trans.getStepInterface(dummyStepName, 0);
RowStepCollector dummyRowCollector = new RowStepCollector();
si.addRowListener(dummyRowCollector);
// Create a row producer
RowProducer rowProducer = trans.addRowProducer(injectorStepName, 0);
trans.startThreads();
// create the rows
List<RowMetaAndData> inputList = createInputData(inputData);
for (RowMetaAndData rowMetaAndData : inputList) {
rowProducer.putRow(rowMetaAndData.getRowMeta(), rowMetaAndData.getData());
}
rowProducer.finished();
trans.waitUntilFinished();
return dummyRowCollector.getRowsWritten();
}
示例2: testInjector
import org.pentaho.di.trans.step.StepInterface; //導入方法依賴的package包/類
/**
* Test case for injector step... also a show case on how
* to use injector.
*/
public void testInjector() throws Exception
{
EnvUtil.environmentInit();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("injectortest");
StepLoader steploader = StepLoader.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = steploader.getStepPluginID(im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = steploader.getStepPluginID(dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
TransHopMeta hi = new TransHopMeta(injectorStep, dummyStep);
transMeta.addTransHop(hi);
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector rc = new RowStepCollector();
si.addRowListener(rc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for (RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = rc.getRowsWritten();
checkRows(resultRows, inputList);
}
示例3: testCaseSensitiveNoPreviousSort
import org.pentaho.di.trans.step.StepInterface; //導入方法依賴的package包/類
public void testCaseSensitiveNoPreviousSort() throws Exception
{
EnvUtil.environmentInit();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
StepLoader steploader = StepLoader.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = steploader.getStepPluginID(im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] {"KEY"});
urm.setCaseInsensitive(new boolean[] {false});
String uniqueRowsStepPid = steploader.getStepPluginID(urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = steploader.getStepPluginID(dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for ( RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataCaseSensitiveNoPreviousSort(), resultRows);
}
示例4: testCaseInsensitiveNoPreviousSort
import org.pentaho.di.trans.step.StepInterface; //導入方法依賴的package包/類
public void testCaseInsensitiveNoPreviousSort() throws Exception
{
EnvUtil.environmentInit();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
StepLoader steploader = StepLoader.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = steploader.getStepPluginID(im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] {"KEY"});
urm.setCaseInsensitive(new boolean[] {true});
String uniqueRowsStepPid = steploader.getStepPluginID(urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = steploader.getStepPluginID(dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for ( RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataCaseInsensitiveNoPreviousSort(), resultRows);
}
示例5: testRowGenerator
import org.pentaho.di.trans.step.StepInterface; //導入方法依賴的package包/類
/**
* Test case for Row Generator step.
*/
public void testRowGenerator() throws Exception
{
EnvUtil.environmentInit();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("row generatortest");
StepLoader steploader = StepLoader.getInstance();
//
// create a row generator step...
//
String rowGeneratorStepname = "row generator step";
RowGeneratorMeta rm = new RowGeneratorMeta();
// Set the information of the row generator.
String rowGeneratorPid = steploader.getStepPluginID(rm);
StepMeta rowGeneratorStep = new StepMeta(rowGeneratorPid, rowGeneratorStepname, (StepMetaInterface)rm);
transMeta.addStep(rowGeneratorStep);
//
// Do the following specs 3 times.
//
String fieldName[] = { "string", "boolean", "integer" };
String type[] = { "String", "Boolean", "Integer" };
String value[] = { "string_value", "true", "20" };
String fieldFormat[] = { "", "", "" };
String group[] = { "", "", "" };
String decimal[] = { "", "", "" };
int intDummies[] = { -1, -1, -1 };
rm.setDefault();
rm.setFieldName(fieldName);
rm.setFieldType(type);
rm.setValue(value);
rm.setFieldLength(intDummies);
rm.setFieldPrecision(intDummies);
rm.setRowLimit("3");
rm.setFieldFormat(fieldFormat);
rm.setGroup(group);
rm.setDecimal(decimal);
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = steploader.getStepPluginID(dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
TransHopMeta hi = new TransHopMeta(rowGeneratorStep, dummyStep);
transMeta.addTransHop(hi);
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector rc = new RowStepCollector();
si.addRowListener(rc);
trans.startThreads();
trans.waitUntilFinished();
List<RowMetaAndData> checkList = createData();
List<RowMetaAndData> resultRows = rc.getRowsWritten();
checkRows(resultRows, checkList);
}
示例6: executeTestTransformation
import org.pentaho.di.trans.step.StepInterface; //導入方法依賴的package包/類
public static List<RowMetaAndData> executeTestTransformation(TransMeta transMeta, String injectorStepname, String testStepname, String dummyStepname, List<RowMetaAndData> inputData) throws KettleException {
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
// Capture the rows that come out of the dummy step...
//
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
// Add a row producer...
//
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
// Start the steps...
//
trans.startThreads();
// Inject the actual test rows...
//
List<RowMetaAndData> inputList = inputData;
Iterator<RowMetaAndData> it = inputList.iterator();
while ( it.hasNext() )
{
RowMetaAndData rm = (RowMetaAndData)it.next();
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
// Wait until the transformation is finished...
//
trans.waitUntilFinished();
// If there is an error in the result, throw an exception here...
//
if (trans.getResult().getNrErrors()>0) {
throw new KettleException("Test transformation finished with errors. Check the log.");
}
// Return the result from the dummy step...
//
return dummyRc.getRowsRead();
}
示例7: run
import org.pentaho.di.trans.step.StepInterface; //導入方法依賴的package包/類
public void run() throws Exception {
FileObject tempFile = KettleVFS.createTempFile("datacleaner", ".kettlestream",
System.getProperty("java.io.tmpdir"));
filename = KettleVFS.getFilename(tempFile);
outputStream = new DataOutputStream(KettleVFS.getOutputStream(tempFile, false));
log.logBasic("DataCleaner temp file created: " + filename);
RowMetaInterface rowMeta = transMeta.getStepFields(stepMeta);
log.logBasic("Opened an output stream to DataCleaner.");
// Write the transformation name, the step name and the row metadata
// first...
//
outputStream.writeUTF(transMeta.getName());
log.logBasic("wrote the transformation name.");
outputStream.writeUTF(stepMeta.getName());
log.logBasic("wrote the step name.");
rowMeta.writeMeta(outputStream);
log.logBasic("Wrote the row metadata");
// Add a row listener to the selected step...
//
List<StepInterface> steps = trans.findBaseSteps(stepMeta.getName());
// Just do one step copy for the time being...
//
StepInterface step = steps.get(0);
step.addRowListener(this);
log.logBasic("Added the row listener to step: " + step.toString());
// Now start the transformation...
//
trans.startThreads();
log.logBasic("Started the transformation to profile... waiting until the transformation has finished");
trans.waitUntilFinished();
log.logBasic("The transformation to profile finished.");
}