details: /erp/devel/pi/rev/19edfd9af74e
changeset: 12351:19edfd9af74e
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Mon May 23 15:59:08 2011 +0200
summary: Two performance optimizations to improve FIC execution:
- Application Dictionary DAL objects have been cached, when the system is not
in development.
- ComboTableData structure information has also been cached, when the system is
not in development.
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/DynamicExpressionParser.java
| 8 +-
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
| 48 ++++--
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
| 15 +-
src/org/openbravo/erpCommon/utility/ComboTableData.java
| 74 ++++++++-
src/org/openbravo/reference/ui/UIList.java
| 5 +
src/org/openbravo/reference/ui/UIPAttribute.java
| 5 +
src/org/openbravo/reference/ui/UIReference.java
| 13 +
src/org/openbravo/reference/ui/UITable.java
| 5 +
src/org/openbravo/reference/ui/UITableDir.java
| 5 +
9 files changed, 142 insertions(+), 36 deletions(-)
diffs (truncated from 485 to 300 lines):
diff -r ec660802c30c -r 19edfd9af74e
modules/org.openbravo.client.application/src/org/openbravo/client/application/DynamicExpressionParser.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/DynamicExpressionParser.java
Mon May 23 14:48:52 2011 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/DynamicExpressionParser.java
Mon May 23 15:59:08 2011 +0200
@@ -24,6 +24,8 @@
import java.util.Map;
import java.util.StringTokenizer;
+import org.openbravo.base.weld.WeldUtils;
+import
org.openbravo.client.application.window.ApplicationDictionaryCachedStructures;
import org.openbravo.client.kernel.KernelUtils;
import org.openbravo.client.kernel.reference.UIDefinition;
import org.openbravo.client.kernel.reference.UIDefinitionController;
@@ -192,7 +194,9 @@
private DisplayLogicElement getDisplayLogicTextTranslate(String token) {
if (token == null || token.trim().equals(""))
return new DisplayLogicElement("", false);
- for (Field field : tab.getADFieldList()) {
+ ApplicationDictionaryCachedStructures cachedStructures = WeldUtils
+
.getInstanceFromStaticBeanManager(ApplicationDictionaryCachedStructures.class);
+ for (Field field : cachedStructures.getFieldsOfTab(tab.getId())) {
if (token.equalsIgnoreCase(field.getColumn().getDBColumnName())) {
fieldsInExpression.add(field);
final String fieldName =
KernelUtils.getInstance().getPropertyFromColumn(field.getColumn())
@@ -205,7 +209,7 @@
uiDef instanceof YesNoUIDefinition);
}
}
- for (AuxiliaryInput auxIn : tab.getADAuxiliaryInputList()) {
+ for (AuxiliaryInput auxIn :
cachedStructures.getAuxiliarInputList(tab.getId())) {
if (token.equalsIgnoreCase(auxIn.getName())) {
auxInputsInExpression.add(auxIn);
return new DisplayLogicElement(TOKEN_PREFIX + auxIn.getName(), false);
diff -r ec660802c30c -r 19edfd9af74e
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Mon May 23 14:48:52 2011 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Mon May 23 15:59:08 2011 +0200
@@ -29,6 +29,8 @@
import java.util.List;
import java.util.Map;
+import javax.inject.Inject;
+
import org.apache.log4j.Logger;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
@@ -97,6 +99,9 @@
private static final int MAX_CALLOUT_CALLS = 50;
+ @Inject
+ private ApplicationDictionaryCachedStructures cachedStructures;
+
@Override
protected JSONObject execute(Map<String, Object> parameters, String content)
{
OBContext.setAdminMode(true);
@@ -315,18 +320,17 @@
}
if (mode.equals("NEW") || mode.equals("EDIT") || mode.equals("CHANGE")) {
JSONObject jsonColumnValues = new JSONObject();
- for (Field field : tab.getADFieldList()) {
+ for (Field field : getADFieldList(tab.getId())) {
jsonColumnValues.put(field.getColumn().getDBColumnName(),
columnValues.get("inp"
+
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName())));
}
finalObject.put("columnValues", jsonColumnValues);
}
JSONObject jsonAuxiliaryInputValues = new JSONObject();
- for (AuxiliaryInput auxIn : tab.getADAuxiliaryInputList()) {
+ for (AuxiliaryInput auxIn : getAuxiliaryInputList(tab.getId())) {
jsonAuxiliaryInputValues.put(auxIn.getName(), columnValues.get("inp"
+ Sqlc.TransformaNombreColumna(auxIn.getName())));
}
-
finalObject.put("auxiliaryInputValues", jsonAuxiliaryInputValues);
if (mode.equals("NEW") || mode.equals("EDIT") ||
mode.equals("SETSESSION")) {
@@ -334,7 +338,7 @@
// and we add the columns which have a callout
final Map<String, String> sessionAttributesMap = new HashMap<String,
String>();
- for (Field field : tab.getADFieldList()) {
+ for (Field field : getADFieldList(tab.getId())) {
if (field.getColumn().getCallout() != null) {
final String columnName = "inp"
+
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName());
@@ -357,7 +361,6 @@
sessionAttributesMap.put(attrName.startsWith("#") ?
attrName.replace("#", "_")
: attrName, attrValue);
}
-
}
}
@@ -417,7 +420,7 @@
RequestContext.get().setRequestParameter("donotaddcurrentelement",
"true");
}
HashMap<String, Field> columnsOfFields = new HashMap<String, Field>();
- for (Field field : tab.getADFieldList()) {
+ for (Field field : getADFieldList(tab.getId())) {
columnsOfFields.put(field.getColumn().getDBColumnName(), field);
}
List<String> changedCols = new ArrayList<String>();
@@ -539,7 +542,7 @@
}
}
- for (Field field : tab.getADFieldList()) {
+ for (Field field : getADFieldList(tab.getId())) {
String columnId = field.getColumn().getId();
UIDefinition uiDef =
UIDefinitionController.getInstance().getUIDefinition(columnId);
// We need to fire callouts if the field is a combo
@@ -581,7 +584,7 @@
}
}
HashMap<String, Field> columnsOfFields = new HashMap<String, Field>();
- for (Field field : tab.getADFieldList()) {
+ for (Field field : getADFieldList(tab.getId())) {
for (String col : columnsToComputeAgain) {
if (col.equalsIgnoreCase(field.getColumn().getDBColumnName())) {
columnsOfFields.put(col, field);
@@ -617,7 +620,7 @@
// See issue 17239 for more information
return;
}
- for (AuxiliaryInput auxIn : tab.getADAuxiliaryInputList()) {
+ for (AuxiliaryInput auxIn : getAuxiliaryInputList(tab.getId())) {
Object value = computeAuxiliaryInput(auxIn, tab.getWindow().getId());
log.debug("Final Computed Value. Name: " + auxIn.getName() + " Value: "
+ value);
JSONObject jsonObj = new JSONObject();
@@ -663,7 +666,7 @@
private void setValuesInRequest(String mode, Tab tab, BaseOBObject row,
JSONObject jsContent) {
- List<Field> fields = tab.getADFieldList();
+ List<Field> fields = getADFieldList(tab.getId());
if (mode.equals("EDIT")) {
// In EDIT mode we initialize them from the database
for (Field field : fields) {
@@ -739,7 +742,7 @@
private void computeListOfColumnsSortedByValidationDependencies(String mode,
Tab tab,
List<String> sortedColumns, Map<String, List<String>>
columnsInValidation,
List<String> changeEventCols, String changedColumn) {
- List<Field> fields = tab.getADFieldList();
+ List<Field> fields = getADFieldList(tab.getId());
ArrayList<String> columns = new ArrayList<String>();
List<String> columnsWithValidation = new ArrayList<String>();
HashMap<String, String> validations = new HashMap<String, String>();
@@ -878,7 +881,7 @@
}
private void setSessionValues(BaseOBObject object, Tab tab) {
- for (Column col : tab.getTable().getADColumnList()) {
+ for (Column col : getADColumnList(tab.getTable().getId())) {
if (col.isStoredInSession() || col.isKeyColumn()) {
Property prop =
object.getEntity().getPropertyByColumnName(col.getDBColumnName());
Object value = object.get(prop.getName());
@@ -900,9 +903,7 @@
setValueOfColumnInRequest(object, col.getDBColumnName());
}
}
- OBCriteria<AuxiliaryInput> auxInC =
OBDal.getInstance().createCriteria(AuxiliaryInput.class);
- auxInC.add(Restrictions.eq(AuxiliaryInput.PROPERTY_TAB, tab));
- List<AuxiliaryInput> auxInputs = auxInC.list();
+ List<AuxiliaryInput> auxInputs = getAuxiliaryInputList(tab.getId());
for (AuxiliaryInput auxIn : auxInputs) {
Object value = computeAuxiliaryInput(auxIn, tab.getWindow().getId());
setSessionValue(tab.getWindow().getId() + "|" + auxIn.getName(), value);
@@ -949,7 +950,7 @@
// one
if (mode.equals("CHANGE")) {
if (changedColumn != null) {
- for (Column col : tab.getTable().getADColumnList()) {
+ for (Column col : getADColumnList(tab.getTable().getId())) {
if (("inp" +
Sqlc.TransformaNombreColumna(col.getDBColumnName())).equals(changedColumn)) {
if (col.getCallout() != null) {
// The column has a callout. We will add the callout to the
callout list
@@ -983,7 +984,7 @@
} catch (SQLException e1) {
throw new OBException("Error committing before runnings callouts", e1);
}
- List<Field> fields = tab.getADFieldList();
+ List<Field> fields = getADFieldList(tab.getId());
HashMap<String, Field> inpFields = buildInpField(fields);
String lastCalledCallout = "";
String lastFieldOfLastCalloutCalled = "";
@@ -1392,4 +1393,17 @@
}
return null;
}
+
+ private List<Field> getADFieldList(String tabId) {
+ return cachedStructures.getFieldsOfTab(tabId);
+ }
+
+ private List<Column> getADColumnList(String tableId) {
+ return cachedStructures.getColumnsOfTable(tableId);
+ }
+
+ private List<AuxiliaryInput> getAuxiliaryInputList(String tabId) {
+ return cachedStructures.getAuxiliarInputList(tabId);
+ }
+
}
diff -r ec660802c30c -r 19edfd9af74e
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
Mon May 23 14:48:52 2011 +0200
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
Mon May 23 15:59:08 2011 +0200
@@ -38,6 +38,8 @@
import org.openbravo.base.model.domaintype.DomainType;
import org.openbravo.base.model.domaintype.PrimitiveDomainType;
import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.base.weld.WeldUtils;
+import
org.openbravo.client.application.window.ApplicationDictionaryCachedStructures;
import org.openbravo.client.kernel.KernelUtils;
import org.openbravo.client.kernel.RequestContext;
import org.openbravo.dal.service.OBDal;
@@ -427,13 +429,16 @@
.getTab().getWindow().getId(),
Integer.parseInt(field.getTab().getTable()
.getDataAccessLevel()));
}
- ComboTableData comboTableData = new ComboTableData(vars, new
DalConnectionProvider(false),
- ref, field.getColumn().getDBColumnName(), objectReference,
validation, orgList,
- clientList, 0);
+ ApplicationDictionaryCachedStructures cachedStructures = WeldUtils
+
.getInstanceFromStaticBeanManager(ApplicationDictionaryCachedStructures.class);
+ ComboTableData comboTableData = cachedStructures.getComboTableData(vars,
ref, field
+ .getColumn().getDBColumnName(), objectReference, validation,
orgList, clientList);
FieldProvider tabData = generateTabData(field.getTab().getADFieldList(),
field, columnValue);
- comboTableData.fillParameters(tabData,
field.getTab().getWindow().getId(),
+ Map<String, String> parameters = comboTableData.fillSQLParametersIntoMap(
+ new DalConnectionProvider(false), vars, tabData,
field.getTab().getWindow().getId(),
(getValueFromSession && !comboreload) ? columnValue : "");
- FieldProvider[] fps = comboTableData.select(getValueFromSession &&
!comboreload);
+ FieldProvider[] fps = comboTableData.select(new
DalConnectionProvider(false), parameters,
+ getValueFromSession && !comboreload);
ArrayList<FieldProvider> values = new ArrayList<FieldProvider>();
values.addAll(Arrays.asList(fps));
ArrayList<JSONObject> comboEntries = new ArrayList<JSONObject>();
diff -r ec660802c30c -r 19edfd9af74e
src/org/openbravo/erpCommon/utility/ComboTableData.java
--- a/src/org/openbravo/erpCommon/utility/ComboTableData.java Mon May 23
14:48:52 2011 +0200
+++ b/src/org/openbravo/erpCommon/utility/ComboTableData.java Mon May 23
15:59:08 2011 +0200
@@ -22,6 +22,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Vector;
import javax.servlet.ServletException;
@@ -57,6 +58,7 @@
private Vector<QueryFieldStructure> from = new Vector<QueryFieldStructure>();
private Vector<QueryFieldStructure> where = new
Vector<QueryFieldStructure>();
private Vector<QueryFieldStructure> orderBy = new
Vector<QueryFieldStructure>();
+ private boolean canBeCached;
public int index = 0;
/**
@@ -819,6 +821,7 @@
.getField("referenceValue"));
}
uiref.setComboTableDataIdentifier(this, tableName, field);
+ canBeCached = uiref.canBeCached();
}
/**
@@ -956,13 +959,15 @@
* Array with the groups to discard.
* @return Integer with the next parameter's index.
*/
- private int setSQLParameters(PreparedStatement st, int iParameter, String[]
discard) {
+ private int setSQLParameters(PreparedStatement st, Map<String, String>
lparameters,
+ int iParameter, String[] discard) {
Vector<QueryParameterStructure> vAux = getSelectParameters();
if (vAux != null) {
for (int i = 0; i < vAux.size(); i++) {
QueryParameterStructure aux = vAux.elementAt(i);
if (!isInArray(discard, aux.getType())) {
- String strAux = getParameter(aux.getName());
+ String strAux = lparameters != null ? (aux.getName() == null ? null
: lparameters.get(aux
+ .getName().toUpperCase())) : getParameter(aux.getName());
if (log4j.isDebugEnabled())
log4j.debug("Parameter - " + iParameter + " - " + aux.getName() +
": " + strAux);
UtilSql.setValue(st, ++iParameter, 12, null, strAux);
@@ -974,7 +979,8 @@
for (int i = 0; i < vAux.size(); i++) {
QueryParameterStructure aux = vAux.elementAt(i);
if (!isInArray(discard, aux.getType())) {
- String strAux = getParameter(aux.getName());
+ String strAux = lparameters != null ? (aux.getName() == null ? null
: lparameters.get(aux
+ .getName().toUpperCase())) : getParameter(aux.getName());
if (log4j.isDebugEnabled())
log4j.debug("Parameter - " + iParameter + " - " + aux.getName() +
": " + strAux);
UtilSql.setValue(st, ++iParameter, 12, null, strAux);
@@ -986,7 +992,8 @@
for (int i = 0; i < vAux.size(); i++) {
QueryParameterStructure aux = vAux.elementAt(i);
if (!isInArray(discard, aux.getType())) {
- String strAux = getParameter(aux.getName());
+ String strAux = lparameters != null ? (aux.getName() == null ? null
: lparameters.get(aux
+ .getName().toUpperCase())) : getParameter(aux.getName());
if (log4j.isDebugEnabled())
log4j.debug("Parameter - " + iParameter + " - " + aux.getName() +
": " + strAux);
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits