[Geoserver-users] error mapping target attribute to complex type

Hello,
I have a problem with mapping target attribute to complex data type
(geoserver 2.3 with app-schema).
The data source is PostgreSQL. Target attribute with name “purpose” has type
datatype2. Datatype2 is a separate table containing 3 fields with types
varchar, integer, integer.
The request: http://localhost:8080/geoserver/wfs?
request=GetFeature&version=1.1.0&typeName=test:DataType2
works fine.
When I try to map target attribute to complex type (substitutionGroup is
gml:AbstractType) the following error appears:
java.lang.RuntimeException: Error applying mapping with targetAttribute
test:purpose Error applying mapping with targetAttribute test:purpose Could
not find working property accessor for attribute (purpose) in object…

The fragment of mapping file is the following:

<AttributeMapping>
        <targetAttribute>test:purpose</targetAttribute>
        <targetAttributeNode>test:DataType2Type</targetAttributeNode>
              <sourceExpression>
                        <OCQL>purpose</OCQL>
               </sourceExpression>
  <isMultiple>true</isMultiple>
    </AttributeMapping>

The XSD fragment is the following:

<element name="DataType2" substitutionGroup="gml:AbstractObject"
type="test:DataType2Type"/>

  <complexType name="DataType2Type">
    <sequence>
      <element maxOccurs="unbounded" name="string" type="string"/>
      <element minOccurs="0" name="intfield" type="integer"/>
    </sequence>
  </complexType>

<element name="LandImmovable" substitutionGroup="gml:AbstractFeature"
type="test:LandImmovableType">

  <complexType name="LandImmovableType">
    <complexContent>
      <extension base="gml:AbstractFeatureType">
         <sequence>
            <element name="identifier" type="string"/>
            <element name="geometry" type="gml:SurfacePropertyType" nillable
= "true"/>
            <element name="purpose" type="test:DataType2PropertyType"/>
            <element name="doublefield" type="gml:AreaType"/>
  …
             …
        </sequence>

What is wrong?
Regards

Hristo,

WFS can only deliver features, not non-feature complex types. It cannot be used to request DataType2 because it is not a feature. I think you should be requesting LandImmovable. Nested properties will be encoded inside LandImmovable.

Why are you using <targetAttributeNode> when the target type is already concrete (test:DataType2PropertyType, which I am assuming obeys the property type pattern)? Furthermore, for complex types <targetAttributeNode> is typically used on the containing property type and does not map data, which is handled in a separate mapping.

You can use feature chaining to nest non-feature complex properties within a complex feature, including multivalued properties. See:
http://docs.geoserver.org/latest/en/user/data/app-schema/feature-chaining.html

You need a separate mapping for this complex type. It can be in the same mapping file.

test:purpose is not multivalued. test:purpose/test:DataType2/test:name is multivalued. I think your isMultiple is for the wrong attribute and in the wrong typeMapping.

Kind regards,
Ben.

On 19/04/13 14:54, Hristo Dechev wrote:

Hello,
I have a problem with mapping target attribute to complex data type
(geoserver 2.3 with app-schema).
The data source is PostgreSQL. Target attribute with name “purpose” has type
datatype2. Datatype2 is a separate table containing 3 fields with types
varchar, integer, integer.
The request: http://localhost:8080/geoserver/wfs?
request=GetFeature&version=1.1.0&typeName=test:DataType2
works fine.
When I try to map target attribute to complex type (substitutionGroup is
gml:AbstractType) the following error appears:
java.lang.RuntimeException: Error applying mapping with targetAttribute
test:purpose Error applying mapping with targetAttribute test:purpose Could
not find working property accessor for attribute (purpose) in object…

The fragment of mapping file is the following:

<AttributeMapping>
         <targetAttribute>test:purpose</targetAttribute>
         <targetAttributeNode>test:DataType2Type</targetAttributeNode>
               <sourceExpression>
                         <OCQL>purpose</OCQL>
                </sourceExpression>
  <isMultiple>true</isMultiple>
     </AttributeMapping>
  …
The XSD fragment is the following:

<element name="DataType2" substitutionGroup="gml:AbstractObject"
type="test:DataType2Type"/>

   <complexType name="DataType2Type">
     <sequence>
       <element maxOccurs="unbounded" name="string" type="string"/>
       <element minOccurs="0" name="intfield" type="integer"/>
     </sequence>
   </complexType>

<element name="LandImmovable" substitutionGroup="gml:AbstractFeature"
type="test:LandImmovableType">

   <complexType name="LandImmovableType">
     <complexContent>
       <extension base="gml:AbstractFeatureType">
          <sequence>
             <element name="identifier" type="string"/>
             <element name="geometry" type="gml:SurfacePropertyType" nillable
= "true"/>
             <element name="purpose" type="test:DataType2PropertyType"/>
             <element name="doublefield" type="gml:AreaType"/>
  …
              …
         </sequence>

What is wrong?
Regards

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis& visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Ben Caradoc-Davies <Ben.Caradoc-Davies@anonymised.com>
Software Engineer
CSIRO Earth Science and Resource Engineering
Australian Resources Research Centre