Search in sources :

Example 41 with StreamInterface

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

the class TransExecutorMeta method handleStreamSelection.

/**
 * When an optional stream is selected, this method is called to handled the ETL metadata implications of that.
 *
 * @param stream The optional stream to handle.
 */
public void handleStreamSelection(StreamInterface stream) {
    // This step targets another step.
    // Make sure that we don't specify the same step for more than 1 target...
    List<StreamInterface> targets = getStepIOMeta().getTargetStreams();
    int index = targets.indexOf(stream);
    StepMeta step = targets.get(index).getStepMeta();
    switch(index) {
        case 0:
            setExecutionResultTargetStepMeta(step);
            break;
        case 1:
            setOutputRowsSourceStepMeta(step);
            break;
        case 2:
            setResultFilesTargetStepMeta(step);
            break;
        case 3:
            setExecutorsOutputStepMeta(step);
        default:
            break;
    }
}
Also used : StepMeta(org.pentaho.di.trans.step.StepMeta) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 42 with StreamInterface

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

the class TableInputMeta method getXML.

public String getXML() {
    StringBuilder retval = new StringBuilder();
    retval.append("    " + XMLHandler.addTagValue("connection", databaseMeta == null ? "" : databaseMeta.getName()));
    retval.append("    " + XMLHandler.addTagValue("sql", sql));
    retval.append("    " + XMLHandler.addTagValue("limit", rowLimit));
    StreamInterface infoStream = getStepIOMeta().getInfoStreams().get(0);
    retval.append("    " + XMLHandler.addTagValue("lookup", infoStream.getStepname()));
    retval.append("    " + XMLHandler.addTagValue("execute_each_row", executeEachInputRow));
    retval.append("    " + XMLHandler.addTagValue("variables_active", variableReplacementActive));
    retval.append("    " + XMLHandler.addTagValue("lazy_conversion_active", lazyConversionActive));
    return retval.toString();
}
Also used : StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 43 with StreamInterface

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

the class TableInputMeta method readRep.

public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException {
    this.databases = databases;
    try {
        databaseMeta = rep.loadDatabaseMetaFromStepAttribute(id_step, "id_connection", databases);
        sql = rep.getStepAttributeString(id_step, "sql");
        rowLimit = rep.getStepAttributeString(id_step, "limit");
        if (rowLimit == null) {
            rowLimit = Long.toString(rep.getStepAttributeInteger(id_step, "limit"));
        }
        String lookupFromStepname = rep.getStepAttributeString(id_step, "lookup");
        StreamInterface infoStream = getStepIOMeta().getInfoStreams().get(0);
        infoStream.setSubject(lookupFromStepname);
        executeEachInputRow = rep.getStepAttributeBoolean(id_step, "execute_each_row");
        variableReplacementActive = rep.getStepAttributeBoolean(id_step, "variables_active");
        lazyConversionActive = rep.getStepAttributeBoolean(id_step, "lazy_conversion_active");
    } catch (Exception e) {
        throw new KettleException("Unexpected error reading step information from the repository", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 44 with StreamInterface

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

the class TableInputMeta method readData.

private void readData(Node stepnode, List<? extends SharedObjectInterface> databases) throws KettleXMLException {
    this.databases = databases;
    try {
        databaseMeta = DatabaseMeta.findDatabase(databases, XMLHandler.getTagValue(stepnode, "connection"));
        sql = XMLHandler.getTagValue(stepnode, "sql");
        rowLimit = XMLHandler.getTagValue(stepnode, "limit");
        String lookupFromStepname = XMLHandler.getTagValue(stepnode, "lookup");
        StreamInterface infoStream = getStepIOMeta().getInfoStreams().get(0);
        infoStream.setSubject(lookupFromStepname);
        executeEachInputRow = "Y".equals(XMLHandler.getTagValue(stepnode, "execute_each_row"));
        variableReplacementActive = "Y".equals(XMLHandler.getTagValue(stepnode, "variables_active"));
        lazyConversionActive = "Y".equals(XMLHandler.getTagValue(stepnode, "lazy_conversion_active"));
    } catch (Exception e) {
        throw new KettleXMLException("Unable to load step info from XML", e);
    }
}
Also used : KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 45 with StreamInterface

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

the class StreamLookupMeta method check.

@Override
public void check(List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository, IMetaStore metaStore) {
    CheckResult cr;
    if (prev != null && prev.size() > 0) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.StepReceivingFields", prev.size() + ""), stepMeta);
        remarks.add(cr);
        String error_message = "";
        boolean error_found = false;
        // Check the fields from the previous stream!
        for (String aKeystream : getKeystream()) {
            int idx = prev.indexOfValue(aKeystream);
            if (idx < 0) {
                error_message += "\t\t" + aKeystream + Const.CR;
                error_found = true;
            }
        }
        if (error_found) {
            error_message = BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.FieldsNotFound") + Const.CR + Const.CR + error_message;
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
            remarks.add(cr);
        } else {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.AllFieldsFound"), stepMeta);
            remarks.add(cr);
        }
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.CouldNotFindFieldsFromPreviousSteps"), stepMeta);
        remarks.add(cr);
    }
    if (info != null && info.size() > 0) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.StepReceivingLookupData", info.size() + ""), stepMeta);
        remarks.add(cr);
        String error_message = "";
        boolean error_found = false;
        // Check the fields from the lookup stream!
        for (String aKeylookup : getKeylookup()) {
            int idx = info.indexOfValue(aKeylookup);
            if (idx < 0) {
                error_message += "\t\t" + aKeylookup + Const.CR;
                error_found = true;
            }
        }
        if (error_found) {
            error_message = BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.FieldsNotFoundInLookupStream") + Const.CR + Const.CR + error_message;
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
            remarks.add(cr);
        } else {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.AllFieldsFoundInTheLookupStream"), stepMeta);
            remarks.add(cr);
        }
        // Check the values to retrieve from the lookup stream!
        for (String aValue : getValue()) {
            int idx = info.indexOfValue(aValue);
            if (idx < 0) {
                error_message += "\t\t" + aValue + Const.CR;
                error_found = true;
            }
        }
        if (error_found) {
            error_message = BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.FieldsNotFoundInLookupStream2") + Const.CR + Const.CR + error_message;
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
            remarks.add(cr);
        } else {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.AllFieldsFoundInTheLookupStream2"), stepMeta);
            remarks.add(cr);
        }
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.FieldsNotFoundFromInLookupSep"), stepMeta);
        remarks.add(cr);
    }
    // See if the source step is filled in!
    StreamInterface infoStream = getStepIOMeta().getInfoStreams().get(0);
    if (infoStream.getStepMeta() == null) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.SourceStepNotSelected"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.SourceStepIsSelected"), stepMeta);
        remarks.add(cr);
        // 
        if (info != null) {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.SourceStepExist", infoStream.getStepname()), stepMeta);
            remarks.add(cr);
        } else {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.SourceStepDoesNotExist", infoStream.getStepname()), stepMeta);
            remarks.add(cr);
        }
    }
    // See if we have input streams leading to this step!
    if (input.length >= 2) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.StepReceivingInfoFromInputSteps", input.length + ""), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "StreamLookupMeta.CheckResult.NeedAtLeast2InputStreams", Const.CR, Const.CR), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult) 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