Here are the patches. Anyone have any objections? Andrea you are the original author of FilterAttributeExtractor so your feedback would be great.

Justin Deoliveira wrote:
Gabriel Roldán wrote:
On Monday 09 July 2007 20:00:14 Justin Deoliveira wrote:
Hi Gabriel,

It seems that some code that did attribute name lookup in
DataUtilities.attributeNames is no longer going through the
PropertyAccessor interface when traversing a filter to pull out all
PropertyName's from it.

There is a comment in the code sayign that it is part of GEOT-1192 which
is still in progress... so confused just looking for some explanation.

As far as I know the replacement will cause all xpath and namespace
prefixed property names to fail in this manner.
I see.. well, I have to say that I've relied on the unit tests so it might be worth if we add one for that case. Gonna run home now, but will take care of restoring that functionality asap.
Ok cool... a lot of these issues don't come up until we run cite... a test case will be well worth it, working on one now..

I already have a patch which involves modifying FilterPropertyExtractor which I will submit. I was more wondering if there was an explicit reason for the change but it sounds like not.

Thanks Gabriel.

-Justin
Gabriel

-Justin


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel







--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org
Index: src/main/java/org/geotools/data/DataUtilities.java
===================================================================
--- src/main/java/org/geotools/data/DataUtilities.java  (revision 26180)
+++ src/main/java/org/geotools/data/DataUtilities.java  (working copy)
@@ -205,7 +205,7 @@
         if (filter == null) {
              return new String[0];
          }
-         FilterAttributeExtractor attExtractor = new 
FilterAttributeExtractor();
+         FilterAttributeExtractor attExtractor = new 
FilterAttributeExtractor(featureType);
          filter.accept(attExtractor, null);
          String[] attributeNames = attExtractor.getAttributeNames();
          return attributeNames;
Index: src/main/java/org/geotools/filter/FilterAttributeExtractor.java
===================================================================
--- src/main/java/org/geotools/filter/FilterAttributeExtractor.java     
(revision 26180)
+++ src/main/java/org/geotools/filter/FilterAttributeExtractor.java     
(working copy)
@@ -19,6 +19,8 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import org.geotools.feature.AttributeType;
+import org.geotools.feature.FeatureType;
 import org.geotools.filter.visitor.DefaultFilterVisitor;
 import org.opengis.filter.expression.PropertyName;
 
@@ -33,8 +35,19 @@
 public class FilterAttributeExtractor extends DefaultFilterVisitor {
     /** Last set visited */
     protected Set attributeNames = new HashSet();
+    /** feature type to evaluate against */
+    protected FeatureType featureType;
 
     /**
+     * @deprecated Should use [EMAIL PROTECTED] 
#FilterAttributeExtractor(FeatureType)}.
+     */
+    public FilterAttributeExtractor() {
+        this(null);
+    }
+    public FilterAttributeExtractor(FeatureType featureType) {
+        this.featureType = featureType;
+    }
+    /**
      * DOCUMENT ME!
      *
      * @return an unmofiable set of the attribute names found so far during 
the visit
@@ -63,7 +76,22 @@
         if( data != null && data != attributeNames ){
             attributeNames = (Set) data;
         }
-        attributeNames.add( expression.getPropertyName() );
+        if (featureType != null) {
+            //evaluate against the feature type instead of using straight name
+            // since the path from the property name may be an xpath or a 
+            // namespace prefixed string
+            AttributeType type = (AttributeType) expression.evaluate( 
featureType );
+            if ( type != null ) {
+               attributeNames.add( type.getName() );
+            }
+            else {
+               attributeNames.add( expression.getPropertyName() );
+            }
+        }
+        else {
+            attributeNames.add( expression.getPropertyName() );
+        }
+
         return attributeNames;
     }
 }
\ No newline at end of file
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to