Add check.window.compatibility task, which can be used to find out what windows will be shown in classic mode.
authorAntonio Moreno <antonio.moreno@openbravo.com>
Tue, 08 Mar 2011 17:49:56 +0100
changeset 11114 c4bf3d9f768f
parent 11113 dcea0231fee9
child 11115 af8ac7dfdebc
Add check.window.compatibility task, which can be used to find out what windows will be shown in classic mode.
build.xml
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/WindowsInClassicModeTask.java
--- a/build.xml	Tue Mar 08 17:24:52 2011 +0100
+++ b/build.xml	Tue Mar 08 17:49:56 2011 +0100
@@ -1114,4 +1114,11 @@
     </taskdef>
     <checkConsistency userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties"/>
   </target>
+  
+  <target name="check.window.compatibility">
+    <taskdef name="showclassicwindows" classname="org.openbravo.client.application.WindowsInClassicModeTask">
+      <classpath refid="project.class.path" />
+    </taskdef>
+    <showclassicwindows userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties"/>
+  </target>
 </project>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java	Tue Mar 08 17:24:52 2011 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java	Tue Mar 08 17:49:56 2011 +0100
@@ -18,6 +18,7 @@
  */
 package org.openbravo.client.application;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -49,35 +50,51 @@
   private static Logger log = Logger.getLogger(ApplicationUtils.class);
 
   static boolean showWindowInClassicMode(Window window) {
+    List<String> reasonsToBeShownInClassic = new ArrayList<String>();
+    showWindowInClassicMode(window, reasonsToBeShownInClassic);
+    return reasonsToBeShownInClassic.size() > 0;
+  }
+
+  static void showWindowInClassicMode(Window window, List<String> reasonsToBeShownInClassic) {
     // FIXME Remove this once ImageBLOB is implemented
     // Currently, windows with ImageBLOB reference columns will be shown in classic mode
     String qryStr = "as f where f.column.reference.id = '4AA6C3BE9D3B4D84A3B80489505A23E5' "
         + "and f.tab.window.id = :windowId ";
+    List<String> reasonsOfWindow = new ArrayList<String>();
     OBQuery<Field> qry = OBDal.getInstance().createQuery(Field.class, qryStr);
     qry.setNamedParameter("windowId", window.getId());
     if (qry.count() > 0) {
-      return true;
+      String reason = "   One or more columns in the window " + window.getName()
+          + " have an ImageBLOB reference ";
+      reasonsOfWindow.add(reason);
     }
 
     for (Tab tab : window.getADTabList()) {
       if (tab.getSQLWhereClause() != null && tab.getHqlwhereclause() == null) {
         // There is a tab with a SQL whereclause, but without a defined HQL whereclause
-        return true;
+        reasonsOfWindow.add("   The tab " + tab.getName() + " of the window " + window.getName()
+            + " has a SQLWhereClause, but not an HQLWhereClause");
       }
       if (tab.getSQLOrderByClause() != null && tab.getHqlorderbyclause() == null) {
         // There is a tab with a SQL order by clause, but without a defined HQL order by clause
-        return true;
+        reasonsOfWindow.add("   The tab " + tab.getName() + " of the window " + window.getName()
+            + " has a SQLOrderByClause, but not an HQLOrderByClause");
       }
       if (tab.getFilterClause() != null && tab.getHqlfilterclause() == null) {
         // There is a tab with a SQL filter clause, but without a defined HQL filter clause
-        return true;
+        reasonsOfWindow.add("   The tab " + tab.getName() + " of the window " + window.getName()
+            + " has a FilterClause, but not an HQLFilterClause");
       }
       if (tab.getMasterDetailForm() != null) {
         // There is a tab which is a manual form
-        return true;
+        reasonsOfWindow.add("   The tab " + tab.getName() + " of the window " + window.getName()
+            + " is a manual form");
       }
     }
-    return false;
+    if (reasonsOfWindow.size() > 0) {
+      reasonsToBeShownInClassic.add("Window: " + window.getName());
+      reasonsToBeShownInClassic.addAll(reasonsOfWindow);
+    }
   }
 
   /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/WindowsInClassicModeTask.java	Tue Mar 08 17:49:56 2011 +0100
@@ -0,0 +1,39 @@
+package org.openbravo.client.application;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.hibernate.criterion.Expression;
+import org.openbravo.dal.core.DalInitializingTask;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.dal.service.OBDao;
+import org.openbravo.dal.service.OBQuery;
+import org.openbravo.model.ad.module.Module;
+import org.openbravo.model.ad.ui.Window;
+
+public class WindowsInClassicModeTask extends DalInitializingTask {
+  private static final Logger log = Logger.getLogger(WindowsInClassicModeTask.class);
+
+  @Override
+  protected void doExecute() {
+    OBQuery<Module> modules = OBDal.getInstance().createQuery(Module.class, "");
+    for (Module module : modules.list()) {
+      List<String> classicWindowMessages = new ArrayList<String>();
+      OBCriteria<Window> windowsOfModule = OBDao.getFilteredCriteria(Window.class, Expression.eq(
+          Window.PROPERTY_MODULE, module));
+      for (Window window : windowsOfModule.list()) {
+        ApplicationUtils.showWindowInClassicMode(window, classicWindowMessages);
+      }
+      if (classicWindowMessages.size() > 0) {
+        log.info("Module: " + module.getName());
+        log.info("The following windows will be shown in classic mode:");
+        for (String message : classicWindowMessages) {
+          log.info("  " + message);
+        }
+      }
+    }
+    log.info("The rest of the windows will be shown in new mode.");
+  }
+}