details:   https://code.openbravo.com/erp/devel/pi/rev/4940d1f96b76
changeset: 15606:4940d1f96b76
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Thu Feb 23 17:49:31 2012 +0100
summary:   Related to issue 19839: Adds exception handling in the Alert window

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertManagementActionHandler.java
 |  58 +++++----
 1 files changed, 32 insertions(+), 26 deletions(-)

diffs (76 lines):

diff -r 334833f4c3a7 -r 4940d1f96b76 
modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertManagementActionHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertManagementActionHandler.java
   Thu Feb 23 17:32:29 2012 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertManagementActionHandler.java
   Thu Feb 23 17:49:31 2012 +0100
@@ -30,6 +30,7 @@
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.hibernate.SQLQuery;
+import org.hibernate.exception.SQLGrammarException;
 import org.openbravo.client.kernel.BaseActionHandler;
 import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.dal.core.OBContext;
@@ -138,33 +139,38 @@
                 .addEntity(Alert.ENTITY_NAME);
             sqlQuery.setParameter(0, alertRule.getId());
 
-            log4j.debug("Alert " + alertRule.getName() + " (" + 
alertRule.getId() + ") - SQL:'"
-                + sql + "' - Rows: " + sqlQuery.list().size());
-            // It is not possible to add an SQL filter clause to the grid's 
default datasource.
-            // A String with the alert_id's to filter the grid's so only 
alerts with access are
-            // shown.
-            if (sqlQuery.list().size() > 0) {
-              // Alert rule returns data, adding it to list of alert rules.
-              alertRuleJson = new JSONObject();
-              alertRuleJson.put("name", alertRule.getIdentifier());
-              alertRuleJson.put("alertRuleId", alertRule.getId());
-              if (alertRule.getTab() != null) {
-                alertRuleJson.put("tabId", alertRule.getTab().getId());
-              } else {
-                alertRuleJson.put("tabId", "");
+            try {
+              log4j.debug("Alert " + alertRule.getName() + " (" + 
alertRule.getId() + ") - SQL:'"
+                  + sql + "' - Rows: " + sqlQuery.list().size());
+              // It is not possible to add an SQL filter clause to the grid's 
default datasource.
+              // A String with the alert_id's to filter the grid's so only 
alerts with access are
+              // shown.
+              if (sqlQuery.list().size() > 0) {
+                // Alert rule returns data, adding it to list of alert rules.
+                alertRuleJson = new JSONObject();
+                alertRuleJson.put("name", alertRule.getIdentifier());
+                alertRuleJson.put("alertRuleId", alertRule.getId());
+                if (alertRule.getTab() != null) {
+                  alertRuleJson.put("tabId", alertRule.getTab().getId());
+                } else {
+                  alertRuleJson.put("tabId", "");
+                }
+
+                String filterAlerts = "";
+                @SuppressWarnings("unchecked")
+                List<Alert> alerts = sqlQuery.list();
+                for (Alert alert : alerts) {
+                  if (!filterAlerts.isEmpty()) {
+                    filterAlerts += ", ";
+                  }
+                  filterAlerts += "'" + alert.getId() + "'";
+                }
+                alertRuleJson.put("alerts", filterAlerts);
+
               }
-
-              String filterAlerts = "";
-              @SuppressWarnings("unchecked")
-              List<Alert> alerts = sqlQuery.list();
-              for (Alert alert : alerts) {
-                if (!filterAlerts.isEmpty()) {
-                  filterAlerts += ", ";
-                }
-                filterAlerts += "'" + alert.getId() + "'";
-              }
-              alertRuleJson.put("alerts", filterAlerts);
-
+            } catch (SQLGrammarException e) {
+              log4j.error(
+                  "An error has ocurred when trying to process the alerts: " + 
e.getMessage(), e);
             }
           }
           if (alertRuleJson != null) {

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to