Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033601Openbravo ERPA. Platformpublic2016-08-02 15:182016-09-02 13:25
shuehner 
NaroaIriarte 
normalminorhave not tried
closedfixed 
5
 
3.0PR16Q4 
alostale
Core
No
0033601: Preferences.getPreferenceValue is doing useless extra db-reads (missing getProxy)
On first look this function is missing some getProxy usage to avoid db reads.

proxy is fine as only pk value is used.

  public static String getPreferenceValue(String property, boolean isListProperty,
      String strClient, String strOrg, String strUser, String strRole, String strWindow)
      throws PropertyException {

However checking that function it only calls next function having Client,Organization etc as objects as parameter just to extract the id again to use it.

So maybe swap around those functions do put real content inside the functions having id's and use the other one as the wrapper
      Client client = OBDal.getInstance().get(Client.class, strClient == null ? "" : strClient);
      Organization org = OBDal.getInstance().get(Organization.class, strOrg == null ? "" : strOrg);
      User user = OBDal.getInstance().get(User.class, strUser == null ? "" : strUser);
      Role role = OBDal.getInstance().get(Role.class, strRole == null ? "" : strRole);
      Window window = OBDal.getInstance().get(Window.class, strWindow == null ? "" : strWindow);

are all missing getProxy
NOTE: take care about that strange '== null' checks in there

just to then:
      String clientId = client == null ? null : (String) DalUtil.getId(client);
      String orgId = org == null ? null : (String) DalUtil.getId(org);
      String userId = user == null ? null : (String) DalUtil.getId(user);
      String roleId = role == null ? null : (String) DalUtil.getId(role);
      String windowId = window == null ? null : (String) DalUtil.getId(window);

Note: Those DalUtil.getId are already simplified to be use .getId() in tip of pi.

Performance
Issue History
2016-08-02 15:18shuehnerNew Issue
2016-08-02 15:18shuehnerAssigned To => platform
2016-08-02 15:18shuehnerModules => Core
2016-08-02 15:18shuehnerTriggers an Emergency Pack => No
2016-08-02 15:18shuehnerTag Attached: Performance
2016-08-29 09:19alostaleStatusnew => scheduled
2016-08-29 09:19alostaleAssigned Toplatform => NaroaIriarte
2016-08-31 11:12hgbotCheckin
2016-08-31 11:12hgbotNote Added: 0089589
2016-08-31 11:12hgbotStatusscheduled => resolved
2016-08-31 11:12hgbotResolutionopen => fixed
2016-08-31 11:12hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/938e3500425d8128135e96ea4bf0e97ac0aea493 [^]
2016-09-01 12:12hudsonbotCheckin
2016-09-01 12:12hudsonbotNote Added: 0089647
2016-09-02 13:25alostaleReview Assigned To => alostale
2016-09-02 13:25alostaleNote Added: 0089701
2016-09-02 13:25alostaleStatusresolved => closed
2016-09-02 13:25alostaleFixed in Version => 3.0PR16Q4

Notes
(0089589)
hgbot   
2016-08-31 11:12   
Repository: erp/devel/pi
Changeset: 938e3500425d8128135e96ea4bf0e97ac0aea493
Author: Naroa Iriarte <naroa.iriarte <at> openbravo.com>
Date: Mon Aug 29 15:25:51 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/938e3500425d8128135e96ea4bf0e97ac0aea493 [^]

Fixed issue 33601: Preferences.getPreferenceValue's performance improved

There are two methods called Preferences.getPrferenceValue. Before, one of them was getting the Client, org... objects and passing them as arguments to the other function. The other function was getting the Id from those objects to execute all the logic. This was not a good code, because one function was making queries to the database to get the objects just to pass them as arguments of the other function and in that funtion, those objects were only used to get the Id... so it has been modifyied. Now the function which before was called in the other is the one which calls the other function. Thanks to this change it is not needed to query the database to get the client, organization, user, role and window objects.

---
M src/org/openbravo/erpCommon/businessUtility/Preferences.java
---
(0089647)
hudsonbot   
2016-09-01 12:12   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/a321ec570edd [^]
Maturity status: Test
(0089701)
alostale   
2016-09-02 13:25   
code reviewed + tested