details: https://code.openbravo.com/erp/devel/pi/rev/16187b3a7c1e
changeset: 21353:16187b3a7c1e
user: Augusto Mauch <augusto.mauch <at> openbravo.com>
date: Wed Oct 23 11:04:37 2013 +0200
summary: Fixes issue 24951: Grid always fetches properties used in subtabs
display logic
In order for the display logics of a subtab to be evaluated properly, the
properties that belong to an ancestor tab must be loaded in that tab.
A new utility method called getTabSubtabs has been added to the KernelUtils
class.
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/DynamicExpressionParser.java
| 14 +++
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
| 11 ++
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
| 14 +++-
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
| 22 +++++-
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
| 35 +++++++++
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils_data.xsql
| 38 ++++++++++
6 files changed, 132 insertions(+), 2 deletions(-)
diffs (236 lines):
diff -r dafeaac0d99a -r 16187b3a7c1e
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
Tue Oct 22 23:41:46 2013 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/DynamicExpressionParser.java
Wed Oct 23 11:04:37 2013 +0200
@@ -65,6 +65,7 @@
}
private List<Field> fieldsInExpression = new ArrayList<Field>();
+ private List<String> otherTokensInExpression = new ArrayList<String>();
private List<Parameter> parametersInExpression = new ArrayList<Parameter>();
private List<AuxiliaryInput> auxInputsInExpression = new
ArrayList<AuxiliaryInput>();
private List<String> sessionAttributesInExpression = new ArrayList<String>();
@@ -209,6 +210,15 @@
}
/**
+ * Returns the list of tokens that are not fields of the tab It is only used
when parsing the
+ * display logic of the tabs
+ *
+ */
+ public List<String> getOtherTokensInExpression() {
+ return otherTokensInExpression;
+ }
+
+ /**
* Returns the list of Parameters used in the dynamic expression
*
*/
@@ -334,6 +344,10 @@
return new DisplayLogicElement(
"OB.Utilities.getValue(currentValues,'" + fieldName + "')",
uiDef instanceof YesNoUIDefinition);
+ } else if (tabLevelDisplayLogic) {
+ if (!otherTokensInExpression.contains(token)) {
+ otherTokensInExpression.add(token);
+ }
}
}
for (AuxiliaryInput auxIn : auxIns) {
diff -r dafeaac0d99a -r 16187b3a7c1e
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
Tue Oct 22 23:41:46 2013 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
Wed Oct 23 11:04:37 2013 +0200
@@ -472,6 +472,17 @@
return columnName;
}
+ public boolean isField(String columnName) {
+ final List<Field> adFields = new ArrayList<Field>(tab.getADFieldList());
+ for (Field field : adFields) {
+ if (field.getColumn() != null
+ && columnName.equalsIgnoreCase(field.getColumn().getDBColumnName()))
{
+ return true;
+ }
+ }
+ return false;
+ }
+
interface OBViewFieldDefinition {
public int getGridSort();
diff -r dafeaac0d99a -r 16187b3a7c1e
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
Tue Oct 22 23:41:46 2013 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
Wed Oct 23 11:04:37 2013 +0200
@@ -249,16 +249,21 @@
public List<String> getRequiredGridProperties() {
List<String> requiredGridProperties = new ArrayList<String>();
requiredGridProperties.add("id");
+ // Needed to check if the record is readonly (check addWritableAttribute
method of DefaultJsonDataService)
requiredGridProperties.add("client");
requiredGridProperties.add("organization");
+ // Audit fields are mandatory because the FIC does not returned them when
called in EDIT mode
requiredGridProperties.add("updatedBy");
requiredGridProperties.add("updated");
requiredGridProperties.add("creationDate");
requiredGridProperties.add("createdBy");
+
+ // Always include all the properties that are part of the identifier of
the entity
for (Property identifierProperty : this.entity.getIdentifierProperties()) {
requiredGridProperties.add(identifierProperty.getName());
}
+ // Properties related to buttons that have label values
List<ButtonField> buttonFields = getViewTab().getButtonFields();
for (ButtonField buttonField : buttonFields) {
if (!buttonField.getLabelValues().isEmpty()) {
@@ -266,13 +271,20 @@
}
}
+ // List of properties that are part of the display logic of the subtabs
+ List<String> tabDisplayLogicFields = getViewTab().getDisplayLogicFields();
+ for (String tabDisplayLogicField : tabDisplayLogicFields) {
+ requiredGridProperties.add(tabDisplayLogicField);
+ }
+
+ // List of properties that are part of the display logic of buttons
List<String> propertiesInButtonFieldDisplayLogic =
getViewTab().getFieldHandler()
.getPropertiesInButtonFieldDisplayLogic();
-
for (String propertyName : propertiesInButtonFieldDisplayLogic) {
requiredGridProperties.add(propertyName);
}
+ // Always include the propertyt that links to the parent tab
String linkToParentPropertyName = this.getLinkToParentPropertyName();
if (linkToParentPropertyName != null &&
!linkToParentPropertyName.isEmpty()) {
requiredGridProperties.add(linkToParentPropertyName);
diff -r dafeaac0d99a -r 16187b3a7c1e
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
Tue Oct 22 23:41:46 2013 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
Wed Oct 23 11:04:37 2013 +0200
@@ -563,7 +563,6 @@
final DynamicExpressionParser parser = new
DynamicExpressionParser(tab.getDisplayLogic(),
tab, inpColumnNames);
jsExpression = parser.getJSExpression();
-
// Retrieves the preference attributes used in the display logic of the
tab
setPreferenceAttributesFromParserResult(parser, this.getWindowId());
}
@@ -604,6 +603,27 @@
return preferenceAttributes;
}
+ // Return the list of fields of these tab that are part of the display logic
of its subtabs
+ public List<String> getDisplayLogicFields() {
+ boolean getOnlyFirstLevelSubTabs = false;
+ List<Tab> subTabs = KernelUtils.getInstance().getTabSubtabs(tab,
getOnlyFirstLevelSubTabs);
+ List<String> displayLogicFields = new ArrayList<String>();
+ for (Tab subTab : subTabs) {
+ if (subTab.getDisplayLogic() != null &&
!subTab.getDisplayLogic().isEmpty()) {
+ boolean inpColumnNames = true;
+ final DynamicExpressionParser parser = new DynamicExpressionParser(
+ subTab.getDisplayLogic(), tab, inpColumnNames);
+ List<String> tokens = parser.getOtherTokensInExpression();
+ for (String token : tokens) {
+ if (!displayLogicFields.contains(token) &&
fieldHandler.isField(token)) {
+ displayLogicFields.add(token);
+ }
+ }
+ }
+ }
+ return displayLogicFields;
+ }
+
public class ButtonField {
private static final String AD_DEF_ERROR = "AD definition error: process
parameter (%s) is using %s reference without %s";
private String id;
diff -r dafeaac0d99a -r 16187b3a7c1e
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
Tue Oct 22 23:41:46 2013 +0200
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
Wed Oct 23 11:04:37 2013 +0200
@@ -408,6 +408,41 @@
}
/**
+ * Returns the list of subtabs of a given tab
+ *
+ * @param tab
+ * The tab whose subtabs are to be retrieved
+ * @param onlyFirstLevel
+ * Boolean used to determine whether all the descendent tabs should
be returned or only the next level ones
+ * @return The list of subtabs of the given tab, an empty List if the tab
has none
+ */
+ public List<Tab> getTabSubtabs(Tab tab, boolean onlyFirstLevel) {
+ ConnectionProvider connection = new DalConnectionProvider();
+ Long seqno = tab.getSequenceNumber();
+ Long tabLevel = tab.getTabLevel();
+ String windowId = tab.getWindow().getId();
+ KernelUtilsData[] tabIds = null;
+ try {
+ if (onlyFirstLevel) {
+ tabIds = KernelUtilsData.getFirstLevelSubtabs(connection, windowId,
seqno.toString(),
+ tabLevel.toString());
+ } else {
+ tabIds = KernelUtilsData.getAllSubtabs(connection, windowId,
seqno.toString(),
+ tabLevel.toString());
+ }
+ } catch (ServletException e) {
+ log.error(e.getMessage(), e);
+ }
+ List<Tab> subTabList = new ArrayList<Tab>();
+ for (int i = 0; i < tabIds.length; i++) {
+ String tabId = ((KernelUtilsData) tabIds[i]).adTabId;
+ Tab subTab = OBDal.getInstance().get(Tab.class, tabId);
+ subTabList.add(subTab);
+ }
+ return subTabList;
+ }
+
+ /**
* Calls {@link #getProperty(Entity, Field)} using the entity of the tab of
the field.
*/
public static Property getProperty(org.openbravo.model.ad.ui.Field field) {
diff -r dafeaac0d99a -r 16187b3a7c1e
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils_data.xsql
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils_data.xsql
Tue Oct 22 23:41:46 2013 +0200
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils_data.xsql
Wed Oct 23 11:04:37 2013 +0200
@@ -40,4 +40,42 @@
<Parameter name="sequenceNumber"/>
</SqlMethod>
+ <SqlMethod name="getAllSubtabs" type="preparedStatement" return="multiple">
+ <Sql><![CDATA[
+ select t.ad_tab_id
+ from ad_tab t
+ where ad_window_id = ?
+ and seqno > TO_NUMBER(?)
+ and seqno < (select coalesce(min(seqno), 999999) from ad_tab
+ where tablevel <= TO_NUMBER(?)
+ and seqno > TO_NUMBER(?)
+ and ad_window_id = ?)
+ ]]></Sql>
+ <Parameter name="windowId"/>
+ <Parameter name="sequenceNumber"/>
+ <Parameter name="tabLevel"/>
+ <Parameter name="sequenceNumber"/>
+ <Parameter name="windowId"/>
+ </SqlMethod>
+
+ <SqlMethod name="getFirstLevelSubtabs" type="preparedStatement"
return="multiple">
+ <Sql><![CDATA[
+ select t.ad_tab_id
+ from ad_tab t
+ where ad_window_id = ?
+ and seqno > TO_NUMBER(?)
+ and tablevel = (TO_NUMBER(?)+1)
+ and seqno < (select coalesce(min(seqno), 999999) from ad_tab
+ where tablevel <= TO_NUMBER(?)
+ and seqno > TO_NUMBER(?)
+ and ad_window_id = ?)
+ ]]></Sql>
+ <Parameter name="windowId"/>
+ <Parameter name="sequenceNumber"/>
+ <Parameter name="tabLevel"/>
+ <Parameter name="tabLevel"/>
+ <Parameter name="sequenceNumber"/>
+ <Parameter name="windowId"/>
+ </SqlMethod>
+
</SqlClass>
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits