Search in sources :

Example 51 with CheckResult

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

the class ParGzipCsvInputMeta 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, "ParGzipCsvInputMeta.CheckResult.NotReceivingFields"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "ParGzipCsvInputMeta.CheckResult.StepRecevingData", prev.size() + ""), stepMeta);
        remarks.add(cr);
    }
    // See if we have input streams leading to this step!
    if (input.length > 0) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "ParGzipCsvInputMeta.CheckResult.StepRecevingData2"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ParGzipCsvInputMeta.CheckResult.NoInputReceivedFromOtherSteps"), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult)

Example 52 with CheckResult

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

the class PentahoReportingOutputMeta 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) {
    CheckResult cr;
    // Check output fields
    if (prev != null && prev.size() > 0) {
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "PentahoReportingOutputMeta.CheckResult.ReceivingFields", String.valueOf(prev.size())), stepMeta);
        remarks.add(cr);
    }
    cr = new CheckResult(CheckResult.TYPE_RESULT_COMMENT, BaseMessages.getString(PKG, "PentahoReportingOutputMeta.CheckResult.FileSpecificationsNotChecked"), stepMeta);
    remarks.add(cr);
}
Also used : CheckResult(org.pentaho.di.core.CheckResult)

Example 53 with CheckResult

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

the class PGBulkLoaderMeta 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) {
    CheckResult cr;
    String error_message = "";
    if (databaseMeta != null) {
        Database db = new Database(loggingObject, databaseMeta);
        db.shareVariablesWith(transMeta);
        try {
            db.connect();
            if (!Utils.isEmpty(tableName)) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.TableNameOK"), stepMeta);
                remarks.add(cr);
                boolean first = true;
                boolean error_found = false;
                error_message = "";
                // Check fields in table
                String schemaTable = databaseMeta.getQuotedSchemaTableCombination(transMeta.environmentSubstitute(schemaName), transMeta.environmentSubstitute(tableName));
                RowMetaInterface r = db.getTableFields(schemaTable);
                if (r != null) {
                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.TableExists"), stepMeta);
                    remarks.add(cr);
                    // How about the fields to insert/dateMask in the table?
                    first = true;
                    error_found = false;
                    error_message = "";
                    for (int i = 0; i < fieldTable.length; i++) {
                        String field = fieldTable[i];
                        ValueMetaInterface v = r.searchValueMeta(field);
                        if (v == null) {
                            if (first) {
                                first = false;
                                error_message += BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.MissingFieldsToLoadInTargetTable") + Const.CR;
                            }
                            error_found = true;
                            error_message += "\t\t" + field + Const.CR;
                        }
                    }
                    if (error_found) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
                    } else {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.AllFieldsFoundInTargetTable"), stepMeta);
                    }
                    remarks.add(cr);
                } else {
                    error_message = BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.CouldNotReadTableInfo");
                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
                    remarks.add(cr);
                }
            }
            // Look up fields in the input stream <prev>
            if (prev != null && prev.size() > 0) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.StepReceivingDatas", prev.size() + ""), stepMeta);
                remarks.add(cr);
                boolean first = true;
                error_message = "";
                boolean error_found = false;
                for (int i = 0; i < fieldStream.length; i++) {
                    ValueMetaInterface v = prev.searchValueMeta(fieldStream[i]);
                    if (v == null) {
                        if (first) {
                            first = false;
                            error_message += BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.MissingFieldsInInput") + Const.CR;
                        }
                        error_found = true;
                        error_message += "\t\t" + fieldStream[i] + Const.CR;
                    }
                }
                if (error_found) {
                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
                } else {
                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.AllFieldsFoundInInput"), stepMeta);
                }
                remarks.add(cr);
            } else {
                error_message = BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.MissingFieldsInInput3") + Const.CR;
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
                remarks.add(cr);
            }
        } catch (KettleException e) {
            error_message = BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.DatabaseErrorOccurred") + e.getMessage();
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
            remarks.add(cr);
        } finally {
            db.disconnect();
        }
    } else {
        error_message = BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.InvalidConnection");
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
        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, "GPBulkLoaderMeta.CheckResult.StepReceivingInfoFromOtherSteps"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "GPBulkLoaderMeta.CheckResult.NoInputError"), 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 54 with CheckResult

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

the class ProcessFilesMeta 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;
    String error_message = "";
    // source filename
    if (Utils.isEmpty(sourcefilenamefield)) {
        error_message = BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.SourceFileFieldMissing");
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
        remarks.add(cr);
    } else {
        error_message = BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.TargetFileFieldOK");
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, error_message, stepMeta);
        remarks.add(cr);
    }
    if (operationType != OPERATION_TYPE_DELETE && Utils.isEmpty(targetfilenamefield)) {
        error_message = BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.TargetFileFieldMissing");
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
        remarks.add(cr);
    } else {
        error_message = BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.SourceFileFieldOK");
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, error_message, stepMeta);
        remarks.add(cr);
    }
    // See if we have input streams leading to this step!
    if (input.length > 0) {
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.ReceivingInfoFromOtherSteps"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.NoInpuReceived"), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult)

Example 55 with CheckResult

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

the class SelectValuesMeta 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, "SelectValuesMeta.CheckResult.StepReceivingFields", prev.size() + ""), stepMeta);
        remarks.add(cr);
        /*
       * Take care of the normal SELECT fields...
       */
        String error_message = "";
        boolean error_found = false;
        // Starting from selected fields in ...
        for (int i = 0; i < this.selectFields.length; i++) {
            int idx = prev.indexOfValue(selectFields[i].getName());
            if (idx < 0) {
                error_message += "\t\t" + selectFields[i].getName() + Const.CR;
                error_found = true;
            }
        }
        if (error_found) {
            error_message = BaseMessages.getString(PKG, "SelectValuesMeta.CheckResult.SelectedFieldsNotFound") + 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, "SelectValuesMeta.CheckResult.AllSelectedFieldsFound"), stepMeta);
            remarks.add(cr);
        }
        if (this.selectFields.length > 0) {
            // Starting from prev...
            for (int i = 0; i < prev.size(); i++) {
                ValueMetaInterface pv = prev.getValueMeta(i);
                int idx = Const.indexOfString(pv.getName(), getSelectName());
                if (idx < 0) {
                    error_message += "\t\t" + pv.getName() + " (" + pv.getTypeDesc() + ")" + Const.CR;
                    error_found = true;
                }
            }
            if (error_found) {
                error_message = BaseMessages.getString(PKG, "SelectValuesMeta.CheckResult.FieldsNotFound") + Const.CR + Const.CR + error_message;
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_COMMENT, error_message, stepMeta);
                remarks.add(cr);
            } else {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SelectValuesMeta.CheckResult.AllSelectedFieldsFound2"), stepMeta);
                remarks.add(cr);
            }
        }
        /*
       * How about the DE-SELECT (remove) fields...
       */
        error_message = "";
        error_found = false;
        // Starting from selected fields in ...
        for (int i = 0; i < this.deleteName.length; i++) {
            int idx = prev.indexOfValue(deleteName[i]);
            if (idx < 0) {
                error_message += "\t\t" + deleteName[i] + Const.CR;
                error_found = true;
            }
        }
        if (error_found) {
            error_message = BaseMessages.getString(PKG, "SelectValuesMeta.CheckResult.DeSelectedFieldsNotFound") + 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, "SelectValuesMeta.CheckResult.AllDeSelectedFieldsFound"), stepMeta);
            remarks.add(cr);
        }
        /*
       * How about the Meta-fields...?
       */
        error_message = "";
        error_found = false;
        // Starting from selected fields in ...
        for (int i = 0; i < this.meta.length; i++) {
            int idx = prev.indexOfValue(this.meta[i].getName());
            if (idx < 0) {
                error_message += "\t\t" + this.meta[i].getName() + Const.CR;
                error_found = true;
            }
        }
        if (error_found) {
            error_message = BaseMessages.getString(PKG, "SelectValuesMeta.CheckResult.MetadataFieldsNotFound") + 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, "SelectValuesMeta.CheckResult.AllMetadataFieldsFound"), stepMeta);
            remarks.add(cr);
        }
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SelectValuesMeta.CheckResult.FieldsNotFound2"), stepMeta);
        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, "SelectValuesMeta.CheckResult.StepReceivingInfoFromOtherSteps"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SelectValuesMeta.CheckResult.NoInputReceivedError"), stepMeta);
        remarks.add(cr);
    }
    // Check for doubles in the selected fields...
    int[] cnt = new int[selectFields.length];
    boolean error_found = false;
    String error_message = "";
    for (int i = 0; i < selectFields.length; i++) {
        cnt[i] = 0;
        for (int j = 0; j < selectFields.length; j++) {
            if (selectFields[i].getName().equals(selectFields[j].getName())) {
                cnt[i]++;
            }
        }
        if (cnt[i] > 1) {
            if (!error_found) {
                // first time...
                error_message = BaseMessages.getString(PKG, "SelectValuesMeta.CheckResult.DuplicateFieldsSpecified") + Const.CR;
            } else {
                error_found = true;
            }
            error_message += BaseMessages.getString(PKG, "SelectValuesMeta.CheckResult.OccurentRow", i + " : " + selectFields[i].getName() + "  (" + cnt[i]) + Const.CR;
            error_found = true;
        }
    }
    if (error_found) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

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