use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.
the class SortRowsMeta 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, "SortRowsMeta.CheckResult.FieldsReceived", "" + prev.size()), stepMeta);
remarks.add(cr);
String error_message = "";
boolean error_found = false;
// Starting from selected fields in ...
for (int i = 0; i < fieldName.length; i++) {
int idx = prev.indexOfValue(fieldName[i]);
if (idx < 0) {
error_message += "\t\t" + fieldName[i] + Const.CR;
error_found = true;
}
}
if (error_found) {
error_message = BaseMessages.getString(PKG, "SortRowsMeta.CheckResult.SortKeysNotFound", error_message);
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
remarks.add(cr);
} else {
if (fieldName.length > 0) {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SortRowsMeta.CheckResult.AllSortKeysFound"), stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SortRowsMeta.CheckResult.NoSortKeysEntered"), stepMeta);
remarks.add(cr);
}
}
// Check the sort directory
String realDirectory = transMeta.environmentSubstitute(directory);
File f = new File(realDirectory);
if (f.exists()) {
if (f.isDirectory()) {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SortRowsMeta.CheckResult.DirectoryExists", realDirectory), stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SortRowsMeta.CheckResult.ExistsButNoDirectory", realDirectory), stepMeta);
remarks.add(cr);
}
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SortRowsMeta.CheckResult.DirectoryNotExists", realDirectory), stepMeta);
remarks.add(cr);
}
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SortRowsMeta.CheckResult.NoFields"), 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, "SortRowsMeta.CheckResult.ExpectedInputOk"), stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SortRowsMeta.CheckResult.ExpectedInputError"), stepMeta);
remarks.add(cr);
}
}
use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.
the class SortedMergeMeta 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 (prev != null && prev.size() > 0) {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SortedMergeMeta.CheckResult.FieldsReceived", "" + prev.size()), stepMeta);
remarks.add(cr);
String error_message = "";
boolean error_found = false;
// Starting from selected fields in ...
for (int i = 0; i < fieldName.length; i++) {
int idx = prev.indexOfValue(fieldName[i]);
if (idx < 0) {
error_message += "\t\t" + fieldName[i] + Const.CR;
error_found = true;
}
}
if (error_found) {
error_message = BaseMessages.getString(PKG, "SortedMergeMeta.CheckResult.SortKeysNotFound", error_message);
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, error_message, stepMeta);
remarks.add(cr);
} else {
if (fieldName.length > 0) {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SortedMergeMeta.CheckResult.AllSortKeysFound"), stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SortedMergeMeta.CheckResult.NoSortKeysEntered"), stepMeta);
remarks.add(cr);
}
}
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SortedMergeMeta.CheckResult.NoFields"), 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, "SortedMergeMeta.CheckResult.ExpectedInputOk"), stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SortedMergeMeta.CheckResult.ExpectedInputError"), stepMeta);
remarks.add(cr);
}
}
use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.
the class SQLFileOutputMeta 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(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.ConnectionExists"), stepMeta);
remarks.add(cr);
Database db = new Database(loggingObject, databaseMeta);
try {
db.connect();
cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.ConnectionOk"), stepMeta);
remarks.add(cr);
if (!Utils.isEmpty(tablename)) {
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(schemaName, tablename);
// Check if this table exists...
if (db.checkTableExists(schemaTable)) {
cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.TableAccessible", schemaTable), stepMeta);
remarks.add(cr);
RowMetaInterface r = db.getTableFields(schemaTable);
if (r != null) {
cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SQLFileOutputMeta.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(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.FieldsReceived", "" + prev.size()), stepMeta);
remarks.add(cr);
// 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, "SQLFileOutputMeta.CheckResult.FieldsNotFoundInOutput", error_message);
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.AllFieldsFoundInOutput"), stepMeta);
remarks.add(cr);
}
// Starting from table fields in r...
for (int i = 0; i < r.size(); 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, "SQLFileOutputMeta.CheckResult.FieldsNotFound", error_message);
cr = new CheckResult(CheckResult.TYPE_RESULT_WARNING, error_message, stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.AllFieldsFound"), stepMeta);
remarks.add(cr);
}
} else {
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.NoFields"), stepMeta);
remarks.add(cr);
}
} else {
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.TableNotAccessible"), stepMeta);
remarks.add(cr);
}
} else {
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.TableError", schemaTable), stepMeta);
remarks.add(cr);
}
} else {
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.NoTableName"), stepMeta);
remarks.add(cr);
}
} catch (KettleException e) {
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.UndefinedError", e.getMessage()), stepMeta);
remarks.add(cr);
} finally {
db.disconnect();
}
} else {
CheckResult cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.NoConnection"), stepMeta);
remarks.add(cr);
}
// See if we have input streams leading to this step!
if (input.length > 0) {
CheckResult cr = new CheckResult(CheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.ExpectedInputOk"), stepMeta);
remarks.add(cr);
} else {
CheckResult cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "SQLFileOutputMeta.CheckResult.ExpectedInputError"), stepMeta);
remarks.add(cr);
}
}
use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.
the class TableExistsMeta 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 (database == null) {
error_message = BaseMessages.getString(PKG, "TableExistsMeta.CheckResult.InvalidConnection");
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
remarks.add(cr);
}
if (Utils.isEmpty(resultfieldname)) {
error_message = BaseMessages.getString(PKG, "TableExistsMeta.CheckResult.ResultFieldMissing");
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
remarks.add(cr);
} else {
error_message = BaseMessages.getString(PKG, "TableExistsMeta.CheckResult.ResultFieldOK");
cr = new CheckResult(CheckResult.TYPE_RESULT_OK, error_message, stepMeta);
remarks.add(cr);
}
if (Utils.isEmpty(tablenamefield)) {
error_message = BaseMessages.getString(PKG, "TableExistsMeta.CheckResult.TableFieldMissing");
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta);
remarks.add(cr);
} else {
error_message = BaseMessages.getString(PKG, "TableExistsMeta.CheckResult.TableFieldOK");
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, "TableExistsMeta.CheckResult.ReceivingInfoFromOtherSteps"), stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "TableExistsMeta.CheckResult.NoInpuReceived"), stepMeta);
remarks.add(cr);
}
}
use of org.pentaho.di.core.CheckResult in project pentaho-kettle by pentaho.
the class TableInputMeta 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);
Database db = new Database(loggingObject, databaseMeta);
db.shareVariablesWith(transMeta);
// keep track of it for canceling purposes...
super.databases = new Database[] { db };
try {
db.connect();
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "Connection to database OK", stepMeta);
remarks.add(cr);
if (sql != null && sql.length() != 0) {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "SQL statement is entered", stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "SQL statement is missing.", stepMeta);
remarks.add(cr);
}
} catch (KettleException e) {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "An error occurred: " + e.getMessage(), stepMeta);
remarks.add(cr);
} finally {
db.disconnect();
}
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Please select or create a connection to use", stepMeta);
remarks.add(cr);
}
// See if we have an informative step...
StreamInterface infoStream = getStepIOMeta().getInfoStreams().get(0);
if (!Utils.isEmpty(infoStream.getStepname())) {
boolean found = false;
for (int i = 0; i < input.length; i++) {
if (infoStream.getStepname().equalsIgnoreCase(input[i])) {
found = true;
}
}
if (found) {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "Previous step to read info from [" + infoStream.getStepname() + "] is found.", stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Previous step to read info from [" + infoStream.getStepname() + "] is not found.", stepMeta);
remarks.add(cr);
}
// Count the number of ? in the SQL string:
int count = 0;
for (int i = 0; i < sql.length(); i++) {
char c = sql.charAt(i);
if (c == '\'') {
// skip to next quote!
do {
i++;
c = sql.charAt(i);
} while (c != '\'');
}
if (c == '?') {
count++;
}
}
// Verify with the number of informative fields...
if (info != null) {
if (count == info.size()) {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "This step is expecting and receiving " + info.size() + " fields of input from the previous step.", stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "This step is receiving " + info.size() + " but not the expected " + count + " fields of input from the previous step.", stepMeta);
remarks.add(cr);
}
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Input step name is not recognized!", stepMeta);
remarks.add(cr);
}
} else {
if (input.length > 0) {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Step is not expecting info from input steps.", stepMeta);
remarks.add(cr);
} else {
cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "No input expected, no input provided.", stepMeta);
remarks.add(cr);
}
}
}
Aggregations