details:   https://code.openbravo.com/erp/devel/pi/rev/93ee9377d01e
changeset: 21103:93ee9377d01e
user:      Shankar Balachandran <shankar.balachandran <at> openbravo.com>
date:      Mon Sep 09 16:08:58 2013 +0530
summary:   Fixes Issue 0024677 : Error in linked item when using datasource 
based tables

Linked items is currently calculated through sql and so datasource based tables 
are not supported yet.
Added code to only fetch tables with dataorigintype 'Table'.

diffstat:

 src/org/openbravo/erpCommon/utility/UsedByLink.java      |  18 ++++++++++-----
 src/org/openbravo/erpCommon/utility/UsedByLink_data.xsql |   3 +-
 2 files changed, 14 insertions(+), 7 deletions(-)

diffs (49 lines):

diff -r 7ea21b334c48 -r 93ee9377d01e 
src/org/openbravo/erpCommon/utility/UsedByLink.java
--- a/src/org/openbravo/erpCommon/utility/UsedByLink.java       Mon Sep 09 
13:11:02 2013 +0200
+++ b/src/org/openbravo/erpCommon/utility/UsedByLink.java       Mon Sep 09 
16:08:58 2013 +0530
@@ -646,8 +646,8 @@
   private List<LinkedTable> getLinkedTables(String tableId) {
     OBContext.setAdminMode();
     try {
-      Table table = OBDal.getInstance().get(Table.class, tableId);
-      String tableName = table.getDBTableName();
+      Table table = OBDal.getInstance().get(Table.class, tableId), 
linkedTableObject = null;
+      String tableName = table.getDBTableName(), dataOriginType = null, 
linkedTableId = null;
 
       final List<LinkedTable> linkedTables = new ArrayList<LinkedTable>();
       for (Entity entity : ModelProvider.getInstance().getModel()) {
@@ -656,10 +656,16 @@
           if (!property.isOneToMany() && property.getColumnName() != null
               && property.getTargetEntity() != null
               && 
property.getTargetEntity().getTableName().equalsIgnoreCase(tableName)) {
-            final LinkedTable linkedTable = new LinkedTable();
-            log4j.debug("p:" + property.getColumnName());
-            linkedTable.setColumnId(property.getColumnId());
-            linkedTables.add(linkedTable);
+            // Datasource tables are skipped
+            linkedTableId = property.getEntity().getTableId();
+            linkedTableObject = OBDal.getInstance().get(Table.class, 
linkedTableId);
+            dataOriginType = linkedTableObject.getDataOriginType();
+            if ("TABLE".equals(dataOriginType.toUpperCase())) {
+              final LinkedTable linkedTable = new LinkedTable();
+              log4j.debug("p:" + property.getColumnName());
+              linkedTable.setColumnId(property.getColumnId());
+              linkedTables.add(linkedTable);
+            }
           }
         }
       }
diff -r 7ea21b334c48 -r 93ee9377d01e 
src/org/openbravo/erpCommon/utility/UsedByLink_data.xsql
--- a/src/org/openbravo/erpCommon/utility/UsedByLink_data.xsql  Mon Sep 09 
13:11:02 2013 +0200
+++ b/src/org/openbravo/erpCommon/utility/UsedByLink_data.xsql  Mon Sep 09 
16:08:58 2013 +0530
@@ -86,8 +86,9 @@
         AD_FIELD F left join AD_FIELD_TRL Ft on F.AD_FIELD_ID = Ft.AD_FIELD_ID
                                             AND Ft.AD_LANGUAGE  = ? 
         WHERE W.AD_WINDOW_ID = TB.AD_WINDOW_ID
-        AND TB.AD_TABLE_ID = T.AD_TABLE_ID 
+        AND TB.AD_TABLE_ID = T.AD_TABLE_ID
         AND T.AD_TABLE_ID = C.AD_TABLE_ID 
+        AND UPPER(T.dataorigintype) = 'TABLE'
         AND C.AD_COLUMN_ID = A.AD_COLUMN_ID 
         AND C.AD_COLUMN_ID = F.AD_COLUMN_ID 
         AND W.AD_WINDOW_ID = M.AD_WINDOW_ID 

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to