details: https://code.openbravo.com/erp/devel/pi/rev/f3fe4a52f51e changeset: 20466:f3fe4a52f51e user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Fri May 24 08:52:11 2013 +0200 summary: Related to issue 23870: Fixes spacing of Java file
details: https://code.openbravo.com/erp/devel/pi/rev/5ac834636f94 changeset: 20467:5ac834636f94 user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Fri May 24 08:56:53 2013 +0200 summary: Fixes issue 23870: Filters work properly with property columns In the buildFieldClause method of the AdvancedQueryBuilder class there was a bug that prevented filtering from working in the case where the size of the properties array was longer than 2. This happened because at one point the useFieldName string was being truncated from the first occurrence of the point, when it should have been truncated from the last. diffstat: modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java | 46 +++++----- 1 files changed, 23 insertions(+), 23 deletions(-) diffs (71 lines): diff -r d038772958dd -r 5ac834636f94 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 Fri May 24 01:52:46 2013 +0200 +++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java Fri May 24 08:56:53 2013 +0200 @@ -495,7 +495,7 @@ && referencedTable.getDisplayedColumn().isActive()) { useProperty = property.getEntity().getPropertyByColumnName( referencedTable.getDisplayedColumn().getDBColumnName()); - final int index = useFieldName.indexOf(DalUtil.DOT); + final int index = useFieldName.lastIndexOf(DalUtil.DOT); useFieldName = useFieldName.substring(0, index + 1) + useProperty.getName(); break; } @@ -1129,25 +1129,25 @@ } protected String getOrderByClausePart(String orderByParam) { - // Support for one argument functions - String functionPattern = "(.*)\\((.*)\\) (desc|DESC)+"; - Pattern p = Pattern.compile(functionPattern); - Matcher m = p.matcher(orderByParam); + // Support for one argument functions + String functionPattern = "(.*)\\((.*)\\) (desc|DESC)+"; + Pattern p = Pattern.compile(functionPattern); + Matcher m = p.matcher(orderByParam); - String localOrderBy = null; - String functionName = null; - boolean descOrderedFunction = false; - if (m.find()) { - // If it is a function, retrieve the function name and the localOrderBy - functionName = m.group(1); - localOrderBy = m.group(2); - if (m.groupCount() == 3) { - // Check if the property is to be ordered in descending order - descOrderedFunction = true; - } - } else { - localOrderBy = orderByParam; - } + String localOrderBy = null; + String functionName = null; + boolean descOrderedFunction = false; + if (m.find()) { + // If it is a function, retrieve the function name and the localOrderBy + functionName = m.group(1); + localOrderBy = m.group(2); + if (m.groupCount() == 3) { + // Check if the property is to be ordered in descending order + descOrderedFunction = true; + } + } else { + localOrderBy = orderByParam; + } final boolean asc = !localOrderBy.startsWith("-"); String direction = ""; @@ -1220,10 +1220,10 @@ String orderByClausePart = sb.toString(); if (functionName != null) { - orderByClausePart = functionName + "(" + orderByClausePart + ")"; - if (descOrderedFunction) { - orderByClausePart = orderByClausePart + " desc"; - } + orderByClausePart = functionName + "(" + orderByClausePart + ")"; + if (descOrderedFunction) { + orderByClausePart = orderByClausePart + " desc"; + } } return orderByClausePart; } ------------------------------------------------------------------------------ Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits