use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class TransExecutorMetaTest method secondStreamIsInternalTransformationsOutput.
@Test
public void secondStreamIsInternalTransformationsOutput() throws Exception {
StreamInterface stream = mockStream();
StepIOMetaInterface stepIo = mockStepIo(stream, 1);
TransExecutorMeta meta = new TransExecutorMeta();
meta = spy(meta);
when(meta.getStepIOMeta()).thenReturn(stepIo);
doCallRealMethod().when(meta).handleStreamSelection(any(StreamInterface.class));
meta.handleStreamSelection(stream);
assertEquals(stream.getStepMeta(), meta.getOutputRowsSourceStepMeta());
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class TransExecutorMetaTest method mockStream.
private static StreamInterface mockStream() {
StepMeta stepMeta = mock(StepMeta.class);
StreamInterface stream = mock(StreamInterface.class);
when(stream.getStepMeta()).thenReturn(stepMeta);
return stream;
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class StreamLookupDialog method getData.
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData() {
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "StreamLookupDialog.Log.GettingKeyInfo"));
}
if (input.getKeystream() != null) {
for (int i = 0; i < input.getKeystream().length; i++) {
TableItem item = wKey.table.getItem(i);
if (input.getKeystream()[i] != null) {
item.setText(1, input.getKeystream()[i]);
}
if (input.getKeylookup()[i] != null) {
item.setText(2, input.getKeylookup()[i]);
}
}
}
if (input.getValue() != null) {
for (int i = 0; i < input.getValue().length; i++) {
TableItem item = wReturn.table.getItem(i);
if (input.getValue()[i] != null) {
item.setText(1, input.getValue()[i]);
}
if (input.getValueName()[i] != null && !input.getValueName()[i].equals(input.getValue()[i])) {
item.setText(2, input.getValueName()[i]);
}
if (input.getValueDefault()[i] != null) {
item.setText(3, input.getValueDefault()[i]);
}
item.setText(4, ValueMetaFactory.getValueMetaName(input.getValueDefaultType()[i]));
}
}
StreamInterface infoStream = input.getStepIOMeta().getInfoStreams().get(0);
wStep.setText(Const.NVL(infoStream.getStepname(), ""));
boolean isPreserveMemory = input.isMemoryPreservationActive();
wPreserveMemory.setSelection(isPreserveMemory);
if (isPreserveMemory) {
wSortedList.setEnabled(true);
wIntegerPair.setEnabled(true);
}
// PDI-2107 usually this is sorted list or integer pair
// for backward compatibility they can be set both
// but user will be forced to choose only one option later.
wSortedList.setSelection(input.isUsingSortedList());
wIntegerPair.setSelection(input.isUsingIntegerPair());
wKey.setRowNums();
wKey.optWidth(true);
wReturn.setRowNums();
wReturn.optWidth(true);
wStepname.selectAll();
wStepname.setFocus();
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class TransGraph method addCandidateAsHop.
private void addCandidateAsHop(int mouseX, int mouseY) {
boolean forward = startHopStep != null;
StepMeta fromStep = candidate.getFromStep();
StepMeta toStep = candidate.getToStep();
// See what the options are.
// - Does the source step has multiple stream options?
// - Does the target step have multiple input stream options?
//
List<StreamInterface> streams = new ArrayList<>();
StepIOMetaInterface fromIoMeta = fromStep.getStepMetaInterface().getStepIOMeta();
List<StreamInterface> targetStreams = fromIoMeta.getTargetStreams();
if (forward) {
streams.addAll(targetStreams);
}
StepIOMetaInterface toIoMeta = toStep.getStepMetaInterface().getStepIOMeta();
List<StreamInterface> infoStreams = toIoMeta.getInfoStreams();
if (!forward) {
streams.addAll(infoStreams);
}
if (forward) {
if (fromIoMeta.isOutputProducer() && toStep.equals(currentStep)) {
streams.add(new Stream(StreamType.OUTPUT, fromStep, BaseMessages.getString(PKG, "Spoon.Hop.MainOutputOfStep"), StreamIcon.OUTPUT, null));
}
if (fromStep.supportsErrorHandling() && toStep.equals(currentStep)) {
streams.add(new Stream(StreamType.ERROR, fromStep, BaseMessages.getString(PKG, "Spoon.Hop.ErrorHandlingOfStep"), StreamIcon.ERROR, null));
}
} else {
if (toIoMeta.isInputAcceptor() && fromStep.equals(currentStep)) {
streams.add(new Stream(StreamType.INPUT, toStep, BaseMessages.getString(PKG, "Spoon.Hop.MainInputOfStep"), StreamIcon.INPUT, null));
}
if (fromStep.supportsErrorHandling() && fromStep.equals(currentStep)) {
streams.add(new Stream(StreamType.ERROR, fromStep, BaseMessages.getString(PKG, "Spoon.Hop.ErrorHandlingOfStep"), StreamIcon.ERROR, null));
}
}
//
if (forward) {
streams.addAll(fromStep.getStepMetaInterface().getOptionalStreams());
} else {
streams.addAll(toStep.getStepMetaInterface().getOptionalStreams());
}
//
if (streams.size() > 1) {
// Show a pop-up menu with all the possible options...
//
Menu menu = new Menu(canvas);
for (final StreamInterface stream : streams) {
MenuItem item = new MenuItem(menu, SWT.NONE);
item.setText(Const.NVL(stream.getDescription(), ""));
item.setImage(getImageFor(stream));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
addHop(stream);
}
});
}
menu.setLocation(canvas.toDisplay(mouseX, mouseY));
menu.setVisible(true);
return;
}
if (streams.size() == 1) {
addHop(streams.get(0));
} else {
return;
}
/*
*
* if (transMeta.findTransHop(candidate) == null) { spoon.newHop(transMeta, candidate); } if (startErrorHopStep) {
* addErrorHop(); } if (startTargetHopStream != null) { // Auto-configure the target in the source step... //
* startTargetHopStream.setStepMeta(candidate.getToStep());
* startTargetHopStream.setStepname(candidate.getToStep().getName()); startTargetHopStream = null; }
*/
candidate = null;
selectedSteps = null;
startHopStep = null;
endHopLocation = null;
startErrorHopStep = false;
// redraw();
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class Append method init.
/**
* @see StepInterface#init(org.pentaho.di.trans.step.StepMetaInterface , org.pentaho.di.trans.step.StepDataInterface)
*/
public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
meta = (AppendMeta) smi;
data = (AppendData) sdi;
if (super.init(smi, sdi)) {
data.processHead = true;
data.processTail = false;
data.firstTail = true;
List<StreamInterface> infoStreams = meta.getStepIOMeta().getInfoStreams();
StreamInterface headStream = infoStreams.get(0);
StreamInterface tailStream = infoStreams.get(1);
if (meta.headStepname != null) {
headStream.setStepMeta(getTransMeta().findStep(meta.headStepname));
}
if (meta.tailStepname != null) {
tailStream.setStepMeta(getTransMeta().findStep(meta.tailStepname));
}
if (headStream.getStepname() == null || tailStream.getStepname() == null) {
logError(BaseMessages.getString(PKG, "AppendRows.Log.BothHopsAreNeeded"));
} else {
try {
data.headRowSet = findInputRowSet(headStream.getStepname());
data.tailRowSet = findInputRowSet(tailStream.getStepname());
return true;
} catch (Exception e) {
logError(e.getMessage());
return false;
}
}
}
return false;
}
Aggregations