Search in sources :

Example 21 with StepIOMetaInterface

use of org.pentaho.di.trans.step.StepIOMetaInterface in project pentaho-kettle by pentaho.

the class TransExecutorMetaTest method thirdStreamIsExecutionResultFiles.

@Test
public void thirdStreamIsExecutionResultFiles() throws Exception {
    StreamInterface stream = mockStream();
    StepIOMetaInterface stepIo = mockStepIo(stream, 2);
    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.getResultFilesTargetStepMeta());
}
Also used : StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface) Test(org.junit.Test)

Example 22 with StepIOMetaInterface

use of org.pentaho.di.trans.step.StepIOMetaInterface 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 23 with StepIOMetaInterface

use of org.pentaho.di.trans.step.StepIOMetaInterface 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)

Aggregations

StepIOMetaInterface (org.pentaho.di.trans.step.StepIOMetaInterface)23 StreamInterface (org.pentaho.di.trans.step.errorhandling.StreamInterface)19 StepMeta (org.pentaho.di.trans.step.StepMeta)10 KettleException (org.pentaho.di.core.exception.KettleException)7 TransHopMeta (org.pentaho.di.trans.TransHopMeta)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)6 Point (org.pentaho.di.core.gui.Point)6 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 AreaOwner (org.pentaho.di.core.gui.AreaOwner)4 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)4 RowSet (org.pentaho.di.core.RowSet)3 EImage (org.pentaho.di.core.gui.PrimitiveGCInterface.EImage)3 TransMeta (org.pentaho.di.trans.TransMeta)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 NotePadMeta (org.pentaho.di.core.NotePadMeta)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)2 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)2