[Warehouse]Code review AlertMASequenceProduct alert
authorSandra Huguet <sandra.huguet@openbravo.com>
Mon, 05 Nov 2012 12:54:58 +0100
changeset 18678 6b67f5a1de4d
parent 18677 16b53aef8d52
child 18679 56ba1e43ba88
[Warehouse]Code review AlertMASequenceProduct alert
src-util/modulescript/build/classes/org/openbravo/modulescript/AlertMASequenceProduct.class
src-util/modulescript/build/classes/org/openbravo/modulescript/AlertMASequenceProductData.class
src-util/modulescript/src/org/openbravo/modulescript/AlertMASequenceProduct.java
src-util/modulescript/src/org/openbravo/modulescript/AlertMASequenceProduct_data.xsql
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/AlertMASequenceProduct.class has changed
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/AlertMASequenceProductData.class has changed
--- a/src-util/modulescript/src/org/openbravo/modulescript/AlertMASequenceProduct.java	Mon Nov 05 11:59:18 2012 +0100
+++ b/src-util/modulescript/src/org/openbravo/modulescript/AlertMASequenceProduct.java	Mon Nov 05 12:54:58 2012 +0100
@@ -32,10 +32,11 @@
   public void execute() {
     try {
       ConnectionProvider cp = getConnectionProvider();
-      
-      AlertMASequenceProductData[] data = AlertMASequenceProductData.select(cp);
-      for (AlertMASequenceProductData seqproduct : data) {
-        createAlert(cp, seqproduct);
+      if (!AlertMASequenceProductData.existsAlertRuleAnyClient(cp, ALERT_RULE)) {
+        AlertMASequenceProductData[] data = AlertMASequenceProductData.select(cp);
+        for (AlertMASequenceProductData seqproduct : data) {
+          createAlert(cp, seqproduct);
+        } 
       }
       
     } catch (Exception e) {
--- a/src-util/modulescript/src/org/openbravo/modulescript/AlertMASequenceProduct_data.xsql	Mon Nov 05 11:59:18 2012 +0100
+++ b/src-util/modulescript/src/org/openbravo/modulescript/AlertMASequenceProduct_data.xsql	Mon Nov 05 12:54:58 2012 +0100
@@ -1,11 +1,21 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!--
- ************************************************************************************
- * Copyright (C) 2011 Openbravo S.L.U.
- * Licensed under the Openbravo Commercial License version 1.0
- * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
- * or in the legal folder of this module distribution.
- ************************************************************************************
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * 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 Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
 -->
 <SqlClass name="AlertMASequenceProductData" package="org.openbravo.modulescript">
    <SqlClassComment></SqlClassComment>
@@ -34,6 +44,19 @@
     <Parameter name="alertRule"/>
     <Parameter name="client"/>
   </SqlMethod>
+  
+    <SqlMethod name="existsAlertRuleAnyClient" type="preparedStatement" return="boolean">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+       SELECT COUNT(*) AS EXISTING
+       FROM AD_ALERTRULE
+       WHERE NAME = ?
+         AND ISACTIVE = 'Y'
+      ]]>
+    </Sql>
+    <Parameter name="alertRule"/>
+  </SqlMethod>
+  
   <SqlMethod name="existsAlert" type="preparedStatement" return="boolean">
     <SqlMethodComment></SqlMethodComment>
     <Sql><![CDATA[
@@ -59,7 +82,6 @@
     <Parameter name="name"/>
     <Parameter name="client"/>
   </SqlMethod>
- 
   <SqlMethod name="getRoleId" type="preparedStatement" return="multiple">
     <SqlMethodComment></SqlMethodComment>
     <Sql><![CDATA[