Fixes issue 20891: not possible to upgrade from 2.50 MP43 to 3.0 MP12
authorMikel Irurita <mikel.irurita@openbravo.com>
Thu, 28 Jun 2012 16:33:26 +0200
changeset 17301 54fb97e8175d
parent 17300 e40f0602d615
child 17302 0d1948d3e516
Fixes issue 20891: not possible to upgrade from 2.50 MP43 to 3.0 MP12
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/AccountingTabs.class
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/AccountingTabsData.class
src-util/buildvalidation/src/org/openbravo/buildvalidation/AccountingTabs.java
src-util/buildvalidation/src/org/openbravo/buildvalidation/AccountingTabs_data.xsql
Binary file src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/AccountingTabs.class has changed
Binary file src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/AccountingTabsData.class has changed
--- a/src-util/buildvalidation/src/org/openbravo/buildvalidation/AccountingTabs.java	Thu Jun 28 16:31:17 2012 +0200
+++ b/src-util/buildvalidation/src/org/openbravo/buildvalidation/AccountingTabs.java	Thu Jun 28 16:33:26 2012 +0200
@@ -105,8 +105,13 @@
       StringBuilder msg = new StringBuilder();
 
       for (int i = 0; i < alert.length; i++) {
-        if (AccountingTabsData.existsReference(cp, adAlertruleId, alert[i].referencekeyId).equals(
-            "0")) {
+        boolean existsReference = false;
+        if (AccountingTabsData.existsStatusColumn(cp)) {
+          existsReference = AccountingTabsData.existsReference(cp, adAlertruleId, alert[i].referencekeyId);
+        } else {
+          existsReference = AccountingTabsData.existsReferenceOld(cp, adAlertruleId, alert[i].referencekeyId);
+        }
+        if (!existsReference) {
           AccountingTabsData.insertAlert(cp, alert[i].description, alertRule[0].adAlertruleId,
               alert[i].recordId, alert[i].referencekeyId);
         }
--- a/src-util/buildvalidation/src/org/openbravo/buildvalidation/AccountingTabs_data.xsql	Thu Jun 28 16:31:17 2012 +0200
+++ b/src-util/buildvalidation/src/org/openbravo/buildvalidation/AccountingTabs_data.xsql	Thu Jun 28 16:33:26 2012 +0200
@@ -112,18 +112,39 @@
       <Parameter name="tabId"/>
       <Parameter name="sql"/>
   </SqlMethod>
-   <SqlMethod name="existsReference" type="preparedStatement" return="string">
+   <SqlMethod name="existsReference" type="preparedStatement" return="boolean">
       <SqlMethodComment></SqlMethodComment>
       <Sql><![CDATA[
           SELECT COUNT(*) AS EXISTING
             FROM AD_ALERT
            WHERE AD_ALERTRULE_ID = ?
              AND REFERENCEKEY_ID = ?
-             AND STATUS != 'SOLVED'
+             AND COALESCE(STATUS, 'NEW') != 'SOLVED'
       ]]></Sql>
       <Parameter name="alertRule"/>
       <Parameter name="ref"/>      
    </SqlMethod>
+   <SqlMethod name="existsReferenceOld" type="preparedStatement" return="boolean">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+       SELECT COUNT(*) AS EXISTING
+       FROM AD_ALERT
+       WHERE AD_ALERTRULE_ID = ?
+         AND REFERENCEKEY_ID = ?
+         AND ISFIXED = 'N'
+    ]]></Sql>
+    <Parameter name="alertRule"/>
+    <Parameter name="ref"/>
+  </SqlMethod>
+   <SqlMethod name="existsStatusColumn" type="preparedStatement" return="boolean">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+       SELECT COUNT(*) AS EXISTING
+       FROM  user_tab_columns
+       WHERE lower(table_name) like 'ad_alert'
+         AND lower(column_name) like 'status'
+    ]]></Sql>
+  </SqlMethod>
    <SqlMethod name="insertAlert" type="preparedStatement"
    	return="rowcount">
    	<SqlMethodComment></SqlMethodComment>