details:   https://code.openbravo.com/erp/devel/pi/rev/46b4543cdeb7
changeset: 30994:46b4543cdeb7
user:      Armaignac <collazoandy4 <at> gmail.com>
date:      Thu Nov 24 09:38:42 2016 -0800
summary:   Fixes issue 25186: Java Heap error in Pending Goods Receipt with 
16000 lines

Opening the Pending Goods Receipt windows with more than 1600 lines a Java Heap 
error was shown. Now the total lines of the windows is limited according of the 
Preference FormsLimit value and a warning message is show indicating the 
windows state.

diffstat:

 src-db/database/sourcedata/AD_MESSAGE.xml                             |  12 +++
 src-db/database/sourcedata/AD_PREFERENCE.xml                          |  13 +++
 src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java      |  21 
+++++-
 src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending_data.xsql |  36 
++++++++++
 4 files changed, 80 insertions(+), 2 deletions(-)

diffs (141 lines):

diff -r 7027d3669e56 -r 46b4543cdeb7 src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Mon Dec 19 15:30:07 2016 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Thu Nov 24 09:38:42 2016 -0800
@@ -23214,6 +23214,18 @@
 <!--97D790CCE4B5499EA9EF9E604B2F56C6-->  
<ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--97D790CCE4B5499EA9EF9E604B2F56C6--></AD_MESSAGE>
 
+<!--97E1336471424158880846253F48B805--><AD_MESSAGE>
+<!--97E1336471424158880846253F48B805-->  
<AD_MESSAGE_ID><![CDATA[97E1336471424158880846253F48B805]]></AD_MESSAGE_ID>
+<!--97E1336471424158880846253F48B805-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--97E1336471424158880846253F48B805-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--97E1336471424158880846253F48B805-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--97E1336471424158880846253F48B805-->  
<VALUE><![CDATA[OldFormsLimit]]></VALUE>
+<!--97E1336471424158880846253F48B805-->  <MSGTEXT><![CDATA[This form data is 
limited to @limit@ because the filtering criteria you have specified return a 
number of rows that exceeds the maximum allowed]]></MSGTEXT>
+<!--97E1336471424158880846253F48B805-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--97E1336471424158880846253F48B805-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--97E1336471424158880846253F48B805-->  
<ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--97E1336471424158880846253F48B805--></AD_MESSAGE>
+
 <!--9823CDEEDD364E6EBFFE45B363EDA6C3--><AD_MESSAGE>
 <!--9823CDEEDD364E6EBFFE45B363EDA6C3-->  
<AD_MESSAGE_ID><![CDATA[9823CDEEDD364E6EBFFE45B363EDA6C3]]></AD_MESSAGE_ID>
 <!--9823CDEEDD364E6EBFFE45B363EDA6C3-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 7027d3669e56 -r 46b4543cdeb7 
src-db/database/sourcedata/AD_PREFERENCE.xml
--- a/src-db/database/sourcedata/AD_PREFERENCE.xml      Mon Dec 19 15:30:07 
2016 +0100
+++ b/src-db/database/sourcedata/AD_PREFERENCE.xml      Thu Nov 24 09:38:42 
2016 -0800
@@ -1,5 +1,18 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
+<!--68FC679E2B9245AA82B660715375AAFF--><AD_PREFERENCE>
+<!--68FC679E2B9245AA82B660715375AAFF-->  
<AD_PREFERENCE_ID><![CDATA[68FC679E2B9245AA82B660715375AAFF]]></AD_PREFERENCE_ID>
+<!--68FC679E2B9245AA82B660715375AAFF-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--68FC679E2B9245AA82B660715375AAFF-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--68FC679E2B9245AA82B660715375AAFF-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--68FC679E2B9245AA82B660715375AAFF-->  
<ATTRIBUTE><![CDATA[FormsLimit]]></ATTRIBUTE>
+<!--68FC679E2B9245AA82B660715375AAFF-->  <VALUE><![CDATA[1000]]></VALUE>
+<!--68FC679E2B9245AA82B660715375AAFF-->  
<ISPROPERTYLIST><![CDATA[N]]></ISPROPERTYLIST>
+<!--68FC679E2B9245AA82B660715375AAFF-->  
<VISIBLEAT_CLIENT_ID><![CDATA[0]]></VISIBLEAT_CLIENT_ID>
+<!--68FC679E2B9245AA82B660715375AAFF-->  
<VISIBLEAT_ORG_ID><![CDATA[0]]></VISIBLEAT_ORG_ID>
+<!--68FC679E2B9245AA82B660715375AAFF-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--68FC679E2B9245AA82B660715375AAFF--></AD_PREFERENCE>
+
 <!--9B4A5EB695FDA841E040A8C0E1077381--><AD_PREFERENCE>
 <!--9B4A5EB695FDA841E040A8C0E1077381-->  
<AD_PREFERENCE_ID><![CDATA[9B4A5EB695FDA841E040A8C0E1077381]]></AD_PREFERENCE_ID>
 <!--9B4A5EB695FDA841E040A8C0E1077381-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 7027d3669e56 -r 46b4543cdeb7 
src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java
--- a/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java  Mon Dec 
19 15:30:07 2016 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java  Thu Nov 
24 09:38:42 2016 -0800
@@ -135,7 +135,9 @@
     // String strMessage =
     // vars.getSessionValue("MaterialReceiptPending|message");
     // vars.removeSessionValue("MaterialReceiptPending|message");
-
+    String tot;
+    int intTotal = 0;
+    int limit = 0;
     MaterialReceiptPendingData[] data = null;
     String strTreeOrg = MaterialReceiptPendingData.treeOrg(this, 
vars.getClient());
     if (strC_BPartner_ID.equals("") && strAD_Org_ID.equals("")) {
@@ -143,13 +145,20 @@
           "org/openbravo/erpCommon/ad_forms/MaterialReceiptPending", 
discard).createXmlDocument();
       data = MaterialReceiptPendingData.set();
     } else {
+      tot = MaterialReceiptPendingData.countLines(this, vars.getLanguage(),
+          Utility.getContext(this, vars, "#User_Client", 
"MaterialReceiptPending"),
+          Tree.getMembers(this, strTreeOrg, strAD_Org_ID), strDateFrom,
+          DateTimeData.nDaysAfter(this, strDateTo, "1"), strC_BPartner_ID, 
strDocumentNo);
+      intTotal = new Integer(tot).intValue();
+      limit = Integer.parseInt(Utility.getPreference(vars, "FormsLimit", ""));
       xmlDocument = xmlEngine.readXmlTemplate(
           
"org/openbravo/erpCommon/ad_forms/MaterialReceiptPending").createXmlDocument();
+
       String strDateFormat = vars.getSessionValue("#AD_SqlDateFormat");
       data = MaterialReceiptPendingData.selectLines(this, strDateFormat, 
vars.getLanguage(),
           Utility.getContext(this, vars, "#User_Client", 
"MaterialReceiptPending"),
           Tree.getMembers(this, strTreeOrg, strAD_Org_ID), strDateFrom,
-          DateTimeData.nDaysAfter(this, strDateTo, "1"), strC_BPartner_ID, 
strDocumentNo);
+          DateTimeData.nDaysAfter(this, strDateTo, "1"), strC_BPartner_ID, 
strDocumentNo, 0, limit);
     }
 
     boolean preference = UOMUtil.isUomManagementEnabled();
@@ -201,6 +210,14 @@
     }
     {
       myMessage = vars.getMessage("MaterialReceiptPending");
+      if (intTotal > limit) {
+        myMessage = new OBError();
+        myMessage.setType("Warning");
+        myMessage.setTitle("");
+        String msgbody = Utility.messageBD(this, "OldFormsLimit", 
vars.getLanguage());
+        msgbody = msgbody.replace("@limit@", Integer.toString(limit));
+        myMessage.setMessage(msgbody);
+      }
       vars.removeMessage("MaterialReceiptPending");
       if (myMessage != null) {
         xmlDocument.setParameter("messageType", myMessage.getType());
diff -r 7027d3669e56 -r 46b4543cdeb7 
src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending_data.xsql     
Mon Dec 19 15:30:07 2016 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending_data.xsql     
Thu Nov 24 09:38:42 2016 -0800
@@ -97,6 +97,42 @@
     <Parameter name="parBPartner" optional="true" after="AND 
C_ORDER.ISSOTRX='N'"> AND C_BPARTNER.C_BPARTNER_ID = ?</Parameter>
     <Parameter name="parDocumentNo" optional="true" after="AND 
C_ORDER.ISSOTRX='N'"> AND C_ORDER.DOCUMENTNO LIKE ?</Parameter>
   </SqlMethod>
+    <SqlMethod name="countLines" type="preparedStatement" return="String">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+    <![CDATA[
+      SELECT count(*)
+      FROM(  
+      SELECT C_ORDERLINE.C_ORDERLINE_ID AS ID, C_ORDER.C_ORDER_ID AS 
C_ORDER_ID, C_ORDER.DOCUMENTNO AS DOCUMENTNO, C_ORDER.DATEORDERED AS 
DATEORDERED, 
+      C_BPARTNER.C_BPARTNER_ID AS C_BPARTNER_ID, C_BPARTNER.NAME AS 
PARTNER_NAME, 
+      AD_COLUMN_IDENTIFIER(TO_CHAR('M_Product'), 
TO_CHAR(C_ORDERLINE.M_PRODUCT_ID), TO_CHAR(?)) AS PRODUCT_NAME, 
M_ATTRIBUTESETINSTANCE.DESCRIPTION AS DESCRIPTION, C_ORDERLINE.QTYORDERED AS 
TOTAL_QTY,
+      C_ORDERLINE.QTYORDERED-SUM(COALESCE(M_MATCHPO.QTY,0)) AS QTYORDERED, 
'-1' AS ISACTIVE, C_ORDERLINE.LINE
+      FROM C_ORDERLINE left join M_MATCHPO on C_ORDERLINE.C_ORDERLINE_ID = 
M_MATCHPO.C_ORDERLINE_ID
+                                           and M_MATCHPO.M_INOUTLINE_ID IS NOT 
NULL
+                       left join M_ATTRIBUTESETINSTANCE on 
C_ORDERLINE.M_ATTRIBUTESETINSTANCE_ID = 
M_ATTRIBUTESETINSTANCE.M_ATTRIBUTESETINSTANCE_ID,
+      C_ORDER,   C_BPARTNER, C_DOCTYPE
+      WHERE C_ORDER.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
+      AND C_ORDER.C_ORDER_ID = C_ORDERLINE.C_ORDER_ID
+      AND C_ORDER.AD_CLIENT_ID IN ('1')
+      AND C_ORDER.AD_ORG_ID IN ('1')
+      AND C_ORDER.ISSOTRX='N'
+      AND C_ORDER.DOCSTATUS = 'CO'
+      AND C_ORDER.C_DOCTYPE_ID = C_DOCTYPE.C_DOCTYPE_ID
+      AND C_DOCTYPE.ISRETURN = 'N'
+      GROUP BY C_ORDERLINE.C_ORDERLINE_ID, C_ORDER.C_ORDER_ID, 
C_ORDER.DOCUMENTNO, C_ORDER.DATEORDERED, C_BPARTNER.C_BPARTNER_ID,
+      C_BPARTNER.NAME, C_ORDERLINE.M_PRODUCT_ID, 
M_ATTRIBUTESETINSTANCE.DESCRIPTION, C_ORDERLINE.QTYORDERED, C_ORDERLINE.LINE
+      ) A
+      WHERE (CASE WHEN Total_Qty < 0 THEN -1 ELSE 1 END) = (CASE WHEN 
Qtyordered < 0 THEN -1 ELSE 1 End) AND Qtyordered <> 0
+      ]]></Sql>
+    <Field name="rownum" value="count"/>
+    <Parameter name="adLanguage"/>
+    <Parameter name="adUserClient" type="replace" optional="true" after="AND 
C_ORDER.AD_CLIENT_ID IN (" text="'1'"/>
+    <Parameter name="adOrgId" optional="true" type="replace" after="AND 
C_ORDER.AD_ORG_ID IN (" text="'1'"/>
+    <Parameter name="parDateFrom" optional="true" after="AND 
C_ORDER.ISSOTRX='N'"><![CDATA[ AND C_ORDER.DATEORDERED >= 
TO_DATE(?)]]></Parameter>
+    <Parameter name="parDateTo" optional="true" after="AND 
C_ORDER.ISSOTRX='N'"><![CDATA[ AND C_ORDER.DATEORDERED < 
TO_DATE(?)]]></Parameter>
+    <Parameter name="parBPartner" optional="true" after="AND 
C_ORDER.ISSOTRX='N'"> AND C_BPARTNER.C_BPARTNER_ID = ?</Parameter>
+    <Parameter name="parDocumentNo" optional="true" after="AND 
C_ORDER.ISSOTRX='N'"> AND C_ORDER.DOCUMENTNO LIKE ?</Parameter>
+  </SqlMethod>
   <SqlMethod name="insert" connection="true" type="preparedStatement" 
return="rowCount">
     <SqlMethodComment></SqlMethodComment>
     <Sql>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to