Search in sources :

Example 61 with StreamInterface

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

the class BaseStepMeta method clone.

/*
   * (non-Javadoc)
   *
   * @see java.lang.Object#clone()
   */
@Override
public Object clone() {
    try {
        BaseStepMeta retval = (BaseStepMeta) super.clone();
        // then the step references must be corrected.
        if (ioMeta != null) {
            StepIOMetaInterface stepIOMeta = new StepIOMeta(ioMeta.isInputAcceptor(), ioMeta.isOutputProducer(), ioMeta.isInputOptional(), ioMeta.isSortedDataRequired(), ioMeta.isInputDynamic(), ioMeta.isOutputDynamic());
            List<StreamInterface> infoStreams = ioMeta.getInfoStreams();
            for (StreamInterface infoStream : infoStreams) {
                stepIOMeta.addStream(new Stream(infoStream));
            }
            List<StreamInterface> targetStreams = ioMeta.getTargetStreams();
            for (StreamInterface targetStream : targetStreams) {
                stepIOMeta.addStream(new Stream(targetStream));
            }
            retval.ioMeta = stepIOMeta;
        }
        return retval;
    } catch (CloneNotSupportedException e) {
        return null;
    }
}
Also used : Stream(org.pentaho.di.trans.step.errorhandling.Stream) InputStream(java.io.InputStream) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 62 with StreamInterface

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

the class FuzzyMatchMeta method getXML.

public String getXML() {
    StringBuilder retval = new StringBuilder();
    StreamInterface infoStream = getStepIOMeta().getInfoStreams().get(0);
    retval.append("    " + XMLHandler.addTagValue("from", infoStream.getStepname()));
    retval.append("    " + XMLHandler.addTagValue("lookupfield", lookupfield));
    retval.append("    " + XMLHandler.addTagValue("mainstreamfield", mainstreamfield));
    retval.append("    " + XMLHandler.addTagValue("outputmatchfield", outputmatchfield));
    retval.append("    " + XMLHandler.addTagValue("outputvaluefield", outputvaluefield));
    retval.append("    " + XMLHandler.addTagValue("caseSensitive", caseSensitive));
    retval.append("    " + XMLHandler.addTagValue("closervalue", closervalue));
    retval.append("    " + XMLHandler.addTagValue("minimalValue", minimalValue));
    retval.append("    " + XMLHandler.addTagValue("maximalValue", maximalValue));
    retval.append("    " + XMLHandler.addTagValue("separator", separator));
    retval.append("    ").append(XMLHandler.addTagValue("algorithm", getAlgorithmTypeCode(algorithm)));
    retval.append("    <lookup>" + Const.CR);
    for (int i = 0; i < value.length; i++) {
        retval.append("      <value>" + Const.CR);
        retval.append("        " + XMLHandler.addTagValue("name", value[i]));
        retval.append("        " + XMLHandler.addTagValue("rename", valueName[i]));
        retval.append("      </value>" + Const.CR);
    }
    retval.append("    </lookup>" + Const.CR);
    return retval.toString();
}
Also used : StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 63 with StreamInterface

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

the class FuzzyMatchMeta method getStepIOMeta.

/**
 * Returns the Input/Output metadata for this step. The generator step only produces output, does not accept input!
 */
public StepIOMetaInterface getStepIOMeta() {
    if (ioMeta == null) {
        ioMeta = new StepIOMeta(true, true, false, false, false, false);
        StreamInterface stream = new Stream(StreamType.INFO, null, BaseMessages.getString(PKG, "FuzzyMatchMeta.InfoStream.Description"), StreamIcon.INFO, null);
        ioMeta.addStream(stream);
    }
    return ioMeta;
}
Also used : StepIOMeta(org.pentaho.di.trans.step.StepIOMeta) Stream(org.pentaho.di.trans.step.errorhandling.Stream) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 64 with StreamInterface

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

the class FuzzyMatchMeta method readData.

private void readData(Node stepnode, List<? extends SharedObjectInterface> databases) throws KettleXMLException {
    try {
        String lookupFromStepname = XMLHandler.getTagValue(stepnode, "from");
        StreamInterface infoStream = getStepIOMeta().getInfoStreams().get(0);
        infoStream.setSubject(lookupFromStepname);
        lookupfield = XMLHandler.getTagValue(stepnode, "lookupfield");
        mainstreamfield = XMLHandler.getTagValue(stepnode, "mainstreamfield");
        caseSensitive = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "caseSensitive"));
        closervalue = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "closervalue"));
        minimalValue = XMLHandler.getTagValue(stepnode, "minimalValue");
        maximalValue = XMLHandler.getTagValue(stepnode, "maximalValue");
        separator = XMLHandler.getTagValue(stepnode, "separator");
        outputmatchfield = XMLHandler.getTagValue(stepnode, "outputmatchfield");
        outputvaluefield = XMLHandler.getTagValue(stepnode, "outputvaluefield");
        algorithm = getAlgorithmTypeByCode(Const.NVL(XMLHandler.getTagValue(stepnode, "algorithm"), ""));
        Node lookup = XMLHandler.getSubNode(stepnode, "lookup");
        int nrvalues = XMLHandler.countNodes(lookup, "value");
        allocate(nrvalues);
        for (int i = 0; i < nrvalues; i++) {
            Node vnode = XMLHandler.getSubNodeByNr(lookup, "value", i);
            value[i] = XMLHandler.getTagValue(vnode, "name");
            valueName[i] = XMLHandler.getTagValue(vnode, "rename");
            if (valueName[i] == null) {
                // default: same name to return!
                valueName[i] = value[i];
            }
        }
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "FuzzyMatchMeta.Exception.UnableToLoadStepInfoFromXML"), e);
    }
}
Also used : Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 65 with StreamInterface

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

the class FuzzyMatchMeta method saveRep.

public void saveRep(Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step) throws KettleException {
    try {
        StreamInterface infoStream = getStepIOMeta().getInfoStreams().get(0);
        rep.saveStepAttribute(id_transformation, id_step, "lookup_from_step", infoStream.getStepname());
        rep.saveStepAttribute(id_transformation, id_step, "lookupfield", lookupfield);
        rep.saveStepAttribute(id_transformation, id_step, "mainstreamfield", mainstreamfield);
        rep.saveStepAttribute(id_transformation, id_step, "outputmatchfield", outputmatchfield);
        rep.saveStepAttribute(id_transformation, id_step, "outputvaluefield", outputvaluefield);
        rep.saveStepAttribute(id_transformation, id_step, "caseSensitive", caseSensitive);
        rep.saveStepAttribute(id_transformation, id_step, "closervalue", closervalue);
        rep.saveStepAttribute(id_transformation, id_step, "minimalValue", minimalValue);
        rep.saveStepAttribute(id_transformation, id_step, "maximalValue", maximalValue);
        rep.saveStepAttribute(id_transformation, id_step, "separator", separator);
        rep.saveStepAttribute(id_transformation, id_step, "algorithm", getAlgorithmTypeCode(algorithm));
        for (int i = 0; i < value.length; i++) {
            rep.saveStepAttribute(id_transformation, id_step, i, "return_value_name", value[i]);
            rep.saveStepAttribute(id_transformation, id_step, i, "return_value_rename", valueName[i]);
        }
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(PKG, "FuzzyMatchMeta.Exception.UnableToSaveStepInfoToRepository") + id_step, e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) 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