Hmmm... nothing jumps out at me right way, Ben probably has a better idea.
The problem seems quite in depth, i think i would need to debug to figure
out what is going on. Which i would be happy to do. Any chance you have a
runnable test case?

On Wed, Oct 6, 2010 at 2:54 AM, Andrea Aime <[email protected]>wrote:

> Hi,
> I'm pulling my hairs quite a bit with an odd situation: I have setup
> one feature chaining in the app-schema mappings,
> I see that the store actually builds the collection of sub-features,
> but then the gml3 encoder won't emit them in output.
> I'm quite baffled as to why, though.
>
> A bit of context. Here is the relevant schema declarations:
>
> <xs:complexType name="OilSpillType">
>                <xs:complexContent>
>                        <xs:extension base="gml:AbstractFeatureType">
>                                <xs:sequence>
>                                        <xs:element name="eventid"
> type="xs:string">
>                                        </xs:element>
>                                        <xs:element name="origin"
> type="csn:OriginType">
>                                        </xs:element>
>                                        <xs:element name="geometry"
> type="gml:MultiPolygonPropertyType"/>
>                                        <xs:element name="polygons"
> type="csn:SpillPolygonArrayType"/>
>                                        ...
> </xs:complexType>
>
> <xs:complexType name="SpillPolygonArrayType">
>                <xs:annotation>
>                        <xs:documentation>Array spill polygons along with
> their
> extension</xs:documentation>
>                </xs:annotation>
>                <xs:sequence>
>                        <xs:element ref="csn:SpillPolygon" minOccurs="0"
> maxOccurs="unbounded"/>
>                </xs:sequence>
>        </xs:complexType>
>        <xs:element name="SpillPolygon" type="csn:SpillPolygonType">
>                <xs:annotation>
>                        <xs:documentation>Oil Spill root element for a
> generic Oil Spill
> observation or prediction</xs:documentation>
>                </xs:annotation>
>        </xs:element>
>        <xs:complexType name="SpillPolygonType">
>                <xs:annotation>
>                        <xs:documentation>A single spill polygons along with
> its
> extension</xs:documentation>
>                </xs:annotation>
>                <xs:sequence>
>                        <xs:element name="polygon"
> type="gml:PolygonPropertyType" minOccurs="0"/>
>                        <xs:element name="extension"
> type="csn:OilSpillExtensionType" minOccurs="0"/>
>                </xs:sequence>
>        </xs:complexType>
>
> (A note there, at first I did not have the SpillPolygon element but
> noted that the app-schema store
>  would not work without an element as the target).
>
> And here is the relevant mapping parts:
>
> <AttributeMapping>
>        <targetAttribute>csndc:polygons/csndc:SpillPolygon</targetAttribute>
>        <sourceExpression>
>                <OCQL>strSubstringStart(getID(), strLastIndexOf(getID(),
> '.') + 1)</OCQL>
>                <linkElement>csndc:SpillPolygon</linkElement>
>                <linkField>FEATURE_LINK</linkField>
>        </sourceExpression>
>        <isMultiple>true</isMultiple>
> </AttributeMapping>
>
> (ok, not too good looking, but that's how I managed to extract the
> actual primary key value
>  to be used for feature joining)
>
> <FeatureTypeMapping>
>                        <sourceDataStore>egeos-emsa-pg</sourceDataStore>
>                        <sourceType>oilspillpolygon</sourceType>
>                        <targetElement>csndc:SpillPolygon</targetElement>
>                        <attributeMappings>
>                                <AttributeMapping>
>
>  <targetAttribute>FEATURE_LINK</targetAttribute>
>                                        <sourceExpression>
>                                                <OCQL>oilspillid</OCQL>
>                                        </sourceExpression>
>                                </AttributeMapping>
>                                <AttributeMapping>
>
>  <targetAttribute>csndc:polygon</targetAttribute>
>                                        <sourceExpression>
>                                                <OCQL>spillpolygon</OCQL>
>                                        </sourceExpression>
>                                </AttributeMapping>
>                                <AttributeMapping>
>
>  <targetAttribute>csndc:extension/csndc:area</targetAttribute>
>                                        <sourceExpression>
>                                                <OCQL>extension_area</OCQL>
>                                        </sourceExpression>
>                                </AttributeMapping>
>                                <AttributeMapping>
>
>  <targetAttribute>csndc:extension/csndc:length</targetAttribute>
>                                        <sourceExpression>
>
>  <OCQL>extension_length</OCQL>
>                                        </sourceExpression>
>                                </AttributeMapping>
>                                <AttributeMapping>
>
>  <targetAttribute>csndc:extension/csndc:width</targetAttribute>
>                                        <sourceExpression>
>                                                <OCQL>extension_width</OCQL>
>                                        </sourceExpression>
>                                </AttributeMapping>
>                        </attributeMappings>
>                </FeatureTypeMapping>
>
> Now, as I said, I debugged the code and I see that the app-schema
> store is actually
> producing the polygons attribute, whose tostring looks like:
>
>
> ComplexAttributeImpl:polygons<SpillPolygonArrayType>=[ComplexAttributeImpl:SpillPolygon<SpillPolygonType>=[FeatureImpl:SpillPolygon<SpillPolygonType
> id=oilspillpolygon.10>=[AttributeImpl:FEATURE_LINK<string>=1,
> GeometryAttributeImpl:polygon<PolygonPropertyType>=POLYGON ((8.927616
> 43.863998, ...
>
> but then the encoder fails to encode it, in particular it seems for
> some reason it's not being
> able to extract the properties inside the spill polygon.
> In fact, in those cases in which I have two polygons inside the array
> I get this as the output:
>
> ...
> <csndc:polygons>
> <csndc:SpillPolygon/>
> <csndc:SpillPolygon/>
> </csndc:polygons>
> ...
>
> I'm quite baffled as to why this is happening. Ah, I also tried to
> make SpillPolygon a feature at the
> schema level and at the mapping level, but when I do I get this exception:
>
> Caused by: java.lang.NullPointerException:
> http://www.emsa.europa.eu/csndc:SpillPolygonType is identified, null
> id not accepted
>        at org.geotools.feature.type.Types.validate(Types.java:118)
>        at org.geotools.feature.type.Types.validate(Types.java:80)
>        at org.geotools.feature.AttributeImpl.<init>(AttributeImpl.java:51)
>        at
> org.geotools.feature.ComplexAttributeImpl.<init>(ComplexAttributeImpl.java:35)
>        at org.geotools.feature.FeatureImpl.<init>(FeatureImpl.java:57)
>        at
> org.geotools.feature.AppSchemaFeatureFactoryImpl.createFeature(AppSchemaFeatureFactoryImpl.java:128)
>        at
> org.geotools.feature.AttributeBuilder.create(AttributeBuilder.java:574)
>        at
> org.geotools.feature.AttributeBuilder.add(AttributeBuilder.java:495)
>        at org.geotools.data.complex.filter.XPath.setValue(XPath.java:769)
>        at org.geotools.data.complex.filter.XPath.set(XPath.java:700)
>        at org.geotools.data.complex.filter.XPath.set(XPath.java:553)
>        at
> org.geotools.data.complex.DataAccessMappingFeatureIterator.setAttributeValue(DataAccessMappingFeatureIterator.java:394)
>        at
> org.geotools.data.complex.DataAccessMappingFeatureIterator.computeNext(DataAccessMappingFeatureIterator.java:712)
>        ... 73 more
>
> With a mapping looking like:
>
> <FeatureTypeMapping>
>                        <sourceDataStore>egeos-emsa-pg</sourceDataStore>
>                        <sourceType>oilspillpolygon</sourceType>
>                        <targetElement>csndc:SpillPolygon</targetElement>
>                        <attributeMappings>
>                                <AttributeMapping>
>
>  <targetAttribute>csndc:SpillPolygon</targetAttribute>
>                                        <idExpression>
>                                                <OCQL>getID()</OCQL>
>                                        </idExpression>
>                                </AttributeMapping>
>                                <AttributeMapping>
>
>  <targetAttribute>FEATURE_LINK</targetAttribute>
>                                        <sourceExpression>
>                                                <OCQL>oilspillid</OCQL>
>                                        </sourceExpression>
>                                </AttributeMapping>
>                                ...
>
> and of course the necessary modifications in the schema to make
> csndc:SpillPolygon
> a feature.
>
> Not that I want it to be a feature, was just guessing that maybe the
> property extractors
> in the encoder work only against features, but as you see I did not
> manage to confirm
> or deny this hypothesis.
>
> Anyways, does the above ring any bell?
>
> Cheers
> Andrea
>
> -----------------------------------------------------
> Ing. Andrea Aime
> Senior Software Engineer
>
> GeoSolutions S.A.S.
> Via Poggio alle Viti 1187
> 55054  Massarosa (LU)
> Italy
>
> phone: +39 0584962313
> fax:     +39 0584962313
>
> http://www.geo-solutions.it
> http://geo-solutions.blogspot.com/
> http://www.linkedin.com/in/andreaaime
> http://twitter.com/geowolf
>
> -----------------------------------------------------
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Geotools-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>



-- 
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to