FR [2870483] - SaaS too slow opening windows
https://sourceforge.net/tracker/?func=detail&aid=2870483&group_id=176962&atid=879335
This commit is contained in:
parent
a0e6fcd1aa
commit
364a6158a0
|
@ -13,7 +13,7 @@
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
* @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ]
|
* @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ] *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
|
@ -79,6 +78,7 @@ public class GridFieldVO implements Serializable
|
||||||
GridFieldVO vo = new GridFieldVO (ctx, WindowNo, TabNo,
|
GridFieldVO vo = new GridFieldVO (ctx, WindowNo, TabNo,
|
||||||
AD_Window_ID, AD_Tab_ID, readOnly);
|
AD_Window_ID, AD_Tab_ID, readOnly);
|
||||||
String columnName = "ColumnName";
|
String columnName = "ColumnName";
|
||||||
|
int AD_Field_ID = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
vo.ColumnName = rs.getString("ColumnName");
|
vo.ColumnName = rs.getString("ColumnName");
|
||||||
|
@ -181,6 +181,7 @@ public class GridFieldVO implements Serializable
|
||||||
}
|
}
|
||||||
if (vo.Header == null)
|
if (vo.Header == null)
|
||||||
vo.Header = vo.ColumnName;
|
vo.Header = vo.ColumnName;
|
||||||
|
AD_Field_ID = rs.getInt("AD_Field_ID");
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
|
@ -190,73 +191,11 @@ public class GridFieldVO implements Serializable
|
||||||
// ASP
|
// ASP
|
||||||
if (vo.IsDisplayed) {
|
if (vo.IsDisplayed) {
|
||||||
MClient client = MClient.get(ctx);
|
MClient client = MClient.get(ctx);
|
||||||
if (client.isUseASP()) {
|
// ASP for fields has a different approach - it must be defined as a field but hidden
|
||||||
// ASP for fields has a different approach - it must be defined as a field but hidden
|
// in order to have the proper context variable filled with defaults
|
||||||
// in order to have the proper context variable filled with defaults
|
// Validate field and put IsDisplayed=N if must be hidden
|
||||||
// Validate field and put IsDisplayed=N if must be hidden
|
if (! client.isDisplayField(AD_Field_ID))
|
||||||
try {
|
vo.IsDisplayed = false;
|
||||||
// TODO : Optimize ASP field code - catch this query
|
|
||||||
int AD_Field_ID = rs.getInt("AD_Field_ID");
|
|
||||||
String sqlvalidate =
|
|
||||||
"SELECT AD_Field_ID "
|
|
||||||
+ " FROM AD_Field "
|
|
||||||
+ " WHERE AD_Field_ID = ? "
|
|
||||||
+ " AND ( AD_Field_ID IN ( "
|
|
||||||
// ASP subscribed fields for client
|
|
||||||
+ " SELECT f.AD_Field_ID "
|
|
||||||
+ " FROM ASP_Field f, ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl "
|
|
||||||
+ " WHERE w.ASP_Level_ID = l.ASP_Level_ID "
|
|
||||||
+ " AND cl.AD_Client_ID = " + client.getAD_Client_ID()
|
|
||||||
+ " AND cl.ASP_Level_ID = l.ASP_Level_ID "
|
|
||||||
+ " AND f.ASP_Tab_ID = t.ASP_Tab_ID "
|
|
||||||
+ " AND t.ASP_Window_ID = w.ASP_Window_ID "
|
|
||||||
+ " AND f.IsActive = 'Y' "
|
|
||||||
+ " AND t.IsActive = 'Y' "
|
|
||||||
+ " AND w.IsActive = 'Y' "
|
|
||||||
+ " AND l.IsActive = 'Y' "
|
|
||||||
+ " AND cl.IsActive = 'Y' "
|
|
||||||
+ " AND f.ASP_Status = 'S') "
|
|
||||||
+ " OR AD_Tab_ID IN ( "
|
|
||||||
// ASP subscribed fields for client
|
|
||||||
+ " SELECT t.AD_Tab_ID "
|
|
||||||
+ " FROM ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl "
|
|
||||||
+ " WHERE w.ASP_Level_ID = l.ASP_Level_ID "
|
|
||||||
+ " AND cl.AD_Client_ID = " + client.getAD_Client_ID()
|
|
||||||
+ " AND cl.ASP_Level_ID = l.ASP_Level_ID "
|
|
||||||
+ " AND t.ASP_Window_ID = w.ASP_Window_ID "
|
|
||||||
+ " AND t.IsActive = 'Y' "
|
|
||||||
+ " AND w.IsActive = 'Y' "
|
|
||||||
+ " AND l.IsActive = 'Y' "
|
|
||||||
+ " AND cl.IsActive = 'Y' "
|
|
||||||
+ " AND t.AllFields = 'Y' "
|
|
||||||
+ " AND t.ASP_Status = 'S') "
|
|
||||||
+ " OR AD_Field_ID IN ( "
|
|
||||||
// ASP show exceptions for client
|
|
||||||
+ " SELECT AD_Field_ID "
|
|
||||||
+ " FROM ASP_ClientException ce "
|
|
||||||
+ " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID()
|
|
||||||
+ " AND ce.IsActive = 'Y' "
|
|
||||||
+ " AND ce.AD_Field_ID IS NOT NULL "
|
|
||||||
+ " AND ce.ASP_Status = 'S') "
|
|
||||||
+ " ) "
|
|
||||||
+ " AND AD_Field_ID NOT IN ( "
|
|
||||||
// minus ASP hide exceptions for client
|
|
||||||
+ " SELECT AD_Field_ID "
|
|
||||||
+ " FROM ASP_ClientException ce "
|
|
||||||
+ " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID()
|
|
||||||
+ " AND ce.IsActive = 'Y' "
|
|
||||||
+ " AND ce.AD_Field_ID IS NOT NULL "
|
|
||||||
+ " AND ce.ASP_Status = 'H')";
|
|
||||||
int validField_ID = DB.getSQLValue(null, sqlvalidate, AD_Field_ID);
|
|
||||||
if (validField_ID != AD_Field_ID)
|
|
||||||
vo.IsDisplayed = false;
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
CLogger.get().log(Level.SEVERE, "ColumnName=" + columnName, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
vo.initFinish();
|
vo.initFinish();
|
||||||
|
|
|
@ -23,6 +23,8 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -56,7 +58,8 @@ public class MClient extends X_AD_Client
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -6345228636481802120L;
|
private static final long serialVersionUID = -6482473737885701403L;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get client
|
* Get client
|
||||||
|
@ -947,4 +950,90 @@ public class MClient extends X_AD_Client
|
||||||
return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE);
|
return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 2870483 - SaaS too slow opening windows */
|
||||||
|
/** Field Access */
|
||||||
|
private ArrayList<Integer> m_fieldAccess = null;
|
||||||
|
/**
|
||||||
|
* Define is a field is displayed based on ASP rules
|
||||||
|
* @param ad_field_id
|
||||||
|
* @return boolean indicating if it's displayed or not
|
||||||
|
*/
|
||||||
|
public boolean isDisplayField(int aDFieldID) {
|
||||||
|
if (! isUseASP())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (m_fieldAccess == null)
|
||||||
|
{
|
||||||
|
m_fieldAccess = new ArrayList<Integer>(11000);
|
||||||
|
String sqlvalidate =
|
||||||
|
"SELECT AD_Field_ID "
|
||||||
|
+ " FROM AD_Field "
|
||||||
|
+ " WHERE ( AD_Field_ID IN ( "
|
||||||
|
// ASP subscribed fields for client
|
||||||
|
+ " SELECT f.AD_Field_ID "
|
||||||
|
+ " FROM ASP_Field f, ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl "
|
||||||
|
+ " WHERE w.ASP_Level_ID = l.ASP_Level_ID "
|
||||||
|
+ " AND cl.AD_Client_ID = " + getAD_Client_ID()
|
||||||
|
+ " AND cl.ASP_Level_ID = l.ASP_Level_ID "
|
||||||
|
+ " AND f.ASP_Tab_ID = t.ASP_Tab_ID "
|
||||||
|
+ " AND t.ASP_Window_ID = w.ASP_Window_ID "
|
||||||
|
+ " AND f.IsActive = 'Y' "
|
||||||
|
+ " AND t.IsActive = 'Y' "
|
||||||
|
+ " AND w.IsActive = 'Y' "
|
||||||
|
+ " AND l.IsActive = 'Y' "
|
||||||
|
+ " AND cl.IsActive = 'Y' "
|
||||||
|
+ " AND f.ASP_Status = 'S') "
|
||||||
|
+ " OR AD_Tab_ID IN ( "
|
||||||
|
// ASP subscribed fields for client
|
||||||
|
+ " SELECT t.AD_Tab_ID "
|
||||||
|
+ " FROM ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl "
|
||||||
|
+ " WHERE w.ASP_Level_ID = l.ASP_Level_ID "
|
||||||
|
+ " AND cl.AD_Client_ID = " + getAD_Client_ID()
|
||||||
|
+ " AND cl.ASP_Level_ID = l.ASP_Level_ID "
|
||||||
|
+ " AND t.ASP_Window_ID = w.ASP_Window_ID "
|
||||||
|
+ " AND t.IsActive = 'Y' "
|
||||||
|
+ " AND w.IsActive = 'Y' "
|
||||||
|
+ " AND l.IsActive = 'Y' "
|
||||||
|
+ " AND cl.IsActive = 'Y' "
|
||||||
|
+ " AND t.AllFields = 'Y' "
|
||||||
|
+ " AND t.ASP_Status = 'S') "
|
||||||
|
+ " OR AD_Field_ID IN ( "
|
||||||
|
// ASP show exceptions for client
|
||||||
|
+ " SELECT AD_Field_ID "
|
||||||
|
+ " FROM ASP_ClientException ce "
|
||||||
|
+ " WHERE ce.AD_Client_ID = " + getAD_Client_ID()
|
||||||
|
+ " AND ce.IsActive = 'Y' "
|
||||||
|
+ " AND ce.AD_Field_ID IS NOT NULL "
|
||||||
|
+ " AND ce.ASP_Status = 'S') "
|
||||||
|
+ " ) "
|
||||||
|
+ " AND AD_Field_ID NOT IN ( "
|
||||||
|
// minus ASP hide exceptions for client
|
||||||
|
+ " SELECT AD_Field_ID "
|
||||||
|
+ " FROM ASP_ClientException ce "
|
||||||
|
+ " WHERE ce.AD_Client_ID = " + getAD_Client_ID()
|
||||||
|
+ " AND ce.IsActive = 'Y' "
|
||||||
|
+ " AND ce.AD_Field_ID IS NOT NULL "
|
||||||
|
+ " AND ce.ASP_Status = 'H')"
|
||||||
|
+ " ORDER BY AD_Field_ID";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sqlvalidate, get_TrxName());
|
||||||
|
rs = pstmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
|
m_fieldAccess.add(rs.getInt(1));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sqlvalidate, e);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (Collections.binarySearch(m_fieldAccess, aDFieldID) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
} // MClient
|
} // MClient
|
||||||
|
|
Loading…
Reference in New Issue