IDEMPIERE-4959 Performance improvement for the opening of form window (#875)
* IDEMPIERE-4959 Performance improvement for the opening of form window * IDEMPIERE-4959 Performance improvement for the opening of form window minor cache name change.
This commit is contained in:
parent
eedc3c6e35
commit
ab12354cb4
|
@ -20,6 +20,8 @@ import java.sql.ResultSet;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
import org.idempiere.cache.ImmutableIntPOCache;
|
||||||
|
import org.idempiere.cache.ImmutablePOSupport;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,14 +30,47 @@ import org.compiere.util.Env;
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: MForm.java,v 1.3 2006/07/30 00:51:02 jjanke Exp $
|
* @version $Id: MForm.java,v 1.3 2006/07/30 00:51:02 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class MForm extends X_AD_Form
|
public class MForm extends X_AD_Form implements ImmutablePOSupport
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -2013533837940046638L;
|
private static final long serialVersionUID = -3617225890452735325L;
|
||||||
|
|
||||||
|
/** Cache */
|
||||||
|
private static ImmutableIntPOCache<Integer,MForm> s_cache = new ImmutableIntPOCache<Integer,MForm>(Table_Name, 20);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get MForm from Cache (immutable)
|
||||||
|
* @param AD_Form_ID id
|
||||||
|
* @return MForm
|
||||||
|
*/
|
||||||
|
public static MForm get (int AD_Form_ID)
|
||||||
|
{
|
||||||
|
return get(Env.getCtx(), AD_Form_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get MFrom from Cache (immutable)
|
||||||
|
* @param ctx context
|
||||||
|
* @param AD_Form_ID id
|
||||||
|
* @return MForm
|
||||||
|
*/
|
||||||
|
public static MForm get (Properties ctx, int AD_Form_ID)
|
||||||
|
{
|
||||||
|
Integer key = Integer.valueOf(AD_Form_ID);
|
||||||
|
MForm retValue = s_cache.get (ctx, key, e -> new MForm(ctx, e));
|
||||||
|
if (retValue != null)
|
||||||
|
return retValue;
|
||||||
|
|
||||||
|
retValue = new MForm (ctx, AD_Form_ID, (String)null);
|
||||||
|
if (retValue.get_ID () == AD_Form_ID) {
|
||||||
|
s_cache.put (key, retValue, e -> new MForm(Env.getCtx(), e));
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} // get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -58,6 +93,27 @@ public class MForm extends X_AD_Form
|
||||||
super(ctx, rs, trxName);
|
super(ctx, rs, trxName);
|
||||||
} // MForm
|
} // MForm
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ctx
|
||||||
|
* @param copy
|
||||||
|
*/
|
||||||
|
public MForm(Properties ctx, MForm copy) {
|
||||||
|
this(ctx, copy, (String) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ctx
|
||||||
|
* @param copy
|
||||||
|
* @param trxName
|
||||||
|
*/
|
||||||
|
public MForm(Properties ctx, MForm copy, String trxName)
|
||||||
|
{
|
||||||
|
this(ctx, 0, trxName);
|
||||||
|
copyPO(copy);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After Save
|
* After Save
|
||||||
* @param newRecord new
|
* @param newRecord new
|
||||||
|
@ -91,4 +147,12 @@ public class MForm extends X_AD_Form
|
||||||
return success;
|
return success;
|
||||||
} // afterSave
|
} // afterSave
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MForm markImmutable() {
|
||||||
|
if (is_Immutable())
|
||||||
|
return this;
|
||||||
|
|
||||||
|
makeImmutable();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
} // MForm
|
} // MForm
|
||||||
|
|
|
@ -29,11 +29,12 @@ import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.exceptions.DBException;
|
import org.adempiere.exceptions.DBException;
|
||||||
import org.adempiere.process.UUIDGenerator;
|
import org.adempiere.process.UUIDGenerator;
|
||||||
import org.compiere.Adempiere;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Language;
|
import org.compiere.util.Language;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
import org.idempiere.cache.ImmutablePOCache;
|
||||||
|
import org.idempiere.cache.ImmutablePOSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language Model
|
* Language Model
|
||||||
|
@ -44,12 +45,17 @@ import org.compiere.util.Msg;
|
||||||
* @author Teo Sarca, www.arhipac.ro
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
* <li>BF [ 2444851 ] MLanguage should throw an exception if there is an error
|
* <li>BF [ 2444851 ] MLanguage should throw an exception if there is an error
|
||||||
*/
|
*/
|
||||||
public class MLanguage extends X_AD_Language
|
public class MLanguage extends X_AD_Language implements ImmutablePOSupport
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 6415602943484245447L;
|
private static final long serialVersionUID = 6553711529361500744L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MLanguage cache key by AD_Language value
|
||||||
|
*/
|
||||||
|
private static final ImmutablePOCache<String, MLanguage> s_cache = new ImmutablePOCache<String, MLanguage>(Table_Name, Table_Name+"|AD_Language", 100, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Language Model from Language
|
* Get Language Model from Language
|
||||||
|
@ -70,9 +76,16 @@ public class MLanguage extends X_AD_Language
|
||||||
*/
|
*/
|
||||||
public static MLanguage get (Properties ctx, String AD_Language)
|
public static MLanguage get (Properties ctx, String AD_Language)
|
||||||
{
|
{
|
||||||
return new Query(ctx, Table_Name, COLUMNNAME_AD_Language+"=?", null)
|
MLanguage retValue = s_cache.get(ctx, AD_Language, e -> new MLanguage(ctx, e));
|
||||||
|
if (retValue != null)
|
||||||
|
return retValue;
|
||||||
|
|
||||||
|
retValue = new Query(ctx, Table_Name, COLUMNNAME_AD_Language+"=?", null)
|
||||||
.setParameters(AD_Language)
|
.setParameters(AD_Language)
|
||||||
.firstOnly();
|
.firstOnly();
|
||||||
|
if (retValue != null)
|
||||||
|
s_cache.put(AD_Language, retValue, e -> new MLanguage(ctx, e));
|
||||||
|
return retValue;
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,6 +160,27 @@ public class MLanguage extends X_AD_Language
|
||||||
setLanguageISO(LanguageISO); // en
|
setLanguageISO(LanguageISO); // en
|
||||||
} // MLanguage
|
} // MLanguage
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ctx
|
||||||
|
* @param copy
|
||||||
|
*/
|
||||||
|
public MLanguage(Properties ctx, MLanguage copy) {
|
||||||
|
this(ctx, copy, (String)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ctx
|
||||||
|
* @param copy
|
||||||
|
* @param trxName
|
||||||
|
*/
|
||||||
|
public MLanguage(Properties ctx, MLanguage copy, String trxName) {
|
||||||
|
this(ctx, 0, trxName);
|
||||||
|
copyPO(copy);
|
||||||
|
this.m_dateFormat = copy.m_dateFormat != null ? new SimpleDateFormat(copy.m_dateFormat.toPattern()) : null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Locale */
|
/** Locale */
|
||||||
private Locale m_locale = null;
|
private Locale m_locale = null;
|
||||||
/** Date Format */
|
/** Date Format */
|
||||||
|
@ -474,18 +508,13 @@ public class MLanguage extends X_AD_Language
|
||||||
return no;
|
return no;
|
||||||
} // addTable
|
} // addTable
|
||||||
|
|
||||||
|
@Override
|
||||||
/**************************************************************************
|
public MLanguage markImmutable() {
|
||||||
* Setup
|
if (is_Immutable())
|
||||||
* @param args args
|
return this;
|
||||||
*/
|
|
||||||
public static void main(String[] args)
|
makeImmutable();
|
||||||
{
|
return this;
|
||||||
System.out.println("Language");
|
}
|
||||||
Adempiere.startup(true);
|
|
||||||
|
|
||||||
System.out.println(MLanguage.get(Env.getCtx(), "de_DE"));
|
|
||||||
System.out.println(MLanguage.get(Env.getCtx(), "en_US"));
|
|
||||||
} // main
|
|
||||||
|
|
||||||
} // MLanguage
|
} // MLanguage
|
||||||
|
|
|
@ -186,7 +186,7 @@ public abstract class ADForm extends Window implements EventListener<Event>, IHe
|
||||||
public static ADForm openForm (int adFormID, GridTab gridTab, ProcessInfo pi, String predefinedContextVariables, boolean isSOTrx)
|
public static ADForm openForm (int adFormID, GridTab gridTab, ProcessInfo pi, String predefinedContextVariables, boolean isSOTrx)
|
||||||
{
|
{
|
||||||
ADForm form;
|
ADForm form;
|
||||||
MForm mform = new MForm(Env.getCtx(), adFormID, null);
|
MForm mform = MForm.get(adFormID);
|
||||||
String formName = mform.getClassname();
|
String formName = mform.getClassname();
|
||||||
String name = mform.get_Translation(MForm.COLUMNNAME_Name);
|
String name = mform.get_Translation(MForm.COLUMNNAME_Name);
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,7 @@ public class HelpController
|
||||||
}
|
}
|
||||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Form))
|
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Form))
|
||||||
{
|
{
|
||||||
MForm form = new MForm(Env.getCtx(), recordId, null);
|
MForm form = MForm.get(recordId);
|
||||||
if (!Env.isBaseLanguage(Env.getCtx(), "AD_Form")) {
|
if (!Env.isBaseLanguage(Env.getCtx(), "AD_Form")) {
|
||||||
|
|
||||||
nameMsg = form.get_Translation("Name",false);
|
nameMsg = form.get_Translation("Name",false);
|
||||||
|
|
Loading…
Reference in New Issue