Search in sources :

Example 71 with StreamInterface

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());
}
Also used : StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface) Test(org.junit.Test)

Example 72 with StreamInterface

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;
}
Also used : StepMeta(org.pentaho.di.trans.step.StepMeta) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 73 with StreamInterface

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();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 74 with StreamInterface

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();
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) SelectionEvent(org.eclipse.swt.events.SelectionEvent) StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) Stream(org.pentaho.di.trans.step.errorhandling.Stream) MenuItem(org.eclipse.swt.widgets.MenuItem) XulMenu(org.pentaho.ui.xul.containers.XulMenu) Menu(org.eclipse.swt.widgets.Menu) StepMeta(org.pentaho.di.trans.step.StepMeta) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 75 with StreamInterface

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;
}
Also used : KettleRowException(org.pentaho.di.core.exception.KettleRowException) KettleException(org.pentaho.di.core.exception.KettleException) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Aggregations

StreamInterface (org.pentaho.di.trans.step.errorhandling.StreamInterface)84 KettleException (org.pentaho.di.core.exception.KettleException)31 KettleStepException (org.pentaho.di.core.exception.KettleStepException)26 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)19 StepIOMetaInterface (org.pentaho.di.trans.step.StepIOMetaInterface)19 StepMeta (org.pentaho.di.trans.step.StepMeta)19 Stream (org.pentaho.di.trans.step.errorhandling.Stream)10 TableItem (org.eclipse.swt.widgets.TableItem)8 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)8 Test (org.junit.Test)7 CheckResult (org.pentaho.di.core.CheckResult)7 KettleRowException (org.pentaho.di.core.exception.KettleRowException)7 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)7 ArrayList (java.util.ArrayList)6 TransHopMeta (org.pentaho.di.trans.TransHopMeta)6 StepIOMeta (org.pentaho.di.trans.step.StepIOMeta)6 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)5 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)5 Point (org.pentaho.di.core.gui.Point)5 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)5