CI: merge back from main
authorRM packaging bot <staff.rm@openbravo.com>
Tue, 05 Feb 2013 22:43:37 +0100
changeset 19605 d40d6073a1dd
parent 19604 b721b6ed25cb (diff)
parent 19602 86db3ad54671 (current diff)
child 19606 1606aff2fafb
CI: merge back from main
src-db/database/sourcedata/AD_MODULE.xml
--- a/src-db/database/sourcedata/AD_MODULE.xml	Tue Feb 05 22:26:12 2013 +0100
+++ b/src-db/database/sourcedata/AD_MODULE.xml	Tue Feb 05 22:43:37 2013 +0100
@@ -22,7 +22,7 @@
 <!--0-->  <ISTRANSLATIONMODULE><![CDATA[N]]></ISTRANSLATIONMODULE>
 <!--0-->  <HASREFERENCEDATA><![CDATA[Y]]></HASREFERENCEDATA>
 <!--0-->  <REFERENCEDATAINFO><![CDATA[Standard document types for orders, invoices, etc. and settings]]></REFERENCEDATAINFO>
-<!--0-->  <VERSION_LABEL><![CDATA[CI]]></VERSION_LABEL>
+<!--0-->  <VERSION_LABEL><![CDATA[dev]]></VERSION_LABEL>
 <!--0-->  <ISCOMMERCIAL><![CDATA[N]]></ISCOMMERCIAL>
 <!--0-->  <ISTRIALALLOWED><![CDATA[N]]></ISTRIALALLOWED>
 <!--0--></AD_MODULE>
Binary file src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/User1Ready.class has changed
Binary file src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/User1ReadyData.class has changed
--- a/src-util/buildvalidation/src/org/openbravo/buildvalidation/User1Ready.java	Tue Feb 05 22:26:12 2013 +0100
+++ b/src-util/buildvalidation/src/org/openbravo/buildvalidation/User1Ready.java	Tue Feb 05 22:43:37 2013 +0100
@@ -27,15 +27,27 @@
  * This validation is related to an API change done to implement properly User1 and User2 Dimensions. This change was introduced by MP18
  */
 public class User1Ready extends BuildValidation {
-   
+  String [] tables = {"a_amortization", "c_budgetline", "c_cash", "c_dp_management", 
+      "c_invoice", "c_invoiceline_acctdimension", "c_order", "c_settlement", "c_validcombination", 
+      "fin_finacc_transaction", "fin_payment",  "fact_acct", "gl_journal", "gl_journalline", "m_inout", 
+      "m_inventory", "m_movement", "m_production"};
+  String [] columns = {"user2_id", "user1_id"};
   @Override
   public List<String> execute() {
     ConnectionProvider cp = getConnectionProvider();
     ArrayList<String> errors = new ArrayList<String>();
     try {
-      if(!User1ReadyData.tableExists(cp)){
-        if (!User1ReadyData.countUser1Usage(cp).equals("0")) {
-  	  errors.add("You can not apply this MP because your instance fails in the pre-validation phase: User1 and User2 dimensions information needs to be properly migrated to newly created tables (User1 and User2). Please contact support.openbravo.com for further details");
+      if(!User1ReadyData.tableExists(cp, "user1")){
+        for(String table: tables){
+          if(User1ReadyData.tableExists(cp, table)){
+            for(String column: columns){
+              if(User1ReadyData.columnExists(cp, column, table)){
+                if (!User1ReadyData.countUser1Usage(cp, table, column).equals("0")) {
+          	  errors.add("You can not apply this MP because your instance fails in the pre-validation phase: User1 and User2 dimensions information needs to be properly migrated to newly created tables (User1 and User2). Please contact support.openbravo.com for further details");
+                }
+              }
+            }
+          }
         }
       }
     } catch (Exception e) {
--- a/src-util/buildvalidation/src/org/openbravo/buildvalidation/User1Ready_data.xsql	Tue Feb 05 22:26:12 2013 +0100
+++ b/src-util/buildvalidation/src/org/openbravo/buildvalidation/User1Ready_data.xsql	Tue Feb 05 22:43:37 2013 +0100
@@ -28,36 +28,34 @@
     ]]></Sql>
    </SqlMethod>
    <SqlMethod name="tableExists" type="preparedStatement" return="boolean">
-      <SqlMethodComment>Checks if User1 table exists in AD. This table has been added in 3.0MP18</SqlMethodComment>
+      <SqlMethodComment>Checks if table exists in AD.</SqlMethodComment>
       <Sql><![CDATA[
              select tablename
              from ad_table
-             where lower(tablename) = 'user1'
+             where lower(tablename) = ?
       ]]></Sql>
+     <Parameter name="tableName"/>
+   </SqlMethod>
+   <SqlMethod name="columnExists" type="preparedStatement" return="boolean">
+      <SqlMethodComment>Checks if table exists in AD.</SqlMethodComment>
+      <Sql><![CDATA[
+             select columnname
+             from ad_column, ad_table
+             where ad_column.ad_table_id = ad_table.ad_table_id
+             and lower(columnname) = ?
+             and lower(tablename) = ?
+      ]]></Sql>
+     <Parameter name="columnname"/>
+     <Parameter name="tablename"/>
    </SqlMethod>
    <SqlMethod name="countUser1Usage" type="preparedStatement" return="string">
       <SqlMethodComment></SqlMethodComment>
       <Sql><![CDATA[
         SELECT COUNT(1) AS RECORDS
         FROM DUAL
-        WHERE EXISTS (SELECT 1 FROM A_Amortization WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM C_BudgetLine WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM C_Cash WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM C_DP_Management WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM C_Invoice WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM C_InvoiceLine_AcctDimension WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM C_Order WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM C_Settlement WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM C_ValidCombination WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM FIN_Finacc_Transaction WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM FIN_Payment WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM Fact_Acct WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM GL_Journal WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM GL_JournalLine WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM M_InOut WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM M_Inventory WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM M_Movement WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
-        OR EXISTS (SELECT 1 FROM M_Production WHERE USER1_ID IS NOT NULL OR USER2_ID IS NOT NULL)
+        WHERE EXISTS (SELECT 1 FROM A_Amortization WHERE  USER1_ID IS NOT NULL)
       ]]></Sql>
+     <Parameter name="tableName" type="replace" optional="true" after="SELECT 1 FROM " text="A_Amortization"/>
+     <Parameter name="columnName" type="replace" optional="true" after="WHERE  " text="USER1_ID"/>
    </SqlMethod>
 </SqlClass>