details:   https://code.openbravo.com/erp/devel/pi/rev/8508f2e8710d
changeset: 31101:8508f2e8710d
user:      Rafael Queralta Pozo <rqueralta <at> nauta.cu>
date:      Mon Jan 09 22:24:16 2017 -0500
summary:   Fixed issue 34620: The ReportWarehouseControl report collapse the 
system

For a better performance, the data was limit with the value of a preference.
And a warning is shown to inform that data is being limited. Besides the query 
does
not be launched when opening the report

diffstat:

 src-db/database/sourcedata/AD_MESSAGE.xml                               |  12 
++++
 src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl.java      |  28 
++++++++-
 src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl_data.xsql |   7 
+-
 3 files changed, 42 insertions(+), 5 deletions(-)

diffs (113 lines):

diff -r ef8c02d2794d -r 8508f2e8710d src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Fri Jan 13 15:32:06 2017 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Mon Jan 09 22:24:16 2017 -0500
@@ -24779,6 +24779,18 @@
 <!--B9EE1302AB724B3FA76024DB096412EE-->  
<ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--B9EE1302AB724B3FA76024DB096412EE--></AD_MESSAGE>
 
+<!--BA67D141662B401C86DEE35102A9ABA7--><AD_MESSAGE>
+<!--BA67D141662B401C86DEE35102A9ABA7-->  
<AD_MESSAGE_ID><![CDATA[BA67D141662B401C86DEE35102A9ABA7]]></AD_MESSAGE_ID>
+<!--BA67D141662B401C86DEE35102A9ABA7-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--BA67D141662B401C86DEE35102A9ABA7-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--BA67D141662B401C86DEE35102A9ABA7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--BA67D141662B401C86DEE35102A9ABA7-->  
<VALUE><![CDATA[ReportsLimit]]></VALUE>
+<!--BA67D141662B401C86DEE35102A9ABA7-->  <MSGTEXT><![CDATA[The filtering 
criteria you have specified for this report return a number of rows that 
exceeds the maximum allowed. The limit of rows to display in a report is 
@limit@. Please, use more selective filtering criteria and execute the report 
again.]]></MSGTEXT>
+<!--BA67D141662B401C86DEE35102A9ABA7-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--BA67D141662B401C86DEE35102A9ABA7-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--BA67D141662B401C86DEE35102A9ABA7-->  
<ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--BA67D141662B401C86DEE35102A9ABA7--></AD_MESSAGE>
+
 <!--BAD33CDEBE2547A9A2FF7E87DA0B4C38--><AD_MESSAGE>
 <!--BAD33CDEBE2547A9A2FF7E87DA0B4C38-->  
<AD_MESSAGE_ID><![CDATA[BAD33CDEBE2547A9A2FF7E87DA0B4C38]]></AD_MESSAGE_ID>
 <!--BAD33CDEBE2547A9A2FF7E87DA0B4C38-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r ef8c02d2794d -r 8508f2e8710d 
src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl.java
--- a/src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl.java        
Fri Jan 13 15:32:06 2017 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl.java        
Mon Jan 09 22:24:16 2017 -0500
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2017 Openbravo SLU 
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -71,10 +71,24 @@
     PrintWriter out = response.getWriter();
     XmlDocument xmlDocument = null;
 
-    ReportWarehouseControlData[] data = ReportWarehouseControlData.select(this,
+    ReportWarehouseControlData[] data = null;
+    int limit = 0;
+    if (!vars.commandIn("DEFAULT")) {
+      limit = Integer.parseInt(Utility.getPreference(vars, "ReportsLimit", 
""));
+
+      String pgLimit = null, oraLimit = null;
+      if (this.myPool.getRDBMS().equalsIgnoreCase("ORACLE")) {
+        oraLimit = String.valueOf(limit + 1);
+      } else {
+        pgLimit = String.valueOf(limit + 1);
+      }
+
+      data = ReportWarehouseControlData.select(this,
         Utility.getContext(this, vars, "#User_Client", 
"ReportWarehouseControl"),
         Utility.getContext(this, vars, "#AccessibleOrgTree", 
"ReportWarehouseControl"),
-        strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), 
strReferential);
+          strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), 
strReferential, pgLimit,
+          oraLimit);
+    }
 
     if (data == null || data.length == 0 || vars.commandIn("DEFAULT")) {
       String discard[] = { "sectionDescription" };
@@ -119,6 +133,14 @@
     }
     {
       OBError myMessage = vars.getMessage("ReportWarehouseControl");
+      if (limit > 0 && data.length > limit) {
+        myMessage = new OBError();
+        myMessage.setType("Warning");
+        myMessage.setTitle("");
+        String msgbody = Utility.messageBD(this, "ReportsLimit", 
vars.getLanguage());
+        msgbody = msgbody.replace("@limit@", String.valueOf(limit + 1));
+        myMessage.setMessage(msgbody);
+      }
       vars.removeMessage("ReportWarehouseControl");
       if (myMessage != null) {
         xmlDocument.setParameter("messageType", myMessage.getType());
diff -r ef8c02d2794d -r 8508f2e8710d 
src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl_data.xsql
--- a/src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl_data.xsql   
Fri Jan 13 15:32:06 2017 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl_data.xsql   
Mon Jan 09 22:24:16 2017 -0500
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2012 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,7 @@
     <SqlMethodComment></SqlMethodComment>
     <Sql>
     <![CDATA[
+      SELECT B.* FROM ( 
       SELECT A.DESCRIPTION, M_PRODUCT.NAME AS PRODUCTNAME, 
       SUBSTR(M_ATTRIBUTESETINSTANCE.DESCRIPTION, 2, 
(LENGTH(M_ATTRIBUTESETINSTANCE.DESCRIPTION)-1)) AS REFERENTIAL, 
M_TRANSACTION.MOVEMENTDATE, SUM(M_TRANSACTION.MOVEMENTQTY) AS MOVEMENTQTY, 
A.UBICATION, A.ID, A.INP, C_UOM.NAME AS UOM, M_LOCATOR.VALUE AS LOCATOR
       FROM (SELECT (M_INOUT.DOCUMENTNO||' '||M_INOUT.MOVEMENTDATE||' 
'||COALESCE(TO_CHAR(C_PROJECT.VALUE), '')) AS DESCRIPTION, 
M_TRANSACTION.M_TRANSACTION_ID, M_INOUT.M_INOUT_ID AS ID, (CASE M_INOUT.ISSOTRX 
WHEN 'Y' THEN '257' ELSE '296' END) AS UBICATION, 'inpmInoutId' AS INP
@@ -61,13 +62,15 @@
       GROUP BY A.DESCRIPTION, M_PRODUCT.NAME, M_LOCATOR.M_LOCATOR_ID, 
M_LOCATOR.VALUE, M_ATTRIBUTESETINSTANCE.DESCRIPTION, 
M_TRANSACTION.MOVEMENTDATE, A.ID, A.UBICATION, A.INP, C_UOM.NAME
       HAVING SUM(M_TRANSACTION.MOVEMENTQTY) <> 0
       ORDER BY A.ID, M_PRODUCT.NAME
+      ) B
      ]]></Sql>
-    <Field name="rownum" value="count"/>
     <Parameter name="adUserClient" type="replace" optional="true" after="AND 
M_TRANSACTION.AD_CLIENT_ID IN (" text="'1'"/>
     <Parameter name="adOrgClient" type="replace" optional="true" after="AND 
M_TRANSACTION.AD_ORG_ID IN (" text="'1'"/>
     <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ 
AND M_TRANSACTION.MOVEMENTDATE >= to_date(?)]]></Parameter>
     <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND 
M_TRANSACTION.MOVEMENTDATE < to_date(?)]]></Parameter>
     <Parameter name="reference" optional="true" after="AND 1=1"><![CDATA[ AND 
UPPER(M_ATTRIBUTESETINSTANCE.DESCRIPTION) LIKE '%'||UPPER(?)||'%']]></Parameter>
+    <Parameter name="pgLimit" type="argument" optional="true" after=") 
B"><![CDATA[LIMIT ]]></Parameter>
+    <Parameter name="oraLimit1" type="argument" optional="true" after=") 
B"><![CDATA[WHERE ROWNUM <= ]]></Parameter>
   </SqlMethod>
 
   <SqlMethod name="set" type="constant" return="multiple">

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to