[Geoserver-users] Problem with app-schema and a one-to-many relation

Hello,
I need some help to doule check my app-schema configuration.
I’ve defined a application schema of my own with two feature types in two xsd files.

The types are ‘HeartStarter’ which contains information about a defibrillator and which has a list (one-to-many) of the type ‘AvailableTime’. The data are stored in a SQL Server.

What I’m looking for is a gml output like:
gml:featureMember
<heart:HeartStarter gml:id=“HjaertstartarIntegrationsVy.fid-40cd2bcf_13b523db3a7_-7a12”>
heart:Id2</heart:Id>
heart:OwnerGrönhögen Golf</heart:Owner>
heart:AddressGolfvägen 1</heart:Address>
heart:ZipCode38065</heart:ZipCode>
heart:CityDegerhamn</heart:City>
heart:FloorEntréplan</heart:Floor>
heart:PlacementI receptionen</heart:Placement>
heart:AdditionalInformation0</heart:AdditionalInformation>
heart:AvailableTimes
heart:Time
heart:IntervalValfria dagar</heart:Interval>
heart:FromDate01-jun</heart:FromDate>
heart:ToDate18-aug</heart:ToDate>
heart:FromWeekdayMåndag</heart:FromWeekday>
heart:ToWeekdayFredag</heart:ToWeekday>
heart:FromTime1900-01-01T09:00:00Z</heart:FromTime>
heart:ToTime1900-01-01T16:00:00Z</heart:ToTime>
</heart:Time>
</heart:AvailableTimes>
heart:the_geom
<gml:Point srsDimension=“2” srsName=“http://www.opengis.net/gml/srs/epsg.xml#900913”>
gml:pos1825684.176806 7612514.23784135</gml:pos>
</gml:Point>
</heart:the_geom>
</heart:HeartStarter>
</gml:featureMember>

The featuretype AvailableTime works fine on its own and produces for example this result:
gml:featureMember
<heart:AvailableTime gml:id=“TillgaengligaTider.1”>
heart:IntervalValfria dagar</heart:Interval>
heart:FromDate01-jun</heart:FromDate>
heart:ToDate18-aug</heart:ToDate>
heart:FromWeekdayMåndag</heart:FromWeekday>
heart:ToWeekdayFredag</heart:ToWeekday>
heart:FromTime1900-01-01T09:00:00Z</heart:FromTime>
heart:ToTime1900-01-01T16:00:00Z</heart:ToTime>
</heart:AvailableTime>
</gml:featureMember>

But when I request one of the Heartstarters that has a AvailableTime the information of the Available time is not displayed in the gml, instead I only get a closed Time element. For example:
gml:featureMember
<heart:HeartStarter gml:id=“HjaertstartarIntegrationsVy.fid-40cd2bcf_13b523db3a7_-7a12”>
heart:Id2</heart:Id>
heart:OwnerGrönhögen Golf</heart:Owner>
heart:AddressGolfvägen 1</heart:Address>
heart:ZipCode38065</heart:ZipCode>
heart:CityDegerhamn</heart:City>
heart:FloorEntréplan</heart:Floor>
heart:PlacementI receptionen</heart:Placement>
heart:AdditionalInformation0</heart:AdditionalInformation>
heart:AvailableTimes
heart:Time/
</heart:AvailableTimes>
heart:the_geom
<gml:Point srsDimension=“2” srsName=“http://www.opengis.net/gml/srs/epsg.xml#900913”>
gml:pos1825684.176806 7612514.23784135</gml:pos>
</gml:Point>
</heart:the_geom>
</heart:HeartStarter>
</gml:featureMember>

I attached the mapping file and the xsd files and I would really appreciate if you take the time to help me as I been banging my head on this for quite some time.

Best regards
Lukas


Lukas Bergliden
Civilingenjör
Decerno AB
Electrum 234, SE-164 40 KISTA
Besöksadress: Kistagången 16, 7 tr
Tel: +46 8 630 75 00
Mobil: +46 70 644 96 61

AvailableTime.xsd (1.07 KB)

HeartStarter.xsd (1.71 KB)

heart_HeartStarter.xml (6.48 KB)

heart_AvailableTime.xml (5.9 KB)

Lucas,

in your mapping for heart:HeartStarter you have an AttributeMapping for heart:AvailableTimes/heart:Time in which you specify linkField twice:

<linkField>HeartStartId</linkField>
<linkField>FEATURE_LINK[1]</linkField>

I am not sure why this element appears twice. What happens if you remove the first linkField element? I think the second is the one that is needed.

I have copied Rini who is our feature chaining expert.

Kind regards,

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

Hello,
Thank you for your answer and I'm sorry for the late answer. I'm on vacation and getting access to internet connection trough my phone stable enough for me to connect to work over VPN is harder than I expected.

I managed to log in today and checked in my mapping file and you are right, there shouldn't be two linkfields and if there are, the link does not work at all (the heartstarter doesn't get any available times at all). I changed into:
<AttributeMapping>
  <sourceExpression>
    <OCQL>Id</OCQL>
    <linkElement>heart:AvailableTime</linkElement>
    <linkField>FEATURE_LINK[1]</linkField>
  </sourceExpression>
</AttributeMapping>
The link then works but the AvaiableTime does not contain any information:
<heart:AvailableTimes>
  <heart:Time/>
</heart:AvailableTimes>

But when i the AvailableTimeType solo with getFeatuure it works.
<heart:AvailableTime gml:id="TillgaengligaTider.3">
  <heart:Interval>Helg</heart:Interval>
  <heart:FromTime>2012-12-28T23:00:00Z</heart:FromTime
  <heart:ToTime>2012-12-28T23:30:00Z</heart:ToTime>
</heart:AvailableTime>

Do you have any more ideas?

Vänliga Hälsningar
Lukas
___________________________
Lukas Bergliden
Civilingenjör
Decerno AB
Electrum 234, SE-164 40 KISTA
Besöksadress: Kistagången 16, 7 tr
Tel: +46 8 630 75 00
Mobil: +46 70 644 96 61

________________________________________
From: Ben Caradoc-Davies [Ben.Caradoc-Davies@anonymised.com]
Sent: Friday, December 14, 2012 6:38 AM
To: Lukas Bergliden
Cc: geoserver-users@lists.sourceforge.net; Rini Angreani
Subject: Re: [Geoserver-users] Problem with app-schema and a one-to-many relation

Lucas,

in your mapping for heart:HeartStarter you have an AttributeMapping for
heart:AvailableTimes/heart:Time in which you specify linkField twice:

<linkField>HeartStartId</linkField>
<linkField>FEATURE_LINK[1]</linkField>

I am not sure why this element appears twice. What happens if you remove
the first linkField element? I think the second is the one that is needed.

I have copied Rini who is our feature chaining expert.

Kind regards,

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

Hi Lukas,

It seems to me your feature chaining doesn't work because your element names are different.
You are expecting heart:Time element when the chained type is a heart:AvailableTime element.
You could either:

1) Change the HeartStarter definition so AvailableTimes contains AvailableTime element, instead of Time element.
This will result in a bit of change in the output:
<heart:AvailableTimes>
    <heart:AvailableTime>
          <heart:Interval>Valfria dagar</heart:Interval>
          <heart:FromDate>01-jun</heart:FromDate>
          <heart:ToDate>18-aug</heart:ToDate>
          <heart:FromWeekday>Måndag</heart:FromWeekday>
          <heart:ToWeekday>Fredag</heart:ToWeekday>
          <heart:FromTime>1900-01-01T09:00:00Z</heart:FromTime>
          <heart:ToTime>1900-01-01T16:00:00Z</heart:ToTime>
    </heart:AvailableTime>
</heart:AvailableTimes>

The schema needs to be changed as follows:

<xs:element name="AvailableTimes">
    <xs:complexType>
        <xs:sequence>
    <xs:element ref="heart:AvailableTime" minOccurs="0" maxOccurs="unbounded"/>

Also the attribute mapping for the AvailableTimes in heart_HeartStarter.xml should be updated to:
<AttributeMapping>
    <targetAttribute>heart:AvailableTimes</targetAttribute>
    <sourceExpression>
        <OCQL>Id</OCQL>
        <linkElement>heart:AvailableTime</linkElement>
        <linkField>FEATURE_LINK[1]</linkField>
    </sourceExpression>
</AttributeMapping>

2) Do the same above and use substitutionGroup in the schema. This will keep the heart:Time element inside heart:AvailableTimes as originally desired.
The following schema changes are required:

<xs:element name="AvailableTimes">
    <xs:complexType>
        <xs:sequence>
    <xs:element ref="heart:AvailableTime" minOccurs="0" maxOccurs="unbounded"/>

Add the following entry in HeartStarter.xsd also:
<xs:element name="Time" type="heart:AvailableTimeType" substitutionGroup="heart:AvailableTime"/>

The heart_AvailableTime.xml mapping file needs to be updated with Time as the top element:

<targetElement>heart:Time</targetElement>
    <attributeMappings>
        <AttributeMapping>
            <targetAttribute>heart:Time</targetAttribute>

Lastly, the attribute mapping for the AvailableTimes in heart_HeartStarter.xml should be updated to:
<AttributeMapping>
    <targetAttribute>heart:AvailableTimes</targetAttribute>
    <sourceExpression>
        <OCQL>Id</OCQL>
        <linkElement>heart:Time</linkElement>
        <linkField>FEATURE_LINK[1]</linkField>
    </sourceExpression>
</AttributeMapping>

I hope this works.

Cheers
Rini

-----Original Message-----
From: Lukas Bergliden [mailto:lukas.bergliden@anonymised.com]
Sent: Saturday, 29 December 2012 11:30 PM
To: Caradoc-Davies, Ben (CESRE, Kensington)
Cc: geoserver-users@lists.sourceforge.net; Angreani, Rini (CESRE, Kensington)
Subject: RE: [Geoserver-users] Problem with app-schema and a one-to-many relation

Hello,
Thank you for your answer and I'm sorry for the late answer. I'm on vacation and getting access to internet connection trough my phone stable enough for me to connect to work over VPN is harder than I expected.

I managed to log in today and checked in my mapping file and you are right, there shouldn't be two linkfields and if there are, the link does not work at all (the heartstarter doesn't get any available times at all). I changed into:
<AttributeMapping>
  <sourceExpression>
    <OCQL>Id</OCQL>
    <linkElement>heart:AvailableTime</linkElement>
    <linkField>FEATURE_LINK[1]</linkField>
  </sourceExpression>
</AttributeMapping>
The link then works but the AvaiableTime does not contain any information:
<heart:AvailableTimes>
  <heart:Time/>
</heart:AvailableTimes>

But when i the AvailableTimeType solo with getFeatuure it works.
<heart:AvailableTime gml:id="TillgaengligaTider.3">
  <heart:Interval>Helg</heart:Interval>
  <heart:FromTime>2012-12-28T23:00:00Z</heart:FromTime
  <heart:ToTime>2012-12-28T23:30:00Z</heart:ToTime>
</heart:AvailableTime>

Do you have any more ideas?

Vänliga Hälsningar
Lukas
___________________________
Lukas Bergliden
Civilingenjör
Decerno AB
Electrum 234, SE-164 40 KISTA
Besöksadress: Kistagången 16, 7 tr
Tel: +46 8 630 75 00
Mobil: +46 70 644 96 61

________________________________________
From: Ben Caradoc-Davies [Ben.Caradoc-Davies@anonymised.com]
Sent: Friday, December 14, 2012 6:38 AM
To: Lukas Bergliden
Cc: geoserver-users@lists.sourceforge.net; Rini Angreani
Subject: Re: [Geoserver-users] Problem with app-schema and a one-to-many relation

Lucas,

in your mapping for heart:HeartStarter you have an AttributeMapping for heart:AvailableTimes/heart:Time in which you specify linkField twice:

<linkField>HeartStartId</linkField>
<linkField>FEATURE_LINK[1]</linkField>

I am not sure why this element appears twice. What happens if you remove the first linkField element? I think the second is the one that is needed.

I have copied Rini who is our feature chaining expert.

Kind regards,

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