Search in sources :

Example 81 with CheckResult

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

the class SynchronizeAfterMergeMeta 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(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.TableNameOK"), stepMeta);
                remarks.add(cr);
                boolean first = true;
                boolean error_found = false;
                error_message = "";
                // Check fields in table
                String schemaTable = databaseMeta.getQuotedSchemaTableCombination(schemaName, tableName);
                RowMetaInterface r = db.getTableFields(schemaTable);
                if (r != null) {
                    cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.TableExists"), stepMeta);
                    remarks.add(cr);
                    for (int i = 0; i < keyLookup.length; i++) {
                        String lufield = keyLookup[i];
                        ValueMetaInterface v = r.searchValueMeta(lufield);
                        if (v == null) {
                            if (first) {
                                first = false;
                                error_message += BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.MissingCompareFieldsInTargetTable") + Const.CR;
                            }
                            error_found = true;
                            error_message += "\t\t" + lufield + Const.CR;
                        }
                    }
                    if (error_found) {
                        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
                    } else {
                        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.AllLookupFieldsFound"), stepMeta);
                    }
                    remarks.add(cr);
                    // How about the fields to insert/update in the table?
                    first = true;
                    error_found = false;
                    error_message = "";
                    for (int i = 0; i < updateLookup.length; i++) {
                        String lufield = updateLookup[i];
                        ValueMetaInterface v = r.searchValueMeta(lufield);
                        if (v == null) {
                            if (first) {
                                first = false;
                                error_message += BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.MissingFieldsToUpdateInTargetTable") + Const.CR;
                            }
                            error_found = true;
                            error_message += "\t\t" + lufield + Const.CR;
                        }
                    }
                    if (error_found) {
                        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
                    } else {
                        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.AllFieldsToUpdateFoundInTargetTable"), stepMeta);
                    }
                    remarks.add(cr);
                } else {
                    error_message = BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.CouldNotReadTableInfo");
                    cr = new CheckResult(CheckResult.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(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.StepReceivingDatas", prev.size() + ""), stepMeta);
                remarks.add(cr);
                boolean first = true;
                error_message = "";
                boolean error_found = false;
                for (int i = 0; i < keyStream.length; i++) {
                    ValueMetaInterface v = prev.searchValueMeta(keyStream[i]);
                    if (v == null) {
                        if (first) {
                            first = false;
                            error_message += BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.MissingFieldsInInput") + Const.CR;
                        }
                        error_found = true;
                        error_message += "\t\t" + keyStream[i] + Const.CR;
                    }
                }
                for (int i = 0; i < keyStream2.length; i++) {
                    if (keyStream2[i] != null && keyStream2[i].length() > 0) {
                        ValueMetaInterface v = prev.searchValueMeta(keyStream2[i]);
                        if (v == null) {
                            if (first) {
                                first = false;
                                error_message += BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.MissingFieldsInInput") + Const.CR;
                            }
                            error_found = true;
                            error_message += "\t\t" + keyStream[i] + Const.CR;
                        }
                    }
                }
                if (error_found) {
                    cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
                } else {
                    cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.AllFieldsFoundInInput"), stepMeta);
                }
                remarks.add(cr);
                // How about the fields to insert/update the table with?
                first = true;
                error_found = false;
                error_message = "";
                for (int i = 0; i < updateStream.length; i++) {
                    String lufield = updateStream[i];
                    ValueMetaInterface v = prev.searchValueMeta(lufield);
                    if (v == null) {
                        if (first) {
                            first = false;
                            error_message += BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.MissingInputStreamFields") + Const.CR;
                        }
                        error_found = true;
                        error_message += "\t\t" + lufield + Const.CR;
                    }
                }
                if (error_found) {
                    cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
                } else {
                    cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.AllFieldsFoundInInput2"), stepMeta);
                    remarks.add(cr);
                }
                // --------------------------> check fields in stream and tables (type)
                // Check fields in table
                String errorMsgDiffField = "";
                boolean errorDiffLenField = false;
                String errorMsgDiffLenField = "";
                boolean errorDiffField = false;
                RowMetaInterface r = db.getTableFields(databaseMeta.getQuotedSchemaTableCombination(schemaName, tableName));
                if (r != null) {
                    for (int i = 0; i < updateStream.length; i++) {
                        String lufieldstream = updateStream[i];
                        String lufieldtable = updateLookup[i];
                        // get value from previous
                        ValueMetaInterface vs = prev.searchValueMeta(lufieldstream);
                        // get value from table fields
                        ValueMetaInterface vt = r.searchValueMeta(lufieldtable);
                        if (vs != null && vt != null) {
                            if (!vs.getTypeDesc().equalsIgnoreCase(vt.getTypeDesc())) {
                                errorMsgDiffField += Const.CR + "The input field [" + vs.getName() + "] ( Type=" + vs.getTypeDesc() + ") is not the same as the type in the target table (Type=" + vt.getTypeDesc() + ")" + Const.CR;
                                errorDiffField = true;
                            } else {
                                // check Length
                                if ((vt.getLength() < vs.getLength() || vs.getLength() == -1) && vt.getLength() != -1) {
                                    errorMsgDiffLenField += Const.CR + "The input field [" + vs.getName() + "] " + "(" + vs.getTypeDesc() + ")" + " has a length (" + vs.getLength() + ")" + " that is higher than that in the target table (" + vt.getLength() + ")." + Const.CR;
                                    errorDiffLenField = true;
                                }
                            }
                        }
                    }
                    // add error/Warning
                    if (errorDiffField) {
                        errorMsgDiffField = BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.FieldsTypeDifferent") + Const.CR + errorMsgDiffField;
                        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, errorMsgDiffField, stepMeta);
                    }
                    if (errorDiffLenField) {
                        errorMsgDiffLenField = BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.FieldsLenDifferent") + Const.CR + errorMsgDiffLenField;
                        cr = new CheckResult(CheckResult.TYPE_RESULT_WARNING, errorMsgDiffLenField, stepMeta);
                    }
                    remarks.add(cr);
                }
            // --------------------------> check fields in stream and tables (type)
            } else {
                error_message = BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.MissingFieldsInInput3") + Const.CR;
                cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
                remarks.add(cr);
            }
        } catch (KettleException e) {
            error_message = BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.DatabaseErrorOccurred") + e.getMessage();
            cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
            remarks.add(cr);
        } finally {
            db.disconnect();
        }
    } else {
        error_message = BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.InvalidConnection");
        cr = new CheckResult(CheckResult.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(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.CheckResult.StepReceivingInfoFromOtherSteps"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SynchronizeAfterMergeMeta.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 82 with CheckResult

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

the class SyslogMessageMeta 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 = "";
    // source filename
    if (Utils.isEmpty(messagefieldname)) {
        error_message = BaseMessages.getString(PKG, "SyslogMessageMeta.CheckResult.MessageFieldMissing");
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
        remarks.add(cr);
    } else {
        error_message = BaseMessages.getString(PKG, "SyslogMessageMeta.CheckResult.MessageFieldOK");
        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, "SyslogMessageMeta.CheckResult.ReceivingInfoFromOtherSteps"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SyslogMessageMeta.CheckResult.NoInpuReceived"), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult)

Example 83 with CheckResult

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

the class SystemDataMeta 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) {
    // See if we have input streams leading to this step!
    int nrRemarks = remarks.size();
    for (int i = 0; i < fieldName.length; i++) {
        if (fieldType[i].ordinal() <= SystemDataTypes.TYPE_SYSTEM_INFO_NONE.ordinal()) {
            CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SystemDataMeta.CheckResult.FieldHasNoType", fieldName[i]), stepMeta);
            remarks.add(cr);
        }
    }
    if (remarks.size() == nrRemarks) {
        CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SystemDataMeta.CheckResult.AllTypesSpecified"), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult)

Example 84 with CheckResult

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

the class TableCompareMeta 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(CheckResult.TYPE_RESULT_WARNING, BaseMessages.getString(PKG, "IfNullMeta.CheckResult.NotReceivingFields"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "IfNullMeta.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(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "IfNullMeta.CheckResult.StepRecevingData2"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "IfNullMeta.CheckResult.NoInputReceivedFromOtherSteps"), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult)

Example 85 with CheckResult

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

the class PropertyOutputMeta 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;
    // Now see what we can find as previous step...
    if (prev != null && prev.size() > 0) {
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "PropertyOutputMeta.CheckResult.FieldsReceived", "" + prev.size()), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "PropertyOutputMeta.CheckResult.NoFields"), 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, "PropertyOutputMeta.CheckResult.ExpectedInputOk"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "PropertyOutputMeta.CheckResult.ExpectedInputError"), stepMeta);
        remarks.add(cr);
    }
    // Check if filename is given
    if (!Utils.isEmpty(fileName)) {
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "PropertyOutputMeta.CheckResult.FilenameOk"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "PropertyOutputMeta.CheckResult.FilenameError"), stepMeta);
        remarks.add(cr);
    }
    // Check for Key field
    ValueMetaInterface v = prev.searchValueMeta(keyfield);
    if (v == null) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "PropertyOutputMeta.CheckResult.KeyFieldMissing"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "PropertyOutputMeta.CheckResult.KeyFieldOk"), stepMeta);
        remarks.add(cr);
    }
    // Check for Value field
    v = prev.searchValueMeta(valuefield);
    if (v == null) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "PropertyOutputMeta.CheckResult.ValueFieldMissing"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "PropertyOutputMeta.CheckResult.ValueFieldOk"), 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