/** * 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() ); } }
@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; if ( jobMeta.nrNotes() == 0 ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "There is not even a single note in the job." ) ); } else { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "At least one not is present in the job." ) ); } return feedback; }
public static List<ImportValidationFeedback> getErrors( List<ImportValidationFeedback> feedback ) { List<ImportValidationFeedback> errors = new ArrayList<ImportValidationFeedback>(); for ( ImportValidationFeedback error : feedback ) { if ( error.isError() ) { errors.add( error ); } } return errors; }
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 );
private boolean toExport( AbstractMeta meta ) { boolean shouldExport = true; List<ImportValidationFeedback> feedback = importRules.verifyRules( meta ); List<ImportValidationFeedback> errors = ImportValidationFeedback.getErrors( feedback ); if ( !errors.isEmpty() ) { shouldExport = false; log.logError( BaseMessages.getString( PKG, "PurRepositoryExporter.ERROR_EXPORT_ITEM", meta.getName() ) ); //$NON-NLS-1$ for ( ImportValidationFeedback error : errors ) { log.logError( BaseMessages.getString( PKG, "PurRepositoryExporter.ERROR_EXPORT_ITEM_RULE", error.toString() ) ); //$NON-NLS-1$ } } return shouldExport; }
@Override public List<ImportValidationFeedback> verifyRule( Object subject ) { List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>(); if ( !isEnabled() ) { return feedback; } if ( !( subject instanceof TransMeta ) ) { return feedback; } TransMeta transMeta = (TransMeta) subject; if ( transMeta.nrNotes() == 0 ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "There is not even a single note in the transformation." ) ); } else { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "At least one not is present in the transformation." ) ); } return feedback; }
private List<ImportValidationFeedback> validateObject( Object subject, boolean boolFeedback ) throws KettleException { if ( !hasRules ) { return Collections.emptyList(); } if ( !boolFeedback ) { // this is call from Pan, job Executor or somthing else - we should throw // exception if one or more export rules is viloated. RepositoryImporter.validateImportedElement( importRules, subject ); } List<ImportValidationFeedback> feedback = importRules.verifyRules( subject ); List<ImportValidationFeedback> errors = new ArrayList<ImportValidationFeedback>( feedback.size() ); for ( ImportValidationFeedback res : feedback ) { if ( res.isError() ) { errors.add( res ); } } return errors; }
@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; }
@Override public List<ImportValidationFeedback> verifyRule( Object subject ) { List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>(); if ( !isEnabled() ) { return feedback; } if ( !( subject instanceof TransMeta ) ) { return feedback; } TransMeta transMeta = (TransMeta) subject; String description = transMeta.getDescription(); if ( Utils.isEmpty( description ) || ( minLength > 0 && description.length() < minLength ) ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "A description is not present or is too short." ) ); } else { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "A description is present" ) ); } return feedback; }
@Override public List<ImportValidationFeedback> verifyRule( Object subject ) { List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>(); if ( !isEnabled() ) { return feedback; } if ( !( subject instanceof TransMeta ) ) { return feedback; } TransMeta transMeta = (TransMeta) subject; for ( int i = 0; i < transMeta.nrTransHops(); i++ ) { TransHopMeta hop = transMeta.getTransHop( i ); if ( !hop.isEnabled() ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "There is a disabled hop in the transformation." ) ); } } if ( feedback.isEmpty() ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "All hops are enabled in this transformation." ) ); } return feedback; }
@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; for ( int i = 0; i < jobMeta.nrJobHops(); i++ ) { JobHopMeta hop = jobMeta.getJobHop( i ); if ( !hop.isEnabled() ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "There is a disabled hop in the job." ) ); } } if ( feedback.isEmpty() ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "All hops are enabled in this job." ) ); } return feedback; }
feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "The logging table is not defined" ) ); } else { if ( !Utils.isEmpty( schemaName ) ) { if ( schemaName.equals( transLogTable.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 ) ); 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 ) ); 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 ) ); feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "The logging table is correctly defined" ) );
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 ) ); 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 ) ); 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 ) ); feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "The logging table is correctly defined" ) );
feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "This rule contains no database to validate against." ) ); return feedback; feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "The name of the database is not set to the expected value '" + databaseMeta.getDatabaseName() + "'." ) ); 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 '" feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "The database port of the database is not set to the expected value '" 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 '" feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "The password of the database is not set to the expected value." ) ); feedback.add( new ImportValidationFeedback(