svn - r34269 - in trunk/modules/unsupported/app-schema/app-schema/src: main/java/org/geotools/data/complex main/java/org/geotools/data/complex/filter test/resources/test-data

1 message Options
Embed this post
Permalink
svn_geotools

svn - r34269 - in trunk/modules/unsupported/app-schema/app-schema/src: main/java/org/geotools/data/complex main/java/org/geotools/data/complex/filter test/resources/test-data

Reply Threaded More More options
Print post
Permalink
Author: ang05a
Date: 2009-10-28 04:46:18 -0400 (Wed, 28 Oct 2009)
New Revision: 34269

Modified:
   trunk/modules/unsupported/app-schema/app-schema/src/main/java/org/geotools/data/complex/XmlFeatureTypeMapping.java
   trunk/modules/unsupported/app-schema/app-schema/src/main/java/org/geotools/data/complex/filter/UnmappingFilterVisitor.java
   trunk/modules/unsupported/app-schema/app-schema/src/test/resources/test-data/xmlDataAccessConfig.xml
Log:
Support filtering leaf complex properties that aren't explicitly mapped but exists inside the mapped root property - take 2

Modified: trunk/modules/unsupported/app-schema/app-schema/src/main/java/org/geotools/data/complex/XmlFeatureTypeMapping.java
===================================================================
--- trunk/modules/unsupported/app-schema/app-schema/src/main/java/org/geotools/data/complex/XmlFeatureTypeMapping.java 2009-10-27 14:06:32 UTC (rev 34268)
+++ trunk/modules/unsupported/app-schema/app-schema/src/main/java/org/geotools/data/complex/XmlFeatureTypeMapping.java 2009-10-28 08:46:18 UTC (rev 34269)
@@ -110,6 +110,20 @@
                 mappings.add(mapping.get(listPath));
             }
         }
+        
+        if (mappings.isEmpty()) {
+            // look in the setter attributes
+            Iterator<TreeAttributeMapping> leafAtts = setterAttributes.iterator();
+            while (leafAtts.hasNext()) {
+                TreeAttributeMapping att = leafAtts.next();
+                String listPath = att.getTargetXPath().toString();
+                String unindexedListPath = removeIndexFromPath(listPath);
+                if (path.equals(unindexedListPath)) {
+                    mappings.add(att.getSourceExpression().toString());
+                }
+            }
+
+        }
         return mappings;
     }
 

Modified: trunk/modules/unsupported/app-schema/app-schema/src/main/java/org/geotools/data/complex/filter/UnmappingFilterVisitor.java
===================================================================
--- trunk/modules/unsupported/app-schema/app-schema/src/main/java/org/geotools/data/complex/filter/UnmappingFilterVisitor.java 2009-10-27 14:06:32 UTC (rev 34268)
+++ trunk/modules/unsupported/app-schema/app-schema/src/main/java/org/geotools/data/complex/filter/UnmappingFilterVisitor.java 2009-10-28 08:46:18 UTC (rev 34269)
@@ -30,6 +30,8 @@
 import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
 
+import org.geotools.data.DataAccess;
+import org.geotools.data.complex.AppSchemaDataAccess;
 import org.geotools.data.complex.AppSchemaDataAccessRegistry;
 import org.geotools.data.complex.AttributeMapping;
 import org.geotools.data.complex.FeatureTypeMapping;
@@ -39,6 +41,7 @@
 import org.geotools.factory.CommonFactoryFinder;
 import org.geotools.feature.NameImpl;
 import org.geotools.feature.Types;
+import org.geotools.filter.AttributeExpressionImpl;
 import org.geotools.filter.NestedAttributeExpression;
 import org.opengis.feature.type.AttributeDescriptor;
 import org.opengis.feature.type.Name;
@@ -893,26 +896,48 @@
                                         "Can't find source expression for: " + targetXPath);
                             }
                         }
-                        Expression srcExpression = matchedExpressions.get(0);
-                        if (!srcExpression.equals(Expression.NIL)) {
-                            if (isNestedMapping) {
+                        if (isNestedMapping) {
+                            if (!matchedExpressions.get(0).equals(Expression.NIL)) {
                                 nestedMappings.add(ff.literal(featureTypeName));
-                                nestedMappings.add(srcExpression);
-                                if (isLast) {
-                                    break;
-                                }
+                                nestedMappings.add(matchedExpressions.get(0));
                                 nextRootIndex++;
                                 stepIncrement = 0;
                                 isNestedMapping = false;
-                            } else {
-                                // mapping found
-                                matchingMappings.add(srcExpression);
-                                break;
                             }
+                        } else if (isLast) {
+                            // must be it
+                            matchingMappings.add(matchedExpressions.get(0));
                         } else {
-                            // NIL expression.. so this is just the header, keep looking
-                            incrementStep = true;
+                            // not the last.. check if the leaf attributes are mapped in the back
+                            // end
+                            DataAccess da = this.mappings.getSource().getDataStore();
+                            if (da instanceof AppSchemaDataAccess) {
+                                // check if the leaf attributes are mapped in the
+                                // back end complex features mapping
+                                FeatureTypeMapping backEndMappings;
+                                try {
+                                    backEndMappings = ((AppSchemaDataAccess) da)
+                                            .getMapping(featureTypeName);
+                                } catch (IOException e) {
+                                    throw new UnsupportedOperationException("Mapping for '"
+                                            + featureTypeName + "' not found!!");
+                                }
+                                AttributeMapping wrappedMapping = backEndMappings
+                                        .getAttributeMapping(simplifiedSteps.subList(nextRootIndex,
+                                                simplifiedSteps.size()));
+                                if (wrappedMapping != null) {
+                                    // it is mapped, but in the back end
+                                    matchingMappings.add(new AttributeExpressionImpl(wrappedMapping
+                                            .getTargetXPath().toString()));
+                                    break;
+                                }
+                            }
                         }
+                        if (isLast) {
+                            break;
+                        }
+                        // not last, keep going
+                        incrementStep = true;
                     }
                 }
                 if (incrementStep || mapping == null) {

Modified: trunk/modules/unsupported/app-schema/app-schema/src/test/resources/test-data/xmlDataAccessConfig.xml
===================================================================
--- trunk/modules/unsupported/app-schema/app-schema/src/test/resources/test-data/xmlDataAccessConfig.xml 2009-10-27 14:06:32 UTC (rev 34268)
+++ trunk/modules/unsupported/app-schema/app-schema/src/test/resources/test-data/xmlDataAccessConfig.xml 2009-10-28 08:46:18 UTC (rev 34269)
@@ -95,11 +95,6 @@
            <value>'gsv:NameSpace'</value>
          </ClientProperty>
          </AttributeMapping>    
-        
-         <AttributeMapping>
-            <parentLabel>gsml:GeologicUnit</parentLabel>          
-            <targetAttribute>gsml:observationMethod</targetAttribute>
-         </AttributeMapping>
 
          <AttributeMapping>
             <parentLabel>gsml:GeologicUnit</parentLabel>          


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
GeoTools-commits mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-commits