IDEMPIERE-5268 Cache PA_DocumentStatus (#1291)

* IDEMPIERE-5268  Cache PA_DocumentStatus

* IDEMPIERE-5268 Cache PA_DocumentStatus
This commit is contained in:
igorpojzl 2022-04-15 09:51:40 +02:00 committed by GitHub
parent d3b6c51655
commit c13039cf82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 2 deletions

View File

@ -36,8 +36,10 @@ import java.util.Properties;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.idempiere.cache.ImmutableIntPOCache;
import org.idempiere.cache.ImmutablePOSupport;
public class MDocumentStatus extends X_PA_DocumentStatus {
public class MDocumentStatus extends X_PA_DocumentStatus implements ImmutablePOSupport {
/**
*
*/
@ -51,6 +53,61 @@ public class MDocumentStatus extends X_PA_DocumentStatus {
super(ctx, rs, trxName);
}
/**
*
* @param copy
*/
public MDocumentStatus(MDocumentStatus copy)
{
this(Env.getCtx(), copy);
}
/**
*
* @param ctx
* @param copy
*/
public MDocumentStatus(Properties ctx, MDocumentStatus copy)
{
this(ctx, copy, (String) null);
}
/**
*
* @param ctx
* @param copy
* @param trxName
*/
public MDocumentStatus(Properties ctx, MDocumentStatus copy, String trxName)
{
this(ctx, 0, trxName);
copyPO(copy);
}
/** Categopry Cache */
private static ImmutableIntPOCache<Integer,MDocumentStatus> s_cache = new ImmutableIntPOCache<Integer,MDocumentStatus>(Table_Name, 20);
/**
* Get from Cache (immutable)
* @param ctx context
* @param M_Product_Category_ID id
* @return category
*/
public static MDocumentStatus get (Properties ctx, int PA_DocumentStatus_ID)
{
Integer ii = Integer.valueOf(PA_DocumentStatus_ID);
MDocumentStatus retValue = s_cache.get(ctx, ii, e -> new MDocumentStatus(ctx, e));
if (retValue != null)
return retValue;
retValue = new MDocumentStatus (ctx, PA_DocumentStatus_ID, (String)null);
if (retValue.get_ID () == PA_DocumentStatus_ID)
{
s_cache.put (PA_DocumentStatus_ID, retValue, e -> new MDocumentStatus(Env.getCtx(), e));
return retValue;
}
return null;
} // get
/**
* Get Document Status Indicators
* @param ctx context
@ -171,4 +228,12 @@ public class MDocumentStatus extends X_PA_DocumentStatus {
return false;
}
@Override
public PO markImmutable() {
if (is_Immutable())
return this;
makeImmutable();
return this;
}
}

View File

@ -162,7 +162,10 @@ public class WDocumentStatusIndicator extends Panel implements EventListener<Eve
}
public void refresh() {
m_documentStatus.load(m_documentStatus.get_TrxName());
MDocumentStatus refresh_documentStatus = MDocumentStatus.get(Env.getCtx(), m_documentStatus.getPA_DocumentStatus_ID());
if(refresh_documentStatus != null) {
m_documentStatus = refresh_documentStatus;
}
statusCount = MDocumentStatus.evaluate(m_documentStatus);
}