Fixed issue 20413. Two changes have been made:
authorAntonio Moreno <antonio.moreno@openbravo.com>
Fri, 04 May 2012 12:31:22 +0200
changeset 16516 21fc11601168
parent 16515 d7a6f96f5831
child 16517 66f6c21ba5dc
Fixed issue 20413. Two changes have been made:
- EmailServerConfiguration will be retrieved correctly. The client/org filter has been disabled, because background processes are executed with a 'system' context, and this caused the list of email servers to always be empty unless the configuration was on the 'system' client itself.
- Also, the client will be picked from the alertrule instead of the first generated alert. This prevents strange problems when an alertrule generates alerts for different clients from happening.
src/org/openbravo/erpCommon/ad_process/AlertProcess.java
src/org/openbravo/erpCommon/ad_process/AlertProcess_data.xsql
--- a/src/org/openbravo/erpCommon/ad_process/AlertProcess.java	Wed Apr 25 16:55:56 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/AlertProcess.java	Fri May 04 12:31:22 2012 +0200
@@ -140,8 +140,8 @@
         // the 'Client' tab or in the 'Email Configuration' tab.
         // The SMTP server configured in 'Client' tab way is @Deprecated in 3.0
 
-        final String adClientId = alert[0].adClientId;
-        final String adOrgId = alert[0].adOrgId;
+        final String adClientId = alertRule.adClientId;
+        final String adOrgId = alertRule.adOrgId;
         final String deprecatedMailHost = OBDal.getInstance().get(Client.class, adClientId)
             .getMailHost();
         boolean isDeprecatedMode = false;
@@ -162,6 +162,8 @@
                 .createCriteria(EmailServerConfiguration.class);
             mailConfigCriteria.add(Restrictions.eq(EmailServerConfiguration.PROPERTY_CLIENT, OBDal
                 .getInstance().get(Client.class, adClientId)));
+            mailConfigCriteria.setFilterOnReadableClients(false);
+            mailConfigCriteria.setFilterOnReadableOrganization(false);
             final List<EmailServerConfiguration> mailConfigList = mailConfigCriteria.list();
 
             if (mailConfigList.size() > 0) {
@@ -194,6 +196,8 @@
                   .createCriteria(AlertRecipient.class);
               alertRecipientsCriteria.add(Restrictions.eq(AlertRecipient.PROPERTY_ALERTRULE, OBDal
                   .getInstance().get(AlertRule.class, alertRule.adAlertruleId)));
+              alertRecipientsCriteria.setFilterOnReadableClients(false);
+              alertRecipientsCriteria.setFilterOnReadableOrganization(false);
 
               final List<AlertRecipient> alertRecipientsList = alertRecipientsCriteria.list();
 
--- a/src/org/openbravo/erpCommon/ad_process/AlertProcess_data.xsql	Wed Apr 25 16:55:56 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/AlertProcess_data.xsql	Fri May 04 12:31:22 2012 +0200
@@ -76,7 +76,7 @@
    <SqlMethod name="selectSQL" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
       <Sql><![CDATA[
-        SELECT AD_ALERTRULE_ID, SQL, NAME
+        SELECT AD_ALERTRULE_ID, SQL, NAME, AD_CLIENT_ID, AD_ORG_ID
           FROM AD_ALERTRULE
          WHERE ISACTIVE = 'Y'
     ]]></Sql>
@@ -85,7 +85,7 @@
    <SqlMethod name="selectSQL" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
       <Sql><![CDATA[
-        SELECT AD_ALERTRULE_ID, SQL, NAME
+        SELECT AD_ALERTRULE_ID, SQL, NAME, AD_CLIENT_ID, AD_ORG_ID
           FROM AD_ALERTRULE
          WHERE ISACTIVE = 'Y'
            AND AD_CLIENT_ID = ?