Fixes Issue 25511:WrongMatchInvAccounting modulescript alertrule performance
authorAtul Gaware <atul.gaware@openbravo.com>
Fri, 24 Jan 2014 14:30:20 +0530
changeset 21872 7b4ae1da74cb
parent 21871 fcc10a50bab6
child 21873 6e74e41e0a0f
Fixes Issue 25511:WrongMatchInvAccounting modulescript alertrule performance
src-util/modulescript/build/classes/org/openbravo/modulescript/Issue21640WrongMatchInvAccounting.class
src-util/modulescript/build/classes/org/openbravo/modulescript/Issue21640WrongMatchInvAccountingData.class
src-util/modulescript/src/org/openbravo/modulescript/Issue21640WrongMatchInvAccounting.java
src-util/modulescript/src/org/openbravo/modulescript/Issue21640WrongMatchInvAccounting_data.xsql
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/Issue21640WrongMatchInvAccounting.class has changed
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/Issue21640WrongMatchInvAccountingData.class has changed
--- a/src-util/modulescript/src/org/openbravo/modulescript/Issue21640WrongMatchInvAccounting.java	Mon Jan 27 14:44:00 2014 +0530
+++ b/src-util/modulescript/src/org/openbravo/modulescript/Issue21640WrongMatchInvAccounting.java	Fri Jan 24 14:30:20 2014 +0530
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2012 Openbravo SLU
+ * All portions are Copyright (C) 2012-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -41,10 +41,14 @@
         if (!Issue21640WrongMatchInvAccountingData.existsAlertRule(cp, ALERT_RULE1,
             client.adClientId)) {
           createAlert1(cp, client.adClientId);
+        } else {
+          Issue21640WrongMatchInvAccountingData.updateAlertRule(cp, client.adClientId, ALERT_RULE1);
         }
         if (!Issue21640WrongMatchInvAccountingData.existsAlertRule(cp, ALERT_RULE2,
             client.adClientId)) {
           createAlert2(cp, client.adClientId);
+        } else {
+          Issue21640WrongMatchInvAccountingData.updateAlertRule(cp, client.adClientId, ALERT_RULE2);
         }
       }
     } catch (Exception e) {
@@ -54,7 +58,7 @@
 
   private void createAlert1(ConnectionProvider cp, String clientId) throws ServletException {
     Issue21640WrongMatchInvAccountingData.insertAlertRule(cp, clientId, ALERT_RULE1, MATCHINV_TAB,
-        ALERT_RULE_SQL1);
+        "");
     final String alertRuleId = Issue21640WrongMatchInvAccountingData.getAlertRuleId(cp,
         ALERT_RULE1, clientId);
     Issue21640WrongMatchInvAccountingData[] roles = Issue21640WrongMatchInvAccountingData
@@ -74,7 +78,7 @@
 
   private void createAlert2(ConnectionProvider cp, String clientId) throws ServletException {
     Issue21640WrongMatchInvAccountingData.insertAlertRule(cp, clientId, ALERT_RULE2, MATCHINV_TAB,
-        ALERT_RULE_SQL2);
+        "");
     final String alertRuleId = Issue21640WrongMatchInvAccountingData.getAlertRuleId(cp,
         ALERT_RULE2, clientId);
     Issue21640WrongMatchInvAccountingData[] roles = Issue21640WrongMatchInvAccountingData
--- a/src-util/modulescript/src/org/openbravo/modulescript/Issue21640WrongMatchInvAccounting_data.xsql	Mon Jan 27 14:44:00 2014 +0530
+++ b/src-util/modulescript/src/org/openbravo/modulescript/Issue21640WrongMatchInvAccounting_data.xsql	Fri Jan 24 14:30:20 2014 +0530
@@ -12,7 +12,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2012 Openbravo SLU
+ * All portions are Copyright (C) 2012-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -131,7 +131,7 @@
       ) VALUES (
         get_uuid(), ?, '0', 'Y',
         now(), '100', now(), '100',
-        ?, ?, '', 'D',
+        ?, ?, '', 'E',
         ?
       )
     ]]></Sql>
@@ -140,6 +140,17 @@
     <Parameter name="tabId"/>
     <Parameter name="sql"/>
   </SqlMethod>
+  <SqlMethod name="updateAlertRule" type="preparedStatement" return="rowcount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        UPDATE AD_AlertRule 
+        SET SQL='', TYPE='E' WHERE AD_Client_ID = ? AND NAME = ?
+      ]]>
+    </Sql>
+    <Parameter name="clientId"/>
+    <Parameter name="name"/>
+  </SqlMethod>
   <SqlMethod name="insertAlert" type="preparedStatement" return="rowcount">
     <SqlMethodComment></SqlMethodComment>
     <Sql><![CDATA[