use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.
the class BaseStreamStep method init.
public boolean init(StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface) {
Preconditions.checkNotNull(stepMetaInterface);
stepMeta = (BaseStreamStepMeta) stepMetaInterface;
stepMeta.setParentStepMeta(getStepMeta());
stepMeta.setFileName(stepMeta.getTransformationPath());
boolean superInit = super.init(stepMetaInterface, stepDataInterface);
try {
TransMeta transMeta = TransExecutorMeta.loadMappingMeta(stepMeta, getTransMeta().getRepository(), getTransMeta().getMetaStore(), getParentVariableSpace());
subtransExecutor = new SubtransExecutor(getStepname(), getTrans(), transMeta, true, new TransExecutorParameters(), environmentSubstitute(stepMeta.getSubStep()));
} catch (KettleException e) {
log.logError(e.getLocalizedMessage(), e);
return false;
}
List<CheckResultInterface> remarks = new ArrayList<>();
stepMeta.check(remarks, getTransMeta(), stepMeta.getParentStepMeta(), // these parameters are not used inside the method
null, // these parameters are not used inside the method
null, // these parameters are not used inside the method
null, // these parameters are not used inside the method
null, variables, getRepository(), getMetaStore());
boolean errorsPresent = remarks.stream().filter(result -> result.getType() == CheckResultInterface.TYPE_RESULT_ERROR).peek(result -> logError(result.getText())).count() > 0;
if (errorsPresent) {
return false;
}
return superInit;
}
use of org.pentaho.di.trans.step.StepDataInterface in project pdi-dataservice-server-plugin by pentaho.
the class AnnotationsQueryServiceTest method createPseudoAnnotate.
private DummyTransMeta createPseudoAnnotate(final ModelAnnotationGroup mag) {
final String magicKey = "KEY_MODEL_ANNOTATIONS";
DummyTransMeta annot1Meta = new DummyTransMeta() {
@Override
public StepInterface getStep(StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr, final Trans trans) {
return new DummyTrans(stepMeta, stepDataInterface, cnr, tr, trans) {
@Override
public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
ModelAnnotationGroup existing = (ModelAnnotationGroup) trans.getExtensionDataMap().get(magicKey);
if (existing == null) {
trans.getExtensionDataMap().put(magicKey, mag);
} else {
existing.addAll(mag);
}
return true;
}
};
}
};
return annot1Meta;
}
use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.
the class Trans method getEnded.
/**
* Gets the number of steps in the transformation that are in an end state, such as Finished, Halted, or Stopped.
*
* @return the number of ended steps
*/
public int getEnded() {
int nrEnded = 0;
if (steps == null) {
return 0;
}
for (int i = 0; i < steps.size(); i++) {
StepMetaDataCombi sid = steps.get(i);
StepDataInterface data = sid.data;
if ((sid.step != null && !sid.step.isRunning()) || // Should normally not be needed anymore, status is kept in data.
data.getStatus() == // Finished processing
StepExecutionStatus.STATUS_FINISHED || // Not launching because of init error
data.getStatus() == StepExecutionStatus.STATUS_HALTED || // Stopped because of an error
data.getStatus() == StepExecutionStatus.STATUS_STOPPED) {
nrEnded++;
}
}
return nrEnded;
}
use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.
the class RowGeneratorUnitTest method setUp.
@Before
public void setUp() throws KettleException {
// add variable to row generator step
StepMetaInterface stepMetaInterface = spy(new RowGeneratorMeta());
((RowGeneratorMeta) stepMetaInterface).setRowLimit("${ROW_LIMIT}");
String[] strings = {};
when(((RowGeneratorMeta) stepMetaInterface).getFieldName()).thenReturn(strings);
StepMeta stepMeta = new StepMeta();
stepMeta.setStepMetaInterface(stepMetaInterface);
stepMeta.setName("ROW_STEP_META");
StepDataInterface stepDataInterface = stepMeta.getStepMetaInterface().getStepData();
// add variable to transformation variable space
Map<String, String> map = new HashMap<String, String>();
map.put("ROW_LIMIT", "1440");
TransMeta transMeta = spy(new TransMeta());
transMeta.injectVariables(map);
when(transMeta.findStep(anyString())).thenReturn(stepMeta);
Trans trans = spy(new Trans(transMeta, null));
when(trans.getSocketRepository()).thenReturn(null);
when(trans.getLogChannelId()).thenReturn("ROW_LIMIT");
// prepare row generator, substitutes variable by value from transformation variable space
rowGenerator = spy(new RowGenerator(stepMeta, stepDataInterface, 0, transMeta, trans));
rowGenerator.initializeVariablesFrom(trans);
rowGenerator.init(stepMetaInterface, stepDataInterface);
}
use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.
the class UnivariateStatsMetaTest method testGetStep.
@Test
public void testGetStep() {
StepMeta mockStepMeta = mock(StepMeta.class);
when(mockStepMeta.getName()).thenReturn("testName");
StepDataInterface mockStepDataInterface = mock(StepDataInterface.class);
int cnr = 10;
TransMeta mockTransMeta = mock(TransMeta.class);
Trans mockTrans = mock(Trans.class);
when(mockTransMeta.findStep("testName")).thenReturn(mockStepMeta);
StepInterface step = new UnivariateStatsMeta().getStep(mockStepMeta, mockStepDataInterface, cnr, mockTransMeta, mockTrans);
assertTrue("Expected Step to be instanceof " + UnivariateStats.class, step instanceof UnivariateStats);
}
Aggregations