Search in sources :

Example 6 with CheckResult

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

the class XMLInputMeta 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;
    // See if we get input...
    if (input.length > 0) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "XMLInputMeta.CheckResult.NoInputExpected"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "XMLInputMeta.CheckResult.NoInput"), stepMeta);
        remarks.add(cr);
    }
    FileInputList fileInputList = getFiles(transMeta);
    // String files[] = getFiles();
    if (fileInputList == null || fileInputList.getFiles().size() == 0) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "XMLInputMeta.CheckResult.NoFiles"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "XMLInputMeta.CheckResult.FilesOk", "" + fileInputList.getFiles().size()), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult) FileInputList(org.pentaho.di.core.fileinput.FileInputList)

Example 7 with CheckResult

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

the class SapInputMeta 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;
    if (databaseMeta != null) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "Connection exists", stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Please select or create a connection to use", stepMeta);
        remarks.add(cr);
    }
    if (function != null) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "Function selected", stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Please select a function to use", stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult)

Example 8 with CheckResult

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

the class TransMeta method checkSteps.

/**
 * Checks all the steps and fills a List of (CheckResult) remarks.
 *
 * @param remarks
 *          The remarks list to add to.
 * @param only_selected
 *          true to check only the selected steps, false for all steps
 * @param monitor
 *          a progress monitor listener to be updated as the SQL statements are generated
 */
public void checkSteps(List<CheckResultInterface> remarks, boolean only_selected, ProgressMonitorListener monitor, VariableSpace space, Repository repository, IMetaStore metaStore) {
    try {
        // Start with a clean slate...
        remarks.clear();
        Map<ValueMetaInterface, String> values = new Hashtable<>();
        String[] stepnames;
        StepMeta[] steps;
        List<StepMeta> selectedSteps = getSelectedSteps();
        if (!only_selected || selectedSteps.isEmpty()) {
            stepnames = getStepNames();
            steps = getStepsArray();
        } else {
            stepnames = getSelectedStepNames();
            steps = selectedSteps.toArray(new StepMeta[selectedSteps.size()]);
        }
        ExtensionPointHandler.callExtensionPoint(getLogChannel(), KettleExtensionPoint.BeforeCheckSteps.id, new CheckStepsExtension(remarks, space, this, steps, repository, metaStore));
        boolean stop_checking = false;
        if (monitor != null) {
            monitor.beginTask(BaseMessages.getString(PKG, "TransMeta.Monitor.VerifyingThisTransformationTask.Title"), steps.length + 2);
        }
        for (int i = 0; i < steps.length && !stop_checking; i++) {
            if (monitor != null) {
                monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.VerifyingStepTask.Title", stepnames[i]));
            }
            StepMeta stepMeta = steps[i];
            int nrinfo = findNrInfoSteps(stepMeta);
            StepMeta[] infostep = null;
            if (nrinfo > 0) {
                infostep = getInfoStep(stepMeta);
            }
            RowMetaInterface info = null;
            if (infostep != null) {
                try {
                    info = getStepFields(infostep);
                } catch (KettleStepException kse) {
                    info = null;
                    CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultError.ErrorOccurredGettingStepInfoFields.Description", "" + stepMeta, Const.CR + kse.getMessage()), stepMeta);
                    remarks.add(cr);
                }
            }
            // The previous fields from non-informative steps:
            RowMetaInterface prev = null;
            try {
                prev = getPrevStepFields(stepMeta);
            } catch (KettleStepException kse) {
                CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultError.ErrorOccurredGettingInputFields.Description", "" + stepMeta, Const.CR + kse.getMessage()), stepMeta);
                remarks.add(cr);
                // This is a severe error: stop checking...
                // Otherwise we wind up checking time & time again because nothing gets put in the database
                // cache, the timeout of certain databases is very long... (Oracle)
                stop_checking = true;
            }
            if (isStepUsedInTransHops(stepMeta) || getSteps().size() == 1) {
                // Get the input & output steps!
                // Copy to arrays:
                String[] input = getPrevStepNames(stepMeta);
                String[] output = getNextStepNames(stepMeta);
                // Check step specific info...
                ExtensionPointHandler.callExtensionPoint(getLogChannel(), KettleExtensionPoint.BeforeCheckStep.id, new CheckStepsExtension(remarks, space, this, new StepMeta[] { stepMeta }, repository, metaStore));
                stepMeta.check(remarks, this, prev, input, output, info, space, repository, metaStore);
                ExtensionPointHandler.callExtensionPoint(getLogChannel(), KettleExtensionPoint.AfterCheckStep.id, new CheckStepsExtension(remarks, space, this, new StepMeta[] { stepMeta }, repository, metaStore));
                // See if illegal characters etc. were used in field-names...
                if (prev != null) {
                    for (int x = 0; x < prev.size(); x++) {
                        ValueMetaInterface v = prev.getValueMeta(x);
                        String name = v.getName();
                        if (name == null) {
                            values.put(v, BaseMessages.getString(PKG, "TransMeta.Value.CheckingFieldName.FieldNameIsEmpty.Description"));
                        } else if (name.indexOf(' ') >= 0) {
                            values.put(v, BaseMessages.getString(PKG, "TransMeta.Value.CheckingFieldName.FieldNameContainsSpaces.Description"));
                        } else {
                            char[] list = new char[] { '.', ',', '-', '/', '+', '*', '\'', '\t', '"', '|', '@', '(', ')', '{', '}', '!', '^' };
                            for (int c = 0; c < list.length; c++) {
                                if (name.indexOf(list[c]) >= 0) {
                                    values.put(v, BaseMessages.getString(PKG, "TransMeta.Value.CheckingFieldName.FieldNameContainsUnfriendlyCodes.Description", String.valueOf(list[c])));
                                }
                            }
                        }
                    }
                    // Check if 2 steps with the same name are entering the step...
                    if (prev.size() > 1) {
                        String[] fieldNames = prev.getFieldNames();
                        String[] sortedNames = Const.sortStrings(fieldNames);
                        String prevName = sortedNames[0];
                        for (int x = 1; x < sortedNames.length; x++) {
                            // Checking for doubles
                            if (prevName.equalsIgnoreCase(sortedNames[x])) {
                                // Give a warning!!
                                CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultWarning.HaveTheSameNameField.Description", prevName), stepMeta);
                                remarks.add(cr);
                            } else {
                                prevName = sortedNames[x];
                            }
                        }
                    }
                } else {
                    CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultError.CannotFindPreviousFields.Description") + stepMeta.getName(), stepMeta);
                    remarks.add(cr);
                }
            } else {
                CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_WARNING, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultWarning.StepIsNotUsed.Description"), stepMeta);
                remarks.add(cr);
            }
            // Also check for mixing rows...
            try {
                checkRowMixingStatically(stepMeta, null);
            } catch (KettleRowException e) {
                CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, e.getMessage(), stepMeta);
                remarks.add(cr);
            }
            if (monitor != null) {
                // progress bar...
                monitor.worked(1);
                if (monitor.isCanceled()) {
                    stop_checking = true;
                }
            }
        }
        // Also, check the logging table of the transformation...
        if (monitor == null || !monitor.isCanceled()) {
            if (monitor != null) {
                monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.CheckingTheLoggingTableTask.Title"));
            }
            if (transLogTable.getDatabaseMeta() != null) {
                Database logdb = new Database(this, transLogTable.getDatabaseMeta());
                logdb.shareVariablesWith(this);
                try {
                    logdb.connect();
                    CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultOK.ConnectingWorks.Description"), null);
                    remarks.add(cr);
                    if (transLogTable.getTableName() != null) {
                        if (logdb.checkTableExists(transLogTable.getTableName())) {
                            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultOK.LoggingTableExists.Description", transLogTable.getTableName()), null);
                            remarks.add(cr);
                            RowMetaInterface fields = transLogTable.getLogRecord(LogStatus.START, null, null).getRowMeta();
                            String sql = logdb.getDDL(transLogTable.getTableName(), fields);
                            if (sql == null || sql.length() == 0) {
                                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultOK.CorrectLayout.Description"), null);
                                remarks.add(cr);
                            } else {
                                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultError.LoggingTableNeedsAdjustments.Description") + Const.CR + sql, null);
                                remarks.add(cr);
                            }
                        } else {
                            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultError.LoggingTableDoesNotExist.Description"), null);
                            remarks.add(cr);
                        }
                    } else {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultError.LogTableNotSpecified.Description"), null);
                        remarks.add(cr);
                    }
                } catch (KettleDatabaseException dbe) {
                // Ignore errors
                } finally {
                    logdb.disconnect();
                }
            }
            if (monitor != null) {
                monitor.worked(1);
            }
        }
        if (monitor != null) {
            monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.CheckingForDatabaseUnfriendlyCharactersInFieldNamesTask.Title"));
        }
        if (values.size() > 0) {
            for (ValueMetaInterface v : values.keySet()) {
                String message = values.get(v);
                CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_WARNING, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultWarning.Description", v.getName(), message, v.getOrigin()), findStep(v.getOrigin()));
                remarks.add(cr);
            }
        } else {
            CheckResult cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "TransMeta.CheckResult.TypeResultOK.Description"), null);
            remarks.add(cr);
        }
        if (monitor != null) {
            monitor.worked(1);
        }
        ExtensionPointHandler.callExtensionPoint(getLogChannel(), KettleExtensionPoint.AfterCheckSteps.id, new CheckStepsExtension(remarks, space, this, steps, repository, metaStore));
    } catch (Exception e) {
        log.logError(Const.getStackTracker(e));
        throw new RuntimeException(e);
    }
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) Hashtable(java.util.Hashtable) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) IOException(java.io.IOException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) CheckResult(org.pentaho.di.core.CheckResult) KettleRowException(org.pentaho.di.core.exception.KettleRowException) Database(org.pentaho.di.core.database.Database)

Example 9 with CheckResult

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

the class ExecSQLRowMeta 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;
    if (databaseMeta != null) {
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ExecSQLRowMeta.CheckResult.ConnectionExists"), stepMeta);
        remarks.add(cr);
        Database db = new Database(loggingObject, databaseMeta);
        // keep track of it for cancelling purposes...
        databases = new Database[] { db };
        try {
            db.connect();
            cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ExecSQLRowMeta.CheckResult.DBConnectionOK"), stepMeta);
            remarks.add(cr);
            if (sqlField != null && sqlField.length() != 0) {
                cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ExecSQLRowMeta.CheckResult.SQLFieldNameEntered"), stepMeta);
            } else {
                cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "ExecSQLRowMeta.CheckResult.SQLFieldNameMissing"), stepMeta);
            }
            remarks.add(cr);
        } catch (KettleException e) {
            cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "ExecSQLRowMeta.CheckResult.ErrorOccurred") + e.getMessage(), stepMeta);
            remarks.add(cr);
        } finally {
            db.disconnect();
        }
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "ExecSQLRowMeta.CheckResult.ConnectionNeeded"), stepMeta);
        remarks.add(cr);
    }
    if (input.length > 0) {
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ExecSQLRowMeta.CheckResult.StepReceivingInfoOK"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "ExecSQLRowMeta.CheckResult.NoInputReceivedError"), 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)

Example 10 with CheckResult

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

the class FieldSplitterMeta 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) {
    String error_message = "";
    CheckResult 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, "FieldSplitterMeta.CheckResult.StepReceivingFields", prev.size() + ""), stepMeta);
        remarks.add(cr);
        error_message = "";
        int i = prev.indexOfValue(splitField);
        if (i < 0) {
            error_message = BaseMessages.getString(PKG, "FieldSplitterMeta.CheckResult.SplitedFieldNotPresentInInputStream", splitField);
            cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
            remarks.add(cr);
        } else {
            cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "FieldSplitterMeta.CheckResult.SplitedFieldFoundInInputStream", splitField), stepMeta);
            remarks.add(cr);
        }
    } else {
        error_message = BaseMessages.getString(PKG, "FieldSplitterMeta.CheckResult.CouldNotReadFieldsFromPreviousStep") + Const.CR;
        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, "FieldSplitterMeta.CheckResult.StepReceivingInfoFromOtherStep"), stepMeta);
        remarks.add(cr);
    } else {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "FieldSplitterMeta.CheckResult.NoInputReceivedFromOtherStep"), stepMeta);
        remarks.add(cr);
    }
}
Also used : CheckResult(org.pentaho.di.core.CheckResult) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

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