Search in sources :

Example 66 with CheckResult

use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.

the class TableOutputMeta method check.

public void check(List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository, IMetaStore metaStore) {
    if (databaseMeta != null) {
        CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.ConnectionExists"), stepMeta);
        remarks.add(cr);
        Database db = new Database(loggingObject, databaseMeta);
        db.shareVariablesWith(transMeta);
        try {
            db.connect();
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.ConnectionOk"), stepMeta);
            remarks.add(cr);
            if (!Utils.isEmpty(tableName)) {
                String schemaTable = databaseMeta.getQuotedSchemaTableCombination(db.environmentSubstitute(schemaName), db.environmentSubstitute(tableName));
                // Check if this table exists...
                if (db.checkTableExists(schemaTable)) {
                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.TableAccessible", schemaTable), stepMeta);
                    remarks.add(cr);
                    RowMetaInterface r = db.getTableFields(schemaTable);
                    if (r != null) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.TableOk", schemaTable), stepMeta);
                        remarks.add(cr);
                        String error_message = "";
                        boolean error_found = false;
                        // Now see what we can find as previous step...
                        if (prev != null && prev.size() > 0) {
                            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.FieldsReceived", "" + prev.size()), stepMeta);
                            remarks.add(cr);
                            if (!specifyFields()) {
                                // Starting from prev...
                                for (int i = 0; i < prev.size(); i++) {
                                    ValueMetaInterface pv = prev.getValueMeta(i);
                                    int idx = r.indexOfValue(pv.getName());
                                    if (idx < 0) {
                                        error_message += "\t\t" + pv.getName() + " (" + pv.getTypeDesc() + ")" + Const.CR;
                                        error_found = true;
                                    }
                                }
                                if (error_found) {
                                    error_message = BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.FieldsNotFoundInOutput", 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, "TableOutputMeta.CheckResult.AllFieldsFoundInOutput"), stepMeta);
                                    remarks.add(cr);
                                }
                            } else {
                                // Specifying the column names explicitly
                                for (int i = 0; i < getFieldDatabase().length; i++) {
                                    int idx = r.indexOfValue(getFieldDatabase()[i]);
                                    if (idx < 0) {
                                        error_message += "\t\t" + getFieldDatabase()[i] + Const.CR;
                                        error_found = true;
                                    }
                                }
                                if (error_found) {
                                    error_message = BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.FieldsSpecifiedNotInTable", 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, "TableOutputMeta.CheckResult.AllFieldsFoundInOutput"), stepMeta);
                                    remarks.add(cr);
                                }
                            }
                            error_message = "";
                            if (!specifyFields()) {
                                // Starting from table fields in r...
                                for (int i = 0; i < getFieldDatabase().length; i++) {
                                    ValueMetaInterface rv = r.getValueMeta(i);
                                    int idx = prev.indexOfValue(rv.getName());
                                    if (idx < 0) {
                                        error_message += "\t\t" + rv.getName() + " (" + rv.getTypeDesc() + ")" + Const.CR;
                                        error_found = true;
                                    }
                                }
                                if (error_found) {
                                    error_message = BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.FieldsNotFound", error_message);
                                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_WARNING, error_message, stepMeta);
                                    remarks.add(cr);
                                } else {
                                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.AllFieldsFound"), stepMeta);
                                    remarks.add(cr);
                                }
                            } else {
                                // Specifying the column names explicitly
                                for (int i = 0; i < getFieldStream().length; i++) {
                                    int idx = prev.indexOfValue(getFieldStream()[i]);
                                    if (idx < 0) {
                                        error_message += "\t\t" + getFieldStream()[i] + Const.CR;
                                        error_found = true;
                                    }
                                }
                                if (error_found) {
                                    error_message = BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.FieldsSpecifiedNotFound", 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, "TableOutputMeta.CheckResult.AllFieldsFound"), stepMeta);
                                    remarks.add(cr);
                                }
                            }
                        } else {
                            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.NoFields"), stepMeta);
                            remarks.add(cr);
                        }
                    } else {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.TableNotAccessible"), stepMeta);
                        remarks.add(cr);
                    }
                } else {
                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.TableError", schemaTable), stepMeta);
                    remarks.add(cr);
                }
            } else {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.NoTableName"), stepMeta);
                remarks.add(cr);
            }
        } catch (KettleException e) {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.UndefinedError", e.getMessage()), stepMeta);
            remarks.add(cr);
        } finally {
            db.disconnect();
        }
    } else {
        CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.NoConnection"), stepMeta);
        remarks.add(cr);
    }
    // See if we have input streams leading to this step!
    if (input.length > 0) {
        CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.ExpectedInputOk"), stepMeta);
        remarks.add(cr);
    } else {
        CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TableOutputMeta.CheckResult.ExpectedInputError"), stepMeta);
        remarks.add(cr);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) CheckResult(org.pentaho.di.core.CheckResult) Database(org.pentaho.di.core.database.Database) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 67 with CheckResult

use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.

the class TeraFastMeta method check.

/**
 * {@inheritDoc}
 *
 * @see org.pentaho.di.trans.step.StepMetaInterface#check(java.util.List, org.pentaho.di.trans.TransMeta,
 *      org.pentaho.di.trans.step.StepMeta, org.pentaho.di.core.row.RowMetaInterface, java.lang.String[],
 *      java.lang.String[], org.pentaho.di.core.row.RowMetaInterface)
 */
public void check(final List<CheckResultInterface> remarks, final TransMeta transmeta, final StepMeta stepMeta, final RowMetaInterface prev, final String[] input, final String[] output, final RowMetaInterface info, VariableSpace space, Repository repository, IMetaStore metaStore) {
    CheckResult checkResult;
    try {
        RowMetaInterface tableFields = getRequiredFields(transmeta);
        checkResult = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, MESSAGES.getString("TeraFastMeta.Message.ConnectionEstablished"), stepMeta);
        remarks.add(checkResult);
        checkResult = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, MESSAGES.getString("TeraFastMeta.Message.TableExists"), stepMeta);
        remarks.add(checkResult);
        boolean error = false;
        for (String field : this.tableFieldList.getValue()) {
            if (tableFields.searchValueMeta(field) == null) {
                error = true;
                checkResult = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, MESSAGES.getString("TeraFastMeta.Exception.TableFieldNotFound"), stepMeta);
                remarks.add(checkResult);
            }
        }
        if (!error) {
            checkResult = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, MESSAGES.getString("TeraFastMeta.Message.AllTableFieldsFound"), stepMeta);
            remarks.add(checkResult);
        }
        if (prev != null && prev.size() > 0) {
            // step mode. step receiving input
            checkResult = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, MESSAGES.getString("TeraFastMeta.Message.StepInputDataFound"), stepMeta);
            remarks.add(checkResult);
            error = false;
            for (String field : this.streamFieldList.getValue()) {
                if (prev.searchValueMeta(field) == null) {
                    error = true;
                    checkResult = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, MESSAGES.getString("TeraFastMeta.Exception.StreamFieldNotFound"), stepMeta);
                    remarks.add(checkResult);
                }
            }
            if (!error) {
                checkResult = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, MESSAGES.getString("TeraFastMeta.Message.AllStreamFieldsFound"), stepMeta);
                remarks.add(checkResult);
            }
        }
    // else { job mode. no input rows. pentaho doesn't seem to allow to check jobs. Default Warning: Step is not
    // in transformation.
    } catch (KettleDatabaseException e) {
        checkResult = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, MESSAGES.getString("TeraFastMeta.Exception.ConnectionFailed"), stepMeta);
        remarks.add(checkResult);
    } catch (KettleException e) {
        checkResult = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, e.getMessage(), stepMeta);
        remarks.add(checkResult);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) CheckResult(org.pentaho.di.core.CheckResult) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 68 with CheckResult

use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.

the class TextFileInputMeta 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;
    // See if we get input...
    if (input.length > 0) {
        if (!isAcceptingFilenames()) {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TextFileInputMeta.CheckResult.NoInputError"), stepMeta);
            remarks.add(cr);
        } else {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TextFileInputMeta.CheckResult.AcceptFilenamesOk"), stepMeta);
            remarks.add(cr);
        }
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TextFileInputMeta.CheckResult.NoInputOk"), stepMeta);
        remarks.add(cr);
    }
    FileInputList textFileList = getTextFileList(transMeta);
    if (textFileList.nrOfFiles() == 0) {
        if (!isAcceptingFilenames()) {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TextFileInputMeta.CheckResult.ExpectedFilesError"), stepMeta);
            remarks.add(cr);
        }
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TextFileInputMeta.CheckResult.ExpectedFilesOk", "" + textFileList.nrOfFiles()), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult) FileInputList(org.pentaho.di.core.fileinput.FileInputList)

Example 69 with CheckResult

use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.

the class TransExecutorMeta method check.

public void check(List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo, 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_WARNING, BaseMessages.getString(PKG, "TransExecutorMeta.CheckResult.NotReceivingAnyFields"), stepinfo);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TransExecutorMeta.CheckResult.StepReceivingFields", prev.size() + ""), stepinfo);
        remarks.add(cr);
    }
    // See if we have input streams leading to this step!
    if (input.length > 0) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TransExecutorMeta.CheckResult.StepReceivingFieldsFromOtherSteps"), stepinfo);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TransExecutorMeta.CheckResult.NoInputReceived"), stepinfo);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult)

Example 70 with CheckResult

use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.

the class UniqueRowsMeta 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 (input.length > 0) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "UniqueRowsMeta.CheckResult.StepReceivingInfoFromOtherSteps"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "UniqueRowsMeta.CheckResult.NoInputReceivedFromOtherSteps"), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult)

Aggregations

CheckResult (org.pentaho.di.core.CheckResult)204 KettleException (org.pentaho.di.core.exception.KettleException)35 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)35 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)26 Database (org.pentaho.di.core.database.Database)25 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)19 FileInputList (org.pentaho.di.core.fileinput.FileInputList)14 StreamInterface (org.pentaho.di.trans.step.errorhandling.StreamInterface)7 KettleStepException (org.pentaho.di.core.exception.KettleStepException)6 File (java.io.File)4 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)4 PaloHelper (org.pentaho.di.palo.core.PaloHelper)4 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)3 Date (java.util.Date)2 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)2 KettleRowException (org.pentaho.di.core.exception.KettleRowException)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 RowMeta (org.pentaho.di.core.row.RowMeta)2 DimensionField (org.pentaho.di.palo.core.DimensionField)2