use of org.pentaho.di.imp.rule.ImportValidationFeedback in project pentaho-kettle by pentaho.
the class ExportFeedback method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
String message = null;
if (this.isSimpleString) {
message = BaseMessages.getString(PKG, "ExportFeedback.Message.Simple", sdf.format(this.getTime()), this.getItemName());
sb.append(message);
sb.append(Const.CR);
return sb.toString();
}
message = BaseMessages.getString(PKG, "ExportFeedback.Message.Main", sdf.format(this.getTime()), this.getStatus().getStatus(), this.getItemName(), this.getItemPath());
sb.append(message);
sb.append(Const.CR);
// that the reason why are you read this comments.
if (getStatus().equals(ExportFeedback.Status.REJECTED)) {
List<ImportValidationFeedback> fList = this.getResult();
for (ImportValidationFeedback res : fList) {
message = BaseMessages.getString(PKG, "ExportFeedback.Message.RuleViolated", res.getComment());
sb.append(message);
sb.append(Const.CR);
}
}
return sb.toString();
}
use of org.pentaho.di.imp.rule.ImportValidationFeedback in project pentaho-kettle by pentaho.
the class RepositoryImporter method validateImportedElement.
/**
* Validates the repository element that is about to get imported against the list of import rules.
*
* @param importRules
* import rules to validate against.
* @param subject
* @throws KettleException
*/
public static void validateImportedElement(ImportRules importRules, Object subject) throws KettleException {
List<ImportValidationFeedback> feedback = importRules.verifyRules(subject);
List<ImportValidationFeedback> errors = ImportValidationFeedback.getErrors(feedback);
if (!errors.isEmpty()) {
StringBuilder message = new StringBuilder(BaseMessages.getString(PKG, "RepositoryImporter.ValidationFailed.Message", subject.toString()));
message.append(Const.CR);
for (ImportValidationFeedback error : errors) {
message.append(" - ");
message.append(error.toString());
message.append(Const.CR);
}
throw new KettleException(message.toString());
}
}
use of org.pentaho.di.imp.rule.ImportValidationFeedback in project pentaho-kettle by pentaho.
the class DatabaseConfigurationImportRule method verifyRule.
@Override
public List<ImportValidationFeedback> verifyRule(Object subject) {
List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>();
if (!isEnabled()) {
return feedback;
}
if (databaseMeta == null) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "This rule contains no database to validate against."));
return feedback;
}
DatabaseMeta verify = null;
if (subject instanceof HasDatabasesInterface) {
HasDatabasesInterface dbs = (HasDatabasesInterface) subject;
verify = dbs.findDatabase(databaseMeta.getName());
} else if (subject instanceof DatabaseMeta) {
//
if (databaseMeta.getName().equals(((DatabaseMeta) subject).getName())) {
verify = (DatabaseMeta) subject;
}
}
if (verify == null) {
return feedback;
}
//
if (!Utils.isEmpty(databaseMeta.getDatabaseName())) {
if (!databaseMeta.getDatabaseName().equals(verify.getDatabaseName())) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "The name of the database is not set to the expected value '" + databaseMeta.getDatabaseName() + "'."));
}
}
//
if (!Utils.isEmpty(databaseMeta.getHostname())) {
if (!databaseMeta.getHostname().equals(verify.getHostname())) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "The host name of the database is not set to the expected value '" + databaseMeta.getHostname() + "'."));
}
}
//
if (!Utils.isEmpty(databaseMeta.getDatabasePortNumberString())) {
if (!databaseMeta.getDatabasePortNumberString().equals(verify.getDatabasePortNumberString())) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "The database port of the database is not set to the expected value '" + databaseMeta.getDatabasePortNumberString() + "'."));
}
}
//
if (!Utils.isEmpty(databaseMeta.getUsername())) {
if (!databaseMeta.getUsername().equals(verify.getUsername())) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "The username of the database is not set to the expected value '" + databaseMeta.getUsername() + "'."));
}
}
//
if (!Utils.isEmpty(databaseMeta.getPassword())) {
if (!databaseMeta.getPassword().equals(verify.getPassword())) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "The password of the database is not set to the expected value."));
}
}
if (feedback.isEmpty()) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.APPROVAL, "The database connection was found and verified."));
}
return feedback;
}
use of org.pentaho.di.imp.rule.ImportValidationFeedback in project pentaho-kettle by pentaho.
the class JobHasDescriptionImportRule method verifyRule.
@Override
public List<ImportValidationFeedback> verifyRule(Object subject) {
List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>();
if (!isEnabled()) {
return feedback;
}
if (!(subject instanceof JobMeta)) {
return feedback;
}
JobMeta transMeta = (JobMeta) subject;
String description = transMeta.getDescription();
if (description != null && description.length() > minLength) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.APPROVAL, "A description is present"));
} else {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "A description is not present or too short"));
}
return feedback;
}
use of org.pentaho.di.imp.rule.ImportValidationFeedback in project pentaho-kettle by pentaho.
the class JobHasJobLogConfiguredImportRule method verifyRule.
@Override
public List<ImportValidationFeedback> verifyRule(Object subject) {
List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>();
if (!isEnabled()) {
return feedback;
}
if (!(subject instanceof JobMeta)) {
return feedback;
}
JobMeta jobMeta = (JobMeta) subject;
JobLogTable jobLogTable = jobMeta.getJobLogTable();
if (!jobLogTable.isDefined()) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "The logging table is not defined"));
} else {
if (!Utils.isEmpty(schemaName)) {
if (schemaName.equals(jobLogTable.getSchemaName())) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.APPROVAL, "The schema name is set to: " + schemaName));
} else {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "The schema name is not set to: " + schemaName));
}
}
if (!Utils.isEmpty(tableName)) {
if (tableName.equals(jobLogTable.getTableName())) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.APPROVAL, "The table name is set to: " + tableName));
} else {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "The table name is not set to: " + tableName));
}
}
if (!Utils.isEmpty(connectionName)) {
if (connectionName.equals(jobLogTable.getDatabaseMeta().getName())) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.APPROVAL, "The database connection used for logging is: " + connectionName));
} else {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "The database connection used for logging is not: " + connectionName));
}
}
if (feedback.isEmpty()) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.APPROVAL, "The logging table is correctly defined"));
}
}
return feedback;
}
Aggregations