Search in sources :

Example 6 with StreamInterface

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

the class MergeJoinDialog method getMeta.

private void getMeta(MergeJoinMeta meta) {
    List<StreamInterface> infoStreams = meta.getStepIOMeta().getInfoStreams();
    infoStreams.get(0).setStepMeta(transMeta.findStep(wStep1.getText()));
    infoStreams.get(1).setStepMeta(transMeta.findStep(wStep2.getText()));
    meta.setJoinType(wType.getText());
    int nrKeys1 = wKeys1.nrNonEmpty();
    int nrKeys2 = wKeys2.nrNonEmpty();
    meta.allocate(nrKeys1, nrKeys2);
    // CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrKeys1; i++) {
        TableItem item = wKeys1.getNonEmpty(i);
        meta.getKeyFields1()[i] = item.getText(1);
    }
    // CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrKeys2; i++) {
        TableItem item = wKeys2.getNonEmpty(i);
        meta.getKeyFields2()[i] = item.getText(1);
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 7 with StreamInterface

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

the class MergeJoinDialog method getKeys2.

private void getKeys2() {
    MergeJoinMeta joinMeta = new MergeJoinMeta();
    getMeta(joinMeta);
    try {
        List<StreamInterface> infoStreams = joinMeta.getStepIOMeta().getInfoStreams();
        StepMeta stepMeta = infoStreams.get(1).getStepMeta();
        if (stepMeta != null) {
            RowMetaInterface prev = transMeta.getStepFields(stepMeta);
            if (prev != null) {
                BaseStepDialog.getFieldsFromPrevious(prev, wKeys2, 1, new int[] { 1 }, new int[] {}, -1, -1, null);
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "MergeJoinDialog.ErrorGettingFields.DialogTitle"), BaseMessages.getString(PKG, "MergeJoinDialog.ErrorGettingFields.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MergeJoinMeta(org.pentaho.di.trans.steps.mergejoin.MergeJoinMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 8 with StreamInterface

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

the class FuzzyMatchDialog method ok.

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;
    }
    input.setMainStreamField(wMainStreamField.getText());
    input.setLookupField(wLookupField.getText());
    input.setAlgorithmType(FuzzyMatchMeta.getAlgorithmTypeByDesc(wAlgorithm.getText()));
    input.setCaseSensitive(wcaseSensitive.getSelection());
    input.setGetCloserValue(wgetCloserValue.getSelection());
    input.setMaximalValue(wmaxValue.getText());
    input.setMinimalValue(wminValue.getText());
    input.setOutputMatchField(wmatchField.getText());
    input.setOutputValueField(wvalueField.getText());
    input.setSeparator(wseparator.getText());
    int nrvalues = wReturn.nrNonEmpty();
    input.allocate(nrvalues);
    if (isDebug()) {
        logDebug(BaseMessages.getString(PKG, "FuzzyMatchDialog.Log.FoundFields", nrvalues + ""));
    }
    // CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrvalues; i++) {
        TableItem item = wReturn.getNonEmpty(i);
        input.getValue()[i] = item.getText(1);
        input.getValueName()[i] = item.getText(2);
        if (input.getValueName()[i] == null || input.getValueName()[i].length() == 0) {
            input.getValueName()[i] = input.getValue()[i];
        }
    }
    StreamInterface infoStream = input.getStepIOMeta().getInfoStreams().get(0);
    infoStream.setStepMeta(transMeta.findStep(wStep.getText()));
    if (infoStream.getStepMeta() == null) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        if (Utils.isEmpty(wStep.getText())) {
            mb.setMessage(BaseMessages.getString(PKG, "FuzzyMatchDialog.NotStepSpecified.DialogMessage", wStep.getText()));
        } else {
            mb.setMessage(BaseMessages.getString(PKG, "FuzzyMatchDialog.StepCanNotFound.DialogMessage", wStep.getText()));
        }
        mb.setText(BaseMessages.getString(PKG, "FuzzyMatchDialog.StepCanNotFound.DialogTitle"));
        mb.open();
    }
    // return value
    stepname = wStepname.getText();
    dispose();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 9 with StreamInterface

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

the class TransMeta method realClone.

/**
 * Perform a real clone of the transformation meta-data object, including cloning all lists and copying all values. If
 * the doClear parameter is true, the clone will be cleared of ALL values before the copy. If false, only the copied
 * fields will be cleared.
 *
 * @param doClear
 *          Whether to clear all of the clone's data before copying from the source object
 * @return a real clone of the calling object
 */
public Object realClone(boolean doClear) {
    try {
        TransMeta transMeta = (TransMeta) super.clone();
        if (doClear) {
            transMeta.clear();
        } else {
            // Clear out the things we're replacing below
            transMeta.databases = new ArrayList<>();
            transMeta.steps = new ArrayList<>();
            transMeta.hops = new ArrayList<>();
            transMeta.notes = new ArrayList<>();
            transMeta.dependencies = new ArrayList<>();
            transMeta.partitionSchemas = new ArrayList<>();
            transMeta.slaveServers = new ArrayList<>();
            transMeta.clusterSchemas = new ArrayList<>();
            transMeta.namedParams = new NamedParamsDefault();
            transMeta.stepChangeListeners = new ArrayList<>();
        }
        for (DatabaseMeta db : databases) {
            transMeta.addDatabase((DatabaseMeta) db.clone());
        }
        for (StepMeta step : steps) {
            transMeta.addStep((StepMeta) step.clone());
        }
        // PDI-15799: Step references are original yet. Set them to the clones.
        for (StepMeta step : transMeta.getSteps()) {
            final StepMetaInterface stepMetaInterface = step.getStepMetaInterface();
            if (stepMetaInterface != null) {
                final StepIOMetaInterface stepIOMeta = stepMetaInterface.getStepIOMeta();
                if (stepIOMeta != null) {
                    for (StreamInterface stream : stepIOMeta.getInfoStreams()) {
                        String streamStepName = stream.getStepname();
                        if (streamStepName != null) {
                            StepMeta streamStepMeta = transMeta.findStep(streamStepName);
                            stream.setStepMeta(streamStepMeta);
                        }
                    }
                }
            }
        }
        for (TransHopMeta hop : hops) {
            transMeta.addTransHop((TransHopMeta) hop.clone());
        }
        for (NotePadMeta note : notes) {
            transMeta.addNote((NotePadMeta) note.clone());
        }
        for (TransDependency dep : dependencies) {
            transMeta.addDependency((TransDependency) dep.clone());
        }
        for (SlaveServer slave : slaveServers) {
            transMeta.getSlaveServers().add((SlaveServer) slave.clone());
        }
        for (ClusterSchema schema : clusterSchemas) {
            transMeta.getClusterSchemas().add(schema.clone());
        }
        for (PartitionSchema schema : partitionSchemas) {
            transMeta.getPartitionSchemas().add((PartitionSchema) schema.clone());
        }
        for (String key : listParameters()) {
            transMeta.addParameterDefinition(key, getParameterDefault(key), getParameterDescription(key));
        }
        return transMeta;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : NamedParamsDefault(org.pentaho.di.core.parameters.NamedParamsDefault) PartitionSchema(org.pentaho.di.partition.PartitionSchema) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) IOException(java.io.IOException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) NotePadMeta(org.pentaho.di.core.NotePadMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 10 with StreamInterface

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

the class TransPainter method drawLine.

private void drawLine(StepMeta fs, StepMeta ts, TransHopMeta hi, boolean is_candidate) {
    int[] line = getLine(fs, ts);
    EColor col;
    ELineStyle linestyle = ELineStyle.SOLID;
    int activeLinewidth = linewidth;
    EImage arrow;
    if (is_candidate) {
        col = EColor.BLUE;
        arrow = EImage.ARROW_CANDIDATE;
    } else {
        if (hi.isEnabled()) {
            if (fs.isSendingErrorRowsToStep(ts)) {
                col = EColor.RED;
                linestyle = ELineStyle.DASH;
                activeLinewidth = linewidth + 1;
                arrow = EImage.ARROW_ERROR;
            } else {
                col = EColor.HOP_DEFAULT;
                arrow = EImage.ARROW_DEFAULT;
            }
        } else {
            col = EColor.GRAY;
            arrow = EImage.ARROW_DISABLED;
        }
    }
    if (hi.split) {
        activeLinewidth = linewidth + 2;
    }
    // Check to see if the source step is an info step for the target step.
    // 
    StepIOMetaInterface ioMeta = ts.getStepMetaInterface().getStepIOMeta();
    List<StreamInterface> infoStreams = ioMeta.getInfoStreams();
    if (!infoStreams.isEmpty()) {
        // 
        for (StreamInterface stream : infoStreams) {
            if (fs.getName().equalsIgnoreCase(stream.getStepname())) {
                // 
                if (fs.getCopies() > 1) {
                    // This is not a desirable situation, it will always end in error.
                    // As such, it's better not to give feedback on it.
                    // We do this by drawing an error icon over the hop...
                    // 
                    col = EColor.RED;
                    arrow = EImage.ARROW_ERROR;
                }
            }
        }
    }
    gc.setForeground(col);
    gc.setLineStyle(linestyle);
    gc.setLineWidth(activeLinewidth);
    drawArrow(arrow, line, hi, fs, ts);
    if (hi.split) {
        gc.setLineWidth(linewidth);
    }
    gc.setForeground(EColor.BLACK);
    gc.setBackground(EColor.BACKGROUND);
    gc.setLineStyle(ELineStyle.SOLID);
}
Also used : EImage(org.pentaho.di.core.gui.PrimitiveGCInterface.EImage) StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) EColor(org.pentaho.di.core.gui.PrimitiveGCInterface.EColor) ELineStyle(org.pentaho.di.core.gui.PrimitiveGCInterface.ELineStyle) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) 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