From 046e326ef88d64bf5ea5d903f3b597f435e3715b Mon Sep 17 00:00:00 2001 From: groldan Date: Fri, 29 Jun 2012 13:23:33 +0000 Subject: [PATCH] Make it so that returning Filter.EXCLUDE from ClientTransactionAccessor.getUpdateFilter(String propName) means the filter referencing that property is not encodable to the backend git-svn-id: http://svn.osgeo.org/geotools/trunk@38849 e5c1c795-43da-0310-a71f-fac65c449510 --- .../visitor/CapabilitiesFilterSplitter.java | 22 +++++++++++++++---- .../visitor/ClientTransactionAccessor.java | 5 ++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/library/main/src/main/java/org/geotools/filter/visitor/CapabilitiesFilterSplitter.java b/modules/library/main/src/main/java/org/geotools/filter/visitor/CapabilitiesFilterSplitter.java index 5853789fce2..1033335874d 100644 --- a/modules/library/main/src/main/java/org/geotools/filter/visitor/CapabilitiesFilterSplitter.java +++ b/modules/library/main/src/main/java/org/geotools/filter/visitor/CapabilitiesFilterSplitter.java @@ -126,12 +126,21 @@ * say with certainty exactly how the logic for that part of this works, but the test suite does * seem to test it and the tests do pass. *

+ *

+ * Since GeoTools 8.0, the {@link ClientTransactionAccessor} interface can also be used to instruct + * the splitter that a filter referencing a given {@link PropertyName} can't be encoded by the + * back-end, by returning {@link Filter#EXCLUDE} in + * {@link ClientTransactionAccessor#getUpdateFilter(String) getUpdateFilter(String)}. This is so + * because there may be the case where some attribute names are encodable to the back-end's query + * language, while others may not be, or may not be part of the stored data model. In such case, + * returning {@code Filter.EXCLUDE} makes the filter referencing the property name part of the + * post-processing filter instead of the pre-processing filter. * * @author dzwiers * @author commented and ported from gt to ogc filters by saul.farber * @author ported to work upon {@code org.geotools.filter.Capabilities} by Gabriel Roldan - * - * + * + * * @source $URL$ * @since 2.5.3 */ @@ -801,8 +810,13 @@ public Object visit(PropertyName expression, Object notUsed) { Filter updateFilter = (Filter) transactionAccessor.getUpdateFilter(expression .getPropertyName()); if (updateFilter != null) { - changedStack.add(updateFilter); - preStack.push(updateFilter); + if(updateFilter == Filter.EXCLUDE){ + // property name not encodable to backend + postStack.push(expression); + }else{ + changedStack.add(updateFilter); + preStack.push(updateFilter); + } } else preStack.push(expression); } else { diff --git a/modules/library/main/src/main/java/org/geotools/filter/visitor/ClientTransactionAccessor.java b/modules/library/main/src/main/java/org/geotools/filter/visitor/ClientTransactionAccessor.java index 11d002c1ad4..6b8e01b75a0 100644 --- a/modules/library/main/src/main/java/org/geotools/filter/visitor/ClientTransactionAccessor.java +++ b/modules/library/main/src/main/java/org/geotools/filter/visitor/ClientTransactionAccessor.java @@ -43,7 +43,10 @@ public interface ClientTransactionAccessor { * Returns all the filters of updates that affect the attribute in the expression ORed together. * * @param attributePath the xpath identifier of the attribute. - * @return all the filters of updates that affect the attribute in the expression ORed together. + * @return all the filters of updates that affect the attribute in the expression ORed together, + * {@link Filter#EXCLUDE} if the attribute path is not supported/encodable to the backend + * (and hence any filter including it shall only be evaluated at runtime), or {@code null} if no behavior + * change is to be applied. */ Filter getUpdateFilter(String attributePath);