details: https://code.openbravo.com/erp/devel/pi/rev/e44119bb1d49
changeset: 23023:e44119bb1d49
user: Augusto Mauch <augusto.mauch <at> openbravo.com>
date: Wed May 14 13:26:15 2014 +0200
summary: Fixes issue 26544: Auxiliary inputs are not properly calculated in
grid view
The problem was that:
- The FIC needed all the columns used in the auxiliary inputs sent in the FIC
request
- If those columns where not shown in the grid they were not being sent in the
FIC request, so the FIC was not able to compute the auxiliary inputs properly
To fix this, all the columns used in the auxiliary inputs of a tab are included
as required grid properties.
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
| 59 ++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diffs (93 lines):
diff -r 0e4ee8136bfb -r e44119bb1d49
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
Wed May 14 10:09:44 2014 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
Wed May 14 13:26:15 2014 +0200
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
+import org.hibernate.criterion.Restrictions;
import org.openbravo.base.model.Entity;
import org.openbravo.base.model.ModelProvider;
import org.openbravo.base.model.Property;
@@ -37,9 +38,11 @@
import org.openbravo.client.kernel.Template;
import org.openbravo.dal.core.DalUtil;
import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
import org.openbravo.dal.service.OBQuery;
import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.ad.ui.AuxiliaryInput;
import org.openbravo.model.ad.ui.Tab;
import org.openbravo.model.common.order.Order;
import org.openbravo.model.common.order.OrderLine;
@@ -306,6 +309,12 @@
requiredGridProperties.add(storedInSessionProperty);
}
+ // Include the properties used in the auxiliary inputs of this tab
+ List<String> propertiesUsedInAuxiliaryInputs =
getPropertiesUsedInAuxiliaryInputs();
+ for (String propertyUsedInAuxiliaryInputs :
propertiesUsedInAuxiliaryInputs) {
+ requiredGridProperties.add(propertyUsedInAuxiliaryInputs);
+ }
+
// Include the Processing and Processed propertes, required by doc action
buttons (see
// https://issues.openbravo.com/view.php?id=25460)
if (getViewTab().getFieldHandler().hasProcessNowProperty()) {
@@ -318,6 +327,56 @@
return requiredGridProperties;
}
+ /**
+ * @return the list of properties that belong to this entity and that are
used in auxiliary inputs
+ * declared for this tab
+ */
+ private List<String> getPropertiesUsedInAuxiliaryInputs() {
+ OBCriteria<AuxiliaryInput> criteria =
OBDal.getInstance().createCriteria(AuxiliaryInput.class);
+ criteria.add(Restrictions.eq(AuxiliaryInput.PROPERTY_TAB, tab));
+ List<AuxiliaryInput> auxInputs = criteria.list();
+ boolean throwExceptionIfNotExists = false;
+ List<String> propertiesUsedInAuxiliaryInputs = new ArrayList<String>();
+ for (AuxiliaryInput auxInput : auxInputs) {
+ List<String> possibleColumns =
parseAuxInputCode(auxInput.getValidationCode());
+ for (String columnName : possibleColumns) {
+ Property property = entity.getPropertyByColumnName(columnName,
throwExceptionIfNotExists);
+ if (property != null) {
+ propertiesUsedInAuxiliaryInputs.add(property.getName());
+ }
+ }
+ }
+ return propertiesUsedInAuxiliaryInputs;
+ }
+
+ /**
+ * Returns the list of tokens that appear between '@' in a validation code
+ *
+ * @param validationCode
+ * the validation code where the '@' token '@' substrings will be
looked for in
+ * @return the list of tokens that appear between '@' in a validation code
+ */
+ private List<String> parseAuxInputCode(String validationCode) {
+ List<String> possibleProperties = new ArrayList<String>();
+ String token = validationCode;
+ int i = token.indexOf("@");
+ while (i != -1) {
+ token = token.substring(i + 1);
+ if (!token.startsWith("SQL")) {
+ i = token.indexOf("@");
+ if (i != -1) {
+ String strAux = token.substring(0, i);
+ token = token.substring(i + 1);
+ if (!possibleProperties.contains(strAux)) {
+ possibleProperties.add(strAux);
+ }
+ }
+ }
+ i = token.indexOf("@");
+ }
+ return possibleProperties;
+ }
+
private String getLinkToParentPropertyName() {
Tab parentTab = KernelUtils.getInstance().getParentTab(tab);
if (parentTab == null) {
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits