details: https://code.openbravo.com/erp/devel/pi/rev/bde8cc5b9fd9
changeset: 22894:bde8cc5b9fd9
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Tue Apr 22 09:22:32 2014 +0200
summary: fixed bug 26317: cannot filter by properties not in main entity
Adding complete path to filtered property, so it works even it is not
a direct property of the main entity but it is reached through a path
diffstat:
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
| 9 +++++-
modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java
| 12 ++++++++-
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
| 8 ++++--
3 files changed, 22 insertions(+), 7 deletions(-)
diffs (91 lines):
diff -r cb6171e6cd94 -r bde8cc5b9fd9
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
---
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
Mon Apr 21 15:19:02 2014 +0200
+++
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
Tue Apr 22 09:22:32 2014 +0200
@@ -152,6 +152,7 @@
private List<String> additionalProperties = new ArrayList<String>();
private Entity subEntity;
private Property distinctProperty;
+ private String distinctPropertyPath;
private DataEntityQueryService subDataEntityQueryService;
private int aliasOffset = 0;
@@ -228,8 +229,9 @@
}
whereClause += StringUtils.isEmpty(whereClause.trim()) ? "where" : "and";
whereClause += " exists (select 1 from " + subEntity.getName() + " "
- + subEntityQueryBuilder.getJoinClause() + subentityWhere + "e." +
distinctPropName
- + " = " + mainAlias + subEntityClientOrg + ") ";
+ + subEntityQueryBuilder.getJoinClause() + subentityWhere + "e."
+ + distinctPropertyPath.replace(DalUtil.FIELDSEPARATOR, DalUtil.DOT)
+ " = " + mainAlias
+ + subEntityClientOrg + ") ";
typedParameters.addAll(subEntityQueryBuilder.typedParameters);
}
@@ -1692,6 +1694,9 @@
public void setDistinctProperty(Property distinctProperty) {
this.distinctProperty = distinctProperty;
+ }
+ void setDistinctPropertyPath(String distinctPropertyPath) {
+ this.distinctPropertyPath = distinctPropertyPath;
}
}
diff -r cb6171e6cd94 -r bde8cc5b9fd9
modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java
---
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java
Mon Apr 21 15:19:02 2014 +0200
+++
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java
Tue Apr 22 09:22:32 2014 +0200
@@ -365,11 +365,19 @@
* only organizations with that criteria will be shown
* </ul>
*/
- public void setSubEntity(String subEntityName, DataEntityQueryService
dataEntityQueryService,
- Property distinctProperty) {
+ void setSubEntity(String subEntityName, DataEntityQueryService
dataEntityQueryService,
+ Property distinctProperty, String distinctPropertyPath) {
queryBuilder.setSubEntityName(subEntityName);
queryBuilder.setSubDataEntityQueryService(dataEntityQueryService);
queryBuilder.setDistinctProperty(distinctProperty);
+ queryBuilder.setDistinctPropertyPath(distinctPropertyPath);
+ }
+
+ @Deprecated
+ public void setSubEntity(String subEntityName, DataEntityQueryService
dataEntityQueryService,
+ Property distinctProperty) {
+ setSubEntity(subEntityName, dataEntityQueryService, distinctProperty,
+ distinctProperty.getName());
}
}
diff -r cb6171e6cd94 -r bde8cc5b9fd9
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
---
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
Mon Apr 21 15:19:02 2014 +0200
+++
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
Tue Apr 22 09:22:32 2014 +0200
@@ -285,8 +285,9 @@
// this is the main entity of a 'contains' (used in FK drop down lists),
it will create also
// info for subentity
+ final String distinctPropertyPath =
parameters.get(JsonConstants.DISTINCT_PARAMETER);
final Property distinctProperty =
DalUtil.getPropertyFromPath(ModelProvider.getInstance()
- .getEntity(entityName),
parameters.get(JsonConstants.DISTINCT_PARAMETER));
+ .getEntity(entityName), distinctPropertyPath);
final Entity distinctEntity = distinctProperty.getTargetEntity();
// criteria needs to be split in two parts:
@@ -301,7 +302,7 @@
try {
JSONObject jsonCriterion = new JSONObject(criterion);
if (jsonCriterion.getString("fieldName").equals(
- distinctProperty.getName() + "$" + JsonConstants.IDENTIFIER)) {
+ distinctPropertyPath + "$" + JsonConstants.IDENTIFIER)) {
jsonCriterion.put("fieldName", JsonConstants.IDENTIFIER);
baseCriteria = jsonCriterion.toString();
} else {
@@ -346,7 +347,8 @@
// create now subentity
queryService.setSubEntity(entityName,
- createSetQueryService(paramSubCriteria, forCountOperation, true),
distinctProperty);
+ createSetQueryService(paramSubCriteria, forCountOperation, true),
distinctProperty,
+ distinctPropertyPath);
} else {
queryService.setEntityName(entityName);
if (parameters.containsKey(JsonConstants.USE_ALIAS)) {
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits