details:   https://code.openbravo.com/erp/devel/pi/rev/ec2f20c12634
changeset: 13139:ec2f20c12634
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Mon Jul 11 16:11:50 2011 +0200
summary:   Fixed issue 11137. Validation for foreign keys will now be correct.

diffstat:

 src/org/openbravo/service/system/DatabaseValidator.java |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r beefbf9a03da -r ec2f20c12634 
src/org/openbravo/service/system/DatabaseValidator.java
--- a/src/org/openbravo/service/system/DatabaseValidator.java   Mon Jul 11 
14:39:23 2011 +0200
+++ b/src/org/openbravo/service/system/DatabaseValidator.java   Mon Jul 11 
16:11:50 2011 +0200
@@ -211,10 +211,10 @@
       }
     }
     for (int i = 0; i < database.getTableCount(); i++) {
-      checkForeignKeys(database.getTable(i), result);
+      checkForeignKeys(validateModule, database.getTable(i), result);
     }
     for (int i = 0; i < database.getModifiedTableCount(); i++) {
-      checkForeignKeys(database.getModifiedTable(i), result);
+      checkForeignKeys(validateModule, database.getModifiedTable(i), result);
     }
 
     // only check this one if the global validate check is done
@@ -360,7 +360,8 @@
     return null;
   }
 
-  private void checkForeignKeys(org.apache.ddlutils.model.Table table, 
SystemValidationResult result) {
+  private void checkForeignKeys(Module module, org.apache.ddlutils.model.Table 
table,
+      SystemValidationResult result) {
     final Entity entity = 
ModelProvider.getInstance().getEntityByTableName(table.getName());
     if (entity == null) {
       // can happen with mismatches
@@ -389,6 +390,14 @@
           continue;
         }
 
+        // if the property doesn't belong to the module, then it shouldn't be 
checked, as the
+        // physical model will not contain it
+        if (module != null
+            && (property.getModule() == null || !module.getId()
+                .equals(property.getModule().getId()))) {
+          continue;
+        }
+
         boolean found = false;
         for (ForeignKey fk : table.getForeignKeys()) {
           for (Reference reference : fk.getReferences()) {

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to