Removed unneeded codes and added treetype for the new dimensions
authorPandeeswari Ramakrishnan <pandeeswari.ramakrishnan@openbravo.com>
Thu, 04 Oct 2012 12:25:56 +0200
changeset 18824 9a08321af46f
parent 18823 e52da2aceaa6
child 18825 73f7ae811d69
Removed unneeded codes and added treetype for the new dimensions
src-db/database/model/triggers/C_COSTCENTER_TRG.xml
src-db/database/model/triggers/C_USER1_TRG.xml
src-db/database/model/triggers/C_USER2_TRG.xml
src-db/database/sourcedata/AD_TABLE.xml
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateADClientInfo.class
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateADClientInfoData.class
src-util/modulescript/src/org/openbravo/modulescript/UpdateADClientInfo.java
src-util/modulescript/src/org/openbravo/modulescript/UpdateADClientInfo_data.xsql
src/org/openbravo/erpCommon/utility/WindowTreeChecks.java
--- a/src-db/database/model/triggers/C_COSTCENTER_TRG.xml	Thu Oct 04 11:26:54 2012 +0200
+++ b/src-db/database/model/triggers/C_COSTCENTER_TRG.xml	Thu Oct 04 12:25:56 2012 +0200
@@ -19,7 +19,6 @@
 * Contributor(s):  ______________________________________.
 ************************************************************************/
     v_Tree_ID VARCHAR2(32);
-    v_Parent_ID VARCHAR2(32);
     v_count NUMBER;
     
 BEGIN
@@ -30,17 +29,11 @@
 
   IF (INSERTING) THEN    
     --  Create TreeNode --
-    --  get AD_Tree_ID + ParentID
-    SELECT c.AD_Tree_Costcenter_ID,
-      n.Node_ID
-    INTO v_Tree_ID,
-      v_Parent_ID
-    FROM AD_ClientInfo c,
-      AD_TreeNode n
-    WHERE c.AD_Tree_Costcenter_ID=n.AD_Tree_ID
-      AND n.Parent_ID IS NULL
-      AND c.AD_Client_ID=:new.AD_Client_ID;
-    --  DBMS_OUTPUT.PUT_LINE('Tree='||xTree_ID||'  Node='||:new.C_Project_ID||'  Parent='||xParent_ID);
+    SELECT c.AD_Tree_Costcenter_ID
+    INTO v_Tree_ID
+    FROM AD_ClientInfo c
+    WHERE c.AD_Client_ID=:new.AD_Client_ID;
+
     --  Insert into TreeNode
     INSERT
     INTO AD_TreeNode
@@ -55,7 +48,7 @@
         get_uuid(), :new.AD_Client_ID, :new.AD_Org_ID, :new.IsActive,
         :new.Created, :new.CreatedBy, :new.Updated,
         :new.UpdatedBy, v_Tree_ID, :new.C_Costcenter_ID,
-        v_Parent_ID,(
+        '0',(
         CASE :new.IsSummary
           WHEN 'Y'
           THEN 100
--- a/src-db/database/model/triggers/C_USER1_TRG.xml	Thu Oct 04 11:26:54 2012 +0200
+++ b/src-db/database/model/triggers/C_USER1_TRG.xml	Thu Oct 04 12:25:56 2012 +0200
@@ -19,7 +19,6 @@
 * Contributor(s):  ______________________________________.
 ************************************************************************/
     v_Tree_ID VARCHAR2(32);
-    v_Parent_ID VARCHAR2(32);
     v_count NUMBER;
     
 BEGIN
@@ -29,18 +28,13 @@
 
 
   IF (INSERTING) THEN    
+
     --  Create TreeNode --
-    --  get AD_Tree_ID + ParentID
-    SELECT c.AD_Tree_User1_ID,
-      n.Node_ID
-    INTO v_Tree_ID,
-      v_Parent_ID
-    FROM AD_ClientInfo c,
-      AD_TreeNode n
-    WHERE c.AD_Tree_User1_ID=n.AD_Tree_ID
-      AND n.Parent_ID IS NULL
-      AND c.AD_Client_ID=:new.AD_Client_ID;
-    --  DBMS_OUTPUT.PUT_LINE('Tree='||xTree_ID||'  Node='||:new.C_Project_ID||'  Parent='||xParent_ID);
+    SELECT c.AD_Tree_User1_ID
+    INTO v_Tree_ID
+    FROM AD_ClientInfo c
+    WHERE c.AD_Client_ID=:new.AD_Client_ID;
+
     --  Insert into TreeNode
     INSERT
     INTO AD_TreeNode
@@ -55,7 +49,7 @@
         get_uuid(), :new.AD_Client_ID, :new.AD_Org_ID, :new.IsActive,
         :new.Created, :new.CreatedBy, :new.Updated,
         :new.UpdatedBy, v_Tree_ID, :new.C_User1_ID,
-        v_Parent_ID,(
+        '0',(
         CASE :new.IsSummary
           WHEN 'Y'
           THEN 100
--- a/src-db/database/model/triggers/C_USER2_TRG.xml	Thu Oct 04 11:26:54 2012 +0200
+++ b/src-db/database/model/triggers/C_USER2_TRG.xml	Thu Oct 04 12:25:56 2012 +0200
@@ -19,7 +19,6 @@
 * Contributor(s):  ______________________________________.
 ************************************************************************/
     v_Tree_ID VARCHAR2(32);
-    v_Parent_ID VARCHAR2(32);
     v_count NUMBER;
     
 BEGIN
@@ -29,18 +28,13 @@
 
 
   IF (INSERTING) THEN    
+
     --  Create TreeNode --
-    --  get AD_Tree_ID + ParentID
-    SELECT c.AD_Tree_User2_ID,
-      n.Node_ID
-    INTO v_Tree_ID,
-      v_Parent_ID
-    FROM AD_ClientInfo c,
-      AD_TreeNode n
-    WHERE c.AD_Tree_User2_ID=n.AD_Tree_ID
-      AND n.Parent_ID IS NULL
-      AND c.AD_Client_ID=:new.AD_Client_ID;
-    --  DBMS_OUTPUT.PUT_LINE('Tree='||xTree_ID||'  Node='||:new.C_Project_ID||'  Parent='||xParent_ID);
+    SELECT c.AD_Tree_User2_ID
+    INTO v_Tree_ID
+    FROM AD_ClientInfo c
+    WHERE c.AD_Client_ID=:new.AD_Client_ID;
+
     --  Insert into TreeNode
     INSERT
     INTO AD_TreeNode
@@ -55,7 +49,7 @@
         get_uuid(), :new.AD_Client_ID, :new.AD_Org_ID, :new.IsActive,
         :new.Created, :new.CreatedBy, :new.Updated,
         :new.UpdatedBy, v_Tree_ID, :new.C_User2_ID,
-        v_Parent_ID,(
+        '0',(
         CASE :new.IsSummary
           WHEN 'Y'
           THEN 100
--- a/src-db/database/sourcedata/AD_TABLE.xml	Thu Oct 04 11:26:54 2012 +0200
+++ b/src-db/database/sourcedata/AD_TABLE.xml	Thu Oct 04 12:25:56 2012 +0200
@@ -8279,6 +8279,7 @@
 <!--16D0C2D87F744A508861CD957C4D3793-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--16D0C2D87F744A508861CD957C4D3793-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--16D0C2D87F744A508861CD957C4D3793-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1CE4B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--16D0C2D87F744A508861CD957C4D3793-->  <TREETYPE><![CDATA[U1]]></TREETYPE>
 <!--16D0C2D87F744A508861CD957C4D3793--></AD_TABLE>
 
 <!--19378B1CC7E14FFDA1819AA9E0AF681F--><AD_TABLE>
@@ -9344,6 +9345,7 @@
 <!--9072A1C049584DB69E4F42AE20B5CB66-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--9072A1C049584DB69E4F42AE20B5CB66-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--9072A1C049584DB69E4F42AE20B5CB66-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1CE4B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--9072A1C049584DB69E4F42AE20B5CB66-->  <TREETYPE><![CDATA[CC]]></TREETYPE>
 <!--9072A1C049584DB69E4F42AE20B5CB66--></AD_TABLE>
 
 <!--93F49C7968574D99B18085A6DD3C5CC6--><AD_TABLE>
@@ -10072,6 +10074,7 @@
 <!--EADDFEC95B5841D881BBA81A8D942CD2-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--EADDFEC95B5841D881BBA81A8D942CD2-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--EADDFEC95B5841D881BBA81A8D942CD2-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1CE4B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--EADDFEC95B5841D881BBA81A8D942CD2-->  <TREETYPE><![CDATA[U2]]></TREETYPE>
 <!--EADDFEC95B5841D881BBA81A8D942CD2--></AD_TABLE>
 
 <!--FF8080812DFFA1CF012DFFB889F40016--><AD_TABLE>
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateADClientInfo.class has changed
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateADClientInfoData.class has changed
--- a/src-util/modulescript/src/org/openbravo/modulescript/UpdateADClientInfo.java	Thu Oct 04 11:26:54 2012 +0200
+++ b/src-util/modulescript/src/org/openbravo/modulescript/UpdateADClientInfo.java	Thu Oct 04 12:25:56 2012 +0200
@@ -55,41 +55,12 @@
 
     private void createTreeAndUpdateClientInfo(final ConnectionProvider cp, final String treeTypeName, final String treeTypeValue, final String columnName)
 	throws ServletException {
-      if(treeTypeValue.equals("AS")) {
-        UpdateADClientInfoData[] clientsID = UpdateADClientInfoData.selectClientsMissingTree(cp, columnName);
-        for (UpdateADClientInfoData clientID: clientsID) {
-          final String treeId = UpdateADClientInfoData.getUUID(cp);
-          final String nameAndDesc = clientID.clientname + " " + treeTypeName;
-          UpdateADClientInfoData.createTree(cp, treeId, clientID.adClientId, nameAndDesc, treeTypeValue);
-          UpdateADClientInfoData.updateClientTree(cp, columnName, treeId, clientID.adClientId);
-        }
-      }
-      else if(treeTypeValue.equals("CC")) {
-        UpdateADClientInfoData[] clientsID = UpdateADClientInfoData.selectClientsMissingCostcenterTree(cp, columnName);
-        for (UpdateADClientInfoData clientID: clientsID) {
-          final String treeId = UpdateADClientInfoData.getUUID(cp);
-          final String nameAndDesc = clientID.clientname + " " + treeTypeName;
-          UpdateADClientInfoData.createTree(cp, treeId, clientID.adClientId, nameAndDesc, treeTypeValue);
-          UpdateADClientInfoData.updateCostcenterTreeAuto(cp, columnName, treeId, clientID.adClientId);
-        }
-      }
-      else if(treeTypeValue.equals("U1")) {
-        UpdateADClientInfoData[] clientsID = UpdateADClientInfoData.selectClientsMissingUser1Tree(cp, columnName);
-        for (UpdateADClientInfoData clientID: clientsID) {
-          final String treeId = UpdateADClientInfoData.getUUID(cp);
-          final String nameAndDesc = clientID.clientname + " " + treeTypeName;
-          UpdateADClientInfoData.createTree(cp, treeId, clientID.adClientId, nameAndDesc, treeTypeValue);
-          UpdateADClientInfoData.updateUser1TreeAuto(cp, columnName, treeId, clientID.adClientId);
-        }
-      }
-      else if(treeTypeValue.equals("U2")) {
-        UpdateADClientInfoData[] clientsID = UpdateADClientInfoData.selectClientsMissingUser2Tree(cp, columnName);
-        for (UpdateADClientInfoData clientID: clientsID) {
-          final String treeId = UpdateADClientInfoData.getUUID(cp);
-          final String nameAndDesc = clientID.clientname + " " + treeTypeName;
-          UpdateADClientInfoData.createTree(cp, treeId, clientID.adClientId, nameAndDesc, treeTypeValue);
-          UpdateADClientInfoData.updateUser2TreeAuto(cp, columnName, treeId, clientID.adClientId);
-        }
+      UpdateADClientInfoData[] clientsID = UpdateADClientInfoData.selectClientsMissingTree(cp, columnName);
+      for (UpdateADClientInfoData clientID: clientsID) {
+        final String treeId = UpdateADClientInfoData.getUUID(cp);
+        final String nameAndDesc = clientID.clientname + " " + treeTypeName;
+        UpdateADClientInfoData.createTree(cp, treeId, clientID.adClientId, nameAndDesc, treeTypeValue);
+        UpdateADClientInfoData.updateClientTree(cp, columnName, treeId, clientID.adClientId);
       }
     }
 
--- a/src-util/modulescript/src/org/openbravo/modulescript/UpdateADClientInfo_data.xsql	Thu Oct 04 11:26:54 2012 +0200
+++ b/src-util/modulescript/src/org/openbravo/modulescript/UpdateADClientInfo_data.xsql	Thu Oct 04 12:25:56 2012 +0200
@@ -147,73 +147,4 @@
     <Parameter name="treetype"/>
     <Parameter name="tablename" optional="false" type="replace" after="AND 1=1 AND a." text="M_PRODUCT_CATEGORY"/>
   </SqlMethod>
-  <SqlMethod name="selectClientsMissingCostcenterTree" type="preparedStatement" return="multiple">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql><![CDATA[
-      SELECT C.AD_CLIENT_ID, C.NAME as clientname
-      FROM AD_CLIENTINFO CI INNER JOIN AD_CLIENT C ON (C.AD_CLIENT_ID = CI.AD_CLIENT_ID)
-      WHERE CI.AD_CLIENT_ID <> '0'
-      AND 1=1 AND CI.AD_TREE_COSTCENTER_ID IS NULL
-      ]]>
-    </Sql>
-    <Parameter name="columnname" optional="false" type="replace" after="AND 1=1 AND CI." text="AD_TREE_COSTCENTER_ID"/>
-  </SqlMethod>
-  <SqlMethod name="updateCostcenterTreeAuto" type="preparedStatement" return="rowcount">
-    <SqlMethodComment>Updates client tree info for already created trees</SqlMethodComment>
-    <Sql><![CDATA[
-      UPDATE AD_CLIENTINFO 
-      SET AD_TREE_COSTCENTER_ID = ?
-      WHERE AD_CLIENT_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="columnname" optional="false" type="replace" after="SET " text="AD_TREE_COSTCENTER_ID"/>
-    <Parameter name="treeID"/>
-    <Parameter name="clientID"/>
-  </SqlMethod>
-  <SqlMethod name="selectClientsMissingUser1Tree" type="preparedStatement" return="multiple">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql><![CDATA[
-      SELECT C.AD_CLIENT_ID, C.NAME as clientname
-      FROM AD_CLIENTINFO CI INNER JOIN AD_CLIENT C ON (C.AD_CLIENT_ID = CI.AD_CLIENT_ID)
-      WHERE CI.AD_CLIENT_ID <> '0'
-      AND 1=1 AND CI.AD_TREE_USER1_ID IS NULL
-      ]]>
-    </Sql>
-    <Parameter name="columnname" optional="false" type="replace" after="AND 1=1 AND CI." text="AD_TREE_USER1_ID"/>
-  </SqlMethod>
-  <SqlMethod name="updateUser1TreeAuto" type="preparedStatement" return="rowcount">
-    <SqlMethodComment>Updates client tree info for already created trees</SqlMethodComment>
-    <Sql><![CDATA[
-      UPDATE AD_CLIENTINFO 
-      SET AD_TREE_USER1_ID = ?
-      WHERE AD_CLIENT_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="columnname" optional="false" type="replace" after="SET " text="AD_TREE_USER1_ID"/>
-    <Parameter name="treeID"/>
-    <Parameter name="clientID"/>
-  </SqlMethod>
-  <SqlMethod name="selectClientsMissingUser2Tree" type="preparedStatement" return="multiple">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql><![CDATA[
-      SELECT C.AD_CLIENT_ID, C.NAME as clientname
-      FROM AD_CLIENTINFO CI INNER JOIN AD_CLIENT C ON (C.AD_CLIENT_ID = CI.AD_CLIENT_ID)
-      WHERE CI.AD_CLIENT_ID <> '0'
-      AND 1=1 AND CI.AD_TREE_USER2_ID IS NULL
-      ]]>
-    </Sql>
-    <Parameter name="columnname" optional="false" type="replace" after="AND 1=1 AND CI." text="AD_TREE_USER2_ID"/>
-  </SqlMethod>
-  <SqlMethod name="updateUser2TreeAuto" type="preparedStatement" return="rowcount">
-    <SqlMethodComment>Updates client tree info for already created trees</SqlMethodComment>
-    <Sql><![CDATA[
-      UPDATE AD_CLIENTINFO 
-      SET AD_TREE_USER2_ID = ?
-      WHERE AD_CLIENT_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="columnname" optional="false" type="replace" after="SET " text="AD_TREE_USER2_ID"/>
-    <Parameter name="treeID"/>
-    <Parameter name="clientID"/>
-  </SqlMethod>
 </SqlClass>
--- a/src/org/openbravo/erpCommon/utility/WindowTreeChecks.java	Thu Oct 04 11:26:54 2012 +0200
+++ b/src/org/openbravo/erpCommon/utility/WindowTreeChecks.java	Thu Oct 04 12:25:56 2012 +0200
@@ -142,6 +142,12 @@
       result = "";
     } else if (TreeType.equals("AS")) { // Asset
       result = "";
+    } else if (TreeType.equals("CC")) { // Cost Center
+      result = "";
+    } else if (TreeType.equals("U1")) { // User Defined Dimension 1
+      result = "";
+    } else if (TreeType.equals("U2")) { // User Defined Dimension 2
+      result = "";
     } else
       result = WindowTreeChecksClient.checkChanges(conn, vars, tabId, topNodeId, nodeId, isChild,
           TreeType, key);