IDEMPIERE-5224 Locator Field type Caching Improvement (#1242)

* IDEMPIERE-5224 Locator Field type Caching Improvement

- Replace M_Locator.get with MLocator ResultSet constructor
- Implement lazy loading for MLocatorLookup

* IDEMPIERE-5224 Locator Field type Caching Improvement

- Implement lazy loading without new constructor (as suggested by
Carlos)
This commit is contained in:
hengsin 2022-03-15 16:30:11 +08:00 committed by GitHub
parent 316d488ac5
commit f15abe6522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 12 deletions

View File

@ -73,9 +73,6 @@ public final class MLocatorLookup extends Lookup implements Serializable
super (DisplayType.TableDir, WindowNo); super (DisplayType.TableDir, WindowNo);
m_ctx = ctx; m_ctx = ctx;
m_validationCode = validationCode; m_validationCode = validationCode;
//
m_loader = new Loader();
m_loader.start();
} // MLocator } // MLocator
/** Context */ /** Context */
@ -183,7 +180,7 @@ public final class MLocatorLookup extends Lookup implements Serializable
return new KeyNamePair (loc.getM_Locator_ID(), loc.toString()); return new KeyNamePair (loc.getM_Locator_ID(), loc.toString());
// Not found and waiting for loader // Not found and waiting for loader
if (m_loader.isAlive()) if (m_loader != null && m_loader.isAlive())
{ {
log.fine("Waiting for Loader"); log.fine("Waiting for Loader");
loadComplete(); loadComplete();
@ -372,7 +369,7 @@ public final class MLocatorLookup extends Lookup implements Serializable
int local_only_warehouse_id = getOnly_Warehouse_ID(); // [ 1674891 ] MLocatorLookup - weird error int local_only_warehouse_id = getOnly_Warehouse_ID(); // [ 1674891 ] MLocatorLookup - weird error
int local_only_product_id = getOnly_Product_ID(); int local_only_product_id = getOnly_Product_ID();
StringBuilder sql = new StringBuilder("SELECT M_Locator.M_Locator_ID FROM M_Locator ") StringBuilder sql = new StringBuilder("SELECT M_Locator.* FROM M_Locator ")
.append(" INNER JOIN M_Warehouse wh ON (wh.M_Warehouse_ID=M_Locator.M_Warehouse_ID) ") .append(" INNER JOIN M_Warehouse wh ON (wh.M_Warehouse_ID=M_Locator.M_Warehouse_ID) ")
.append(" WHERE M_Locator.IsActive='Y' ") .append(" WHERE M_Locator.IsActive='Y' ")
.append(" AND wh.IsActive='Y'"); .append(" AND wh.IsActive='Y'");
@ -431,8 +428,8 @@ public final class MLocatorLookup extends Lookup implements Serializable
// //
while (rs.next()) while (rs.next())
{ {
int M_Locator_ID = rs.getInt(1); MLocator loc = new MLocator(Env.getCtx(), rs, null);
MLocator loc = MLocator.get(m_ctx, M_Locator_ID); int M_Locator_ID = loc.getM_Locator_ID();
m_lookup.put(Integer.valueOf(M_Locator_ID), loc); m_lookup.put(Integer.valueOf(M_Locator_ID), loc);
} }
} }
@ -457,9 +454,13 @@ public final class MLocatorLookup extends Lookup implements Serializable
*/ */
public Collection<MLocator> getData () public Collection<MLocator> getData ()
{ {
if (m_loader.isAlive()) if (m_loader == null)
{ {
log.fine("Waiting for Loader"); refresh();
}
else if (m_loader.isAlive())
{
if (log.isLoggable(Level.FINE)) log.fine("Waiting for Loader");
try try
{ {
m_loader.join(); m_loader.join();
@ -503,7 +504,7 @@ public final class MLocatorLookup extends Lookup implements Serializable
*/ */
public int refresh() public int refresh()
{ {
log.fine("start"); if (log.isLoggable(Level.FINE)) log.fine("start");
m_loader = new Loader(); m_loader = new Loader();
m_loader.start(); m_loader.start();
try try

View File

@ -138,7 +138,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
sameWarehouseCb.setSelected(true); sameWarehouseCb.setSelected(true);
sameWarehouseCb.addActionListener(this); sameWarehouseCb.addActionListener(this);
// load Locator // load Locator
MLocatorLookup locator = new MLocatorLookup(Env.getCtx(), p_WindowNo); MLocatorLookup locator = new MLocatorLookup(Env.getCtx(), p_WindowNo, (String)null);
locatorField = new WLocatorEditor ("M_Locator_ID", true, false, true, locator, p_WindowNo); locatorField = new WLocatorEditor ("M_Locator_ID", true, false, true, locator, p_WindowNo);
initBPartner(false); initBPartner(false);

View File

@ -231,7 +231,7 @@ public class WTrxMaterial extends TrxMaterial
orgField = new WTableDirEditor("AD_Org_ID", false, false, true, orgLookup); orgField = new WTableDirEditor("AD_Org_ID", false, false, true, orgLookup);
// orgField.addVetoableChangeListener(this); // orgField.addVetoableChangeListener(this);
// Locator // Locator
MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo); MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo, null);
locatorField = new WLocatorEditor ("M_Locator_ID", false, false, true, locatorLookup, m_WindowNo); locatorField = new WLocatorEditor ("M_Locator_ID", false, false, true, locatorLookup, m_WindowNo);
// locatorField.addVetoableChangeListener(this); // locatorField.addVetoableChangeListener(this);
// Product // Product