details: https://code.openbravo.com/erp/devel/pi/rev/f412ba02b37b
changeset: 18205:f412ba02b37b
user: Augusto Mauch <augusto.mauch <at> openbravo.com>
date: Thu Oct 11 13:51:24 2012 +0200
summary: Fixes issue 21669: Validation when exporting Database not working
properly
There was a validation that was only being done to the tables that belonged to
the module being validated, but not to the tables modified by that module. Now,
if a module adds a column to a table that belongs to another module but forgets
to add it to the application dictionary, the validation will detect the error,
the same way it has been working for the columns defined in tables that
belonged to the module being validated.
diffstat:
src/org/openbravo/service/system/DatabaseValidator.java | 24 ++++++++++------
1 files changed, 15 insertions(+), 9 deletions(-)
diffs (45 lines):
diff -r ae79cd15bab6 -r f412ba02b37b
src/org/openbravo/service/system/DatabaseValidator.java
--- a/src/org/openbravo/service/system/DatabaseValidator.java Tue Oct 09
15:35:09 2012 +0200
+++ b/src/org/openbravo/service/system/DatabaseValidator.java Thu Oct 11
13:51:24 2012 +0200
@@ -168,11 +168,17 @@
// 2) table present in db, not in ad
// 3) table present on both sides, column match check
+ final Map<String, org.apache.ddlutils.model.Table> dbTablesByName = new
HashMap<String, org.apache.ddlutils.model.Table>();
+
final org.apache.ddlutils.model.Table[] dbTables =
getDatabase().getTables();
- final Map<String, org.apache.ddlutils.model.Table> dbTablesByName = new
HashMap<String, org.apache.ddlutils.model.Table>();
for (org.apache.ddlutils.model.Table dbTable : dbTables) {
dbTablesByName.put(dbTable.getName().toUpperCase(), dbTable);
}
+
+ final org.apache.ddlutils.model.Table[] dbModifiedTables =
getDatabase().getModifiedTables();
+ for (org.apache.ddlutils.model.Table dbModifiedTable : dbModifiedTables) {
+ dbTablesByName.put(dbModifiedTable.getName().toUpperCase(),
dbModifiedTable);
+ }
final Map<String, org.apache.ddlutils.model.Table> tmpDBTablesByName = new
HashMap<String, org.apache.ddlutils.model.Table>(
dbTablesByName);
@@ -464,14 +470,14 @@
}
}
- if (moduleId == null
- || (adTable.getDataPackage().getModule() != null &&
adTable.getDataPackage().getModule()
- .getId().equals(moduleId))) {
- for (org.apache.ddlutils.model.Column dbColumn :
dbColumnsByName.values()) {
-
result.addError(SystemValidationResult.SystemValidationType.NOT_EXIST_IN_AD,
"Column "
- + dbTable.getName() + "." + dbColumn.getName() + " present in the
database "
- + " but not defined in the Application Dictionary.");
- }
+ // The columns in dbColumnsByName belong either to the tables defined in
the module being
+ // validated, or
+ // to its modified tables, so they have to be checked always at this point
+
+ for (org.apache.ddlutils.model.Column dbColumn : dbColumnsByName.values())
{
+
result.addError(SystemValidationResult.SystemValidationType.NOT_EXIST_IN_AD,
"Column "
+ + dbTable.getName() + "." + dbColumn.getName() + " present in the
database "
+ + " but not defined in the Application Dictionary.");
}
}
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits