Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple join conditions between mappings during response lifting #11

Open
sumutcan opened this issue Jan 14, 2021 · 4 comments
Open

multiple join conditions between mappings during response lifting #11

sumutcan opened this issue Jan 14, 2021 · 4 comments

Comments

@sumutcan
Copy link

sumutcan commented Jan 14, 2021

Hi Thibault,

I have an issue with joining three objects.

There are trips, their legs (subtrips), origin and destination for each leg. Here is the mapping file and input:

prefixes:
  schema: "http://schema.org/"
  wasaFunc: "http://actions.semantify.it/wasa/func/"
mappings:
  action:
    sources:
      - ["input~jsonpath", "$"]
    po:
      - [a, schema:Action]
      - [schema:actionStatus, "http://schema.org/CompletedActionStatus"]
      - [schema:result, {mapping: result}]
      
  result:
    sources:
      - ["input~jsonpath", "$.Trip.*"]
    po:
      - [a, schema:Trip]
      - [schema:name, "A trip from $(LegList.Leg.0.Origin.name) to $(LegList.Leg[-1:].Destination.name)"]
      - [schema:arrivalTime, "$(LegList.Leg.0.Origin.time)"]
      - [schema:departureTime, "$(LegList.Leg[-1:].Destination.time)"]
      - [vao:origin, {mapping: origin, join: [idx, idx]}]
      - [vao:destination, {mapping: destination, join: [idx, idx]}]
      - [schema:subTrip, {mapping: subTrip, join: [idx, ^^^idx]}]
      
  origin:
    sources:
      - ["input~jsonpath", "$.Trip.*"]
    s: "https://verkehrsauskunftoesterreich.at/location/$(LegList.Leg.0.Origin.id)"
    po:
      - [a, schema:Place]
      - [schema:name, "$(LegList.Leg.0.Origin.name)"]
      - [schema:geo, {mapping: originGeoCoordinates, join: [idx, idx]}]
      
  originGeoCoordinates:
    sources:
      - ["input~jsonpath", "$.Trip.*"]
    s: "http://adasd.com/$(LegList.Leg.0.Origin.id)/geo"
    po:
      - [a, schema:GeoCoordinates]
      - [schema:latitude, "$(LegList.Leg.0.Origin.lat)"]
      - [schema:longitude, "$(LegList.Leg.0.Origin.lon)"]
      

  destination:
    sources:
      - ["input~jsonpath", "$.Trip.*"]
    s: "https://verkehrsauskunftoesterreich.at/location/$(LegList.Leg[-1:].Destination.id)"
    po:
      - [a, schema:Place]
      - [schema:name, "$(LegList.Leg[-1:].Destination.name)"]
      - [schema:geo, {mapping: destinationGeoCoordinates, join: [idx, idx]}]
      
  destinationGeoCoordinates:
    sources:
      - ["input~jsonpath", "$.Trip.*"]
    s: "http://adasd.com/$(LegList.Leg[-1:].Destination.id)/geo"
    po:
      - [a, schema:GeoCoordinates]
      - [schema:latitude, "$(LegList.Leg[-1:].Destination.lat)"]
      - [schema:longitude, "$(LegList.Leg[-1:].Destination.lon)"]

  subTrip:
    sources:
      - ["input~jsonpath", "$.Trip.*.LegList.Leg.*"]
    s: "http://verkehrstauskunftoesterreich.at/trip/$(^^^idx)/leg/$(idx)"
    po:
      - [a schema:Trip]
      - [schema:departureTime, "$(Origin.time)"]
      - [vao:origin, {mapping: subTripOrigin, join: [idx, ^idx]}]
      - [vao:destination, {mapping: subTripDestination, join: [idx, ^idx]}]
      - [schema:arrivalTime, "$(Destination.time)"]

  subTripOrigin:
    sources:
      - ["input~jsonpath", "$.Trip.*.LegList.Leg.*.Origin"]
    s: "http://verkehrstauskunftoesterreich.at/location/$(id)"
    po:
      - [a schema:Place]
      
  subTripDestination:
      sources:
        - ["input~jsonpath", "$.Trip.*.LegList.Leg.*.Destination"]
      s: "http://verkehrstauskunftoesterreich.at/location/$(id)"
      po:
        - [a schema:Place]
    

Here is the input file:

{
  "Trip": [
    {
      "LegList": {
        "Leg": [
          {
            "Origin": {
              "name": "47.266450, 11.389962",
              "type": "ADR",
              "id": "A=2@O=47.266450, 11.389962@l=@X=11389962@Y=47266450@u=0@",
              "lon": 11.389962,
              "lat": 47.26645,
              "time": "17:16:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "Innsbruck Terminal Marktplatz",
              "type": "ST",
              "id": "A=1@O=Innsbruck Terminal Marktplatz@X=11390304@Y=47266639@U=81@L=476439605@",
              "lon": 11.390304,
              "lat": 47.266639,
              "time": "17:18:00",
              "date": "2021-04-12"
            },
            "idx": 0
          },
          {
            "Origin": {
              "name": "Innsbruck Terminal Marktplatz",
              "type": "ST",
              "id": "A=1@O=Innsbruck Terminal Marktplatz@X=11390304@Y=47266639@U=81@L=476439605@",
              "lon": 11.390304,
              "lat": 47.266639,
              "time": "17:18:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "Innsbruck Mühlauer Brücke",
              "type": "ST",
              "id": "A=1@O=Innsbruck Mühlauer Brücke@X=11403266@Y=47278828@U=81@L=476434003@",
              "lon": 11.403266,
              "lat": 47.278828,
              "time": "17:23:00",
              "date": "2021-04-12"
            },
            "idx": 1
          },
          {
            "Origin": {
              "name": "Innsbruck Mühlauer Brücke",
              "type": "ST",
              "id": "A=1@O=Innsbruck Mühlauer Brücke@X=11403266@Y=47278828@U=81@L=476434003@",
              "lon": 11.403266,
              "lat": 47.278828,
              "time": "17:23:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "Innsbruck Mühlauer Brücke",
              "type": "ST",
              "id": "A=1@O=Innsbruck Mühlauer Brücke@X=11402951@Y=47278801@U=81@L=476434001@",
              "lon": 11.402951,
              "lat": 47.278801,
              "time": "17:26:00",
              "date": "2021-04-12"
            },
            "idx": 2
          },
          {
            "Origin": {
              "name": "Innsbruck Mühlauer Brücke",
              "type": "ST",
              "id": "A=1@O=Innsbruck Mühlauer Brücke@X=11402951@Y=47278801@U=81@L=476434001@",
              "lon": 11.402951,
              "lat": 47.278801,
              "time": "17:26:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "Innsbruck Technologiezentrum Ost",
              "type": "ST",
              "id": "A=1@O=Innsbruck Technologiezentrum Ost@X=11435124@Y=47264670@U=81@L=476162202@",
              "lon": 11.435124,
              "lat": 47.26467,
              "time": "17:37:00",
              "date": "2021-04-12"
            },
            "idx": 3
          },
          {
            "Origin": {
              "name": "Innsbruck Technologiezentrum Ost",
              "type": "ST",
              "id": "A=1@O=Innsbruck Technologiezentrum Ost@X=11435124@Y=47264670@U=81@L=476162202@",
              "lon": 11.435124,
              "lat": 47.26467,
              "time": "17:37:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "47.265000, 11.441450",
              "type": "ADR",
              "id": "A=2@O=47.265000, 11.441450@l=@X=11441450@Y=47265000@u=0@",
              "lon": 11.44145,
              "lat": 47.265,
              "time": "17:43:00",
              "date": "2021-04-12"
            },
            "idx": 4
          }
        ]
      },
      "idx": 0
    },
    {
      "LegList": {
        "Leg": [
          {
            "Origin": {
              "name": "47.266450, 11.389962",
              "type": "ADR",
              "id": "A=2@O=47.266450, 11.389962@l=@X=11389962@Y=47266450@u=0@",
              "lon": 11.389962,
              "lat": 47.26645,
              "time": "17:16:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "Innsbruck Terminal Marktplatz",
              "type": "ST",
              "id": "A=1@O=Innsbruck Terminal Marktplatz@X=11390304@Y=47266639@U=81@L=476439605@",
              "lon": 11.390304,
              "lat": 47.266639,
              "time": "17:18:00",
              "date": "2021-04-12"
            },
            "idx": 0
          },
          {
            "Origin": {
              "name": "Innsbruck Terminal Marktplatz",
              "type": "ST",
              "id": "A=1@O=Innsbruck Terminal Marktplatz@X=11390304@Y=47266639@U=81@L=476439605@",
              "lon": 11.390304,
              "lat": 47.266639,
              "time": "17:18:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "Innsbruck Sillpark",
              "type": "ST",
              "id": "A=1@O=Innsbruck Sillpark@X=11403059@Y=47265488@U=81@L=476158902@",
              "lon": 11.403059,
              "lat": 47.265488,
              "time": "17:24:00",
              "date": "2021-04-12"
            },
            "idx": 1
          },
          {
            "Origin": {
              "name": "Innsbruck Sillpark",
              "type": "ST",
              "id": "A=1@O=Innsbruck Sillpark@X=11403059@Y=47265488@U=81@L=476158902@",
              "lon": 11.403059,
              "lat": 47.265488,
              "time": "17:24:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "Innsbruck Sillpark",
              "type": "ST",
              "id": "A=1@O=Innsbruck Sillpark@X=11403131@Y=47266639@U=81@L=476158904@",
              "lon": 11.403131,
              "lat": 47.266639,
              "time": "17:27:00",
              "date": "2021-04-12"
            },
            "idx": 2
          },
          {
            "Origin": {
              "name": "Innsbruck Sillpark",
              "type": "ST",
              "id": "A=1@O=Innsbruck Sillpark@X=11403131@Y=47266639@U=81@L=476158904@",
              "lon": 11.403131,
              "lat": 47.266639,
              "time": "17:30:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "Innsbruck Baggersee",
              "type": "ST",
              "id": "A=1@O=Innsbruck Baggersee@X=11442702@Y=47265632@U=81@L=476162302@",
              "lon": 11.442702,
              "lat": 47.265632,
              "time": "17:44:00",
              "date": "2021-04-12"
            },
            "idx": 3
          },
          {
            "Origin": {
              "name": "Innsbruck Baggersee",
              "type": "ST",
              "id": "A=1@O=Innsbruck Baggersee@X=11442702@Y=47265632@U=81@L=476162302@",
              "lon": 11.442702,
              "lat": 47.265632,
              "time": "17:44:00",
              "date": "2021-04-12"
            },
            "Destination": {
              "name": "47.265000, 11.441450",
              "type": "ADR",
              "id": "A=2@O=47.265000, 11.441450@l=@X=11441450@Y=47265000@u=0@",
              "lon": 11.44145,
              "lat": 47.265,
              "time": "17:46:00",
              "date": "2021-04-12"
            },
            "idx": 4
          }
        ]
      },
      "idx": 1
    }
  ]
}

Here is the result. Pay attention that there are double entries for origin and destination
of each subtrip.

{
  "@context": {
    "sh": "http://www.w3.org/ns/shacl#",
    "wasa": "https://vocab.sti2.at/wasa/",
    "vao": "https://vocab.sti2.at/vao/",
    "@vocab": "http://schema.org/"
  },
  "@id": "_:http%3A%2F%2Fmapping.example.com%2Fmap_action_000_1",
  "@type": "Action",
  "actionStatus": "http://schema.org/CompletedActionStatus",
  "result": [
    {
      "@id": "_:http%3A%2F%2Fmapping.example.com%2Fmap_result_000_1",
      "@type": "Trip",
      "arrivalTime": "17:16:00",
      "departureTime": "17:43:00",
      "name": "A trip from 47.266450, 11.389962 to 47.265000, 11.441450",
      "subTrip": [
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/0/leg/0",
          "arrivalTime": "17:18:00",
          "departureTime": "17:16:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Terminal%20Marktplatz%40X%3D11390304%40Y%3D47266639%40U%3D81%40L%3D476439605%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Terminal%20Marktplatz%40X%3D11390304%40Y%3D47266639%40U%3D81%40L%3D476439605%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D2%40O%3D47.266450%2C%2011.389962%40l%3D%40X%3D11389962%40Y%3D47266450%40u%3D0%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D2%40O%3D47.266450%2C%2011.389962%40l%3D%40X%3D11389962%40Y%3D47266450%40u%3D0%40"
            }
          ]
        },
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/0/leg/1",
          "arrivalTime": "17:23:00",
          "departureTime": "17:18:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20M%C3%BChlauer%20Br%C3%BCcke%40X%3D11403266%40Y%3D47278828%40U%3D81%40L%3D476434003%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Sillpark%40X%3D11403059%40Y%3D47265488%40U%3D81%40L%3D476158902%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Terminal%20Marktplatz%40X%3D11390304%40Y%3D47266639%40U%3D81%40L%3D476439605%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Terminal%20Marktplatz%40X%3D11390304%40Y%3D47266639%40U%3D81%40L%3D476439605%40"
            }
          ]
        },
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/0/leg/2",
          "arrivalTime": "17:26:00",
          "departureTime": "17:23:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20M%C3%BChlauer%20Br%C3%BCcke%40X%3D11402951%40Y%3D47278801%40U%3D81%40L%3D476434001%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Sillpark%40X%3D11403131%40Y%3D47266639%40U%3D81%40L%3D476158904%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20M%C3%BChlauer%20Br%C3%BCcke%40X%3D11403266%40Y%3D47278828%40U%3D81%40L%3D476434003%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Sillpark%40X%3D11403059%40Y%3D47265488%40U%3D81%40L%3D476158902%40"
            }
          ]
        },
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/0/leg/3",
          "arrivalTime": "17:37:00",
          "departureTime": "17:26:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Technologiezentrum%20Ost%40X%3D11435124%40Y%3D47264670%40U%3D81%40L%3D476162202%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Baggersee%40X%3D11442702%40Y%3D47265632%40U%3D81%40L%3D476162302%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20M%C3%BChlauer%20Br%C3%BCcke%40X%3D11402951%40Y%3D47278801%40U%3D81%40L%3D476434001%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Sillpark%40X%3D11403131%40Y%3D47266639%40U%3D81%40L%3D476158904%40"
            }
          ]
        },
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/0/leg/4",
          "arrivalTime": "17:43:00",
          "departureTime": "17:37:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D2%40O%3D47.265000%2C%2011.441450%40l%3D%40X%3D11441450%40Y%3D47265000%40u%3D0%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D2%40O%3D47.265000%2C%2011.441450%40l%3D%40X%3D11441450%40Y%3D47265000%40u%3D0%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Technologiezentrum%20Ost%40X%3D11435124%40Y%3D47264670%40U%3D81%40L%3D476162202%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Baggersee%40X%3D11442702%40Y%3D47265632%40U%3D81%40L%3D476162302%40"
            }
          ]
        }
      ],
      "vao:destination": {
        "@id": "https://verkehrsauskunftoesterreich.at/location/A%3D2%40O%3D47.265000%2C%2011.441450%40l%3D%40X%3D11441450%40Y%3D47265000%40u%3D0%40",
        "@type": "Place",
        "geo": {
          "@id": "http://verkehrsauskunftoesterreich.at/A%3D2%40O%3D47.265000%2C%2011.441450%40l%3D%40X%3D11441450%40Y%3D47265000%40u%3D0%40/geo",
          "@type": "GeoCoordinates",
          "latitude": "47.265",
          "longitude": "11.44145"
        },
        "name": "47.265000, 11.441450"
      },
      "vao:origin": {
        "@id": "https://verkehrsauskunftoesterreich.at/location/A%3D2%40O%3D47.266450%2C%2011.389962%40l%3D%40X%3D11389962%40Y%3D47266450%40u%3D0%40",
        "@type": "Place",
        "geo": {
          "@id": "http://adasd.com/A%3D2%40O%3D47.266450%2C%2011.389962%40l%3D%40X%3D11389962%40Y%3D47266450%40u%3D0%40/geo",
          "@type": "GeoCoordinates",
          "latitude": "47.26645",
          "longitude": "11.389962"
        },
        "name": "47.266450, 11.389962"
      }
    },
    {
      "@id": "_:http%3A%2F%2Fmapping.example.com%2Fmap_result_000_2",
      "@type": "Trip",
      "arrivalTime": "17:16:00",
      "departureTime": "17:46:00",
      "name": "A trip from 47.266450, 11.389962 to 47.265000, 11.441450",
      "subTrip": [
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/1/leg/0",
          "arrivalTime": "17:18:00",
          "departureTime": "17:16:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Terminal%20Marktplatz%40X%3D11390304%40Y%3D47266639%40U%3D81%40L%3D476439605%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Terminal%20Marktplatz%40X%3D11390304%40Y%3D47266639%40U%3D81%40L%3D476439605%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D2%40O%3D47.266450%2C%2011.389962%40l%3D%40X%3D11389962%40Y%3D47266450%40u%3D0%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D2%40O%3D47.266450%2C%2011.389962%40l%3D%40X%3D11389962%40Y%3D47266450%40u%3D0%40"
            }
          ]
        },
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/1/leg/1",
          "arrivalTime": "17:24:00",
          "departureTime": "17:18:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20M%C3%BChlauer%20Br%C3%BCcke%40X%3D11403266%40Y%3D47278828%40U%3D81%40L%3D476434003%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Sillpark%40X%3D11403059%40Y%3D47265488%40U%3D81%40L%3D476158902%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Terminal%20Marktplatz%40X%3D11390304%40Y%3D47266639%40U%3D81%40L%3D476439605%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Terminal%20Marktplatz%40X%3D11390304%40Y%3D47266639%40U%3D81%40L%3D476439605%40"
            }
          ]
        },
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/1/leg/2",
          "arrivalTime": "17:27:00",
          "departureTime": "17:24:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20M%C3%BChlauer%20Br%C3%BCcke%40X%3D11402951%40Y%3D47278801%40U%3D81%40L%3D476434001%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Sillpark%40X%3D11403131%40Y%3D47266639%40U%3D81%40L%3D476158904%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20M%C3%BChlauer%20Br%C3%BCcke%40X%3D11403266%40Y%3D47278828%40U%3D81%40L%3D476434003%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Sillpark%40X%3D11403059%40Y%3D47265488%40U%3D81%40L%3D476158902%40"
            }
          ]
        },
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/1/leg/3",
          "arrivalTime": "17:44:00",
          "departureTime": "17:30:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Technologiezentrum%20Ost%40X%3D11435124%40Y%3D47264670%40U%3D81%40L%3D476162202%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Baggersee%40X%3D11442702%40Y%3D47265632%40U%3D81%40L%3D476162302%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20M%C3%BChlauer%20Br%C3%BCcke%40X%3D11402951%40Y%3D47278801%40U%3D81%40L%3D476434001%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Sillpark%40X%3D11403131%40Y%3D47266639%40U%3D81%40L%3D476158904%40"
            }
          ]
        },
        {
          "@id": "http://verkehrstauskunftoesterreich.at/trip/1/leg/4",
          "arrivalTime": "17:46:00",
          "departureTime": "17:44:00",
          "vao:destination": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D2%40O%3D47.265000%2C%2011.441450%40l%3D%40X%3D11441450%40Y%3D47265000%40u%3D0%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D2%40O%3D47.265000%2C%2011.441450%40l%3D%40X%3D11441450%40Y%3D47265000%40u%3D0%40"
            }
          ],
          "vao:origin": [
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Technologiezentrum%20Ost%40X%3D11435124%40Y%3D47264670%40U%3D81%40L%3D476162202%40"
            },
            {
              "@id": "http://verkehrstauskunftoesterreich.at/location/A%3D1%40O%3DInnsbruck%20Baggersee%40X%3D11442702%40Y%3D47265632%40U%3D81%40L%3D476162302%40"
            }
          ]
        }
      ],
      "vao:destination": {
        "@id": "https://verkehrsauskunftoesterreich.at/location/A%3D2%40O%3D47.265000%2C%2011.441450%40l%3D%40X%3D11441450%40Y%3D47265000%40u%3D0%40",
        "@type": "Place",
        "geo": {
          "@id": "http://verkehrsauskunftoesterreich.at/A%3D2%40O%3D47.265000%2C%2011.441450%40l%3D%40X%3D11441450%40Y%3D47265000%40u%3D0%40/geo",
          "@type": "GeoCoordinates",
          "latitude": "47.265",
          "longitude": "11.44145"
        },
        "name": "47.265000, 11.441450"
      },
      "vao:origin": {
        "@id": "https://verkehrsauskunftoesterreich.at/location/A%3D2%40O%3D47.266450%2C%2011.389962%40l%3D%40X%3D11389962%40Y%3D47266450%40u%3D0%40",
        "@type": "Place",
        "geo": {
          "@id": "http://adasd.com/A%3D2%40O%3D47.266450%2C%2011.389962%40l%3D%40X%3D11389962%40Y%3D47266450%40u%3D0%40/geo",
          "@type": "GeoCoordinates",
          "latitude": "47.26645",
          "longitude": "11.389962"
        },
        "name": "47.266450, 11.389962"
      }
    }
  ]
}

The problem here is that the subtriporigin and subtripdestination mappings are joined with subtrip, but not with the trip mapping so for each trip there is an origin and destination in each subtrip. This happens because the idx value of a leg is only unique within a trip and there is no other property that can serve as a primary key. Is there a way to solve this? I was thinking about adding a second join condition like idx, ^^^^idx, basically joining the trip idx reached from each origin and destination. Would that work with the current implementation?

@sumutcan
Copy link
Author

could this be related to the multiple join condition support I saw in one of the issues in RML repo, @ThibaultGerrier?

@ThibaultGerrier
Copy link
Contributor

Hey Umut,

I understand the problem, since the items do not have any unique field, there is nothing to join.
I had the same problem with some other mappings, so I introduced the "PATH~" extension to jsonpath for rocketrml that returns the json-pointer (path) of a given element. Since the path of every element is unique you can use that to join. It is used like:

PATH~<jsonpath>

e.g. PATH~ returns path of current element, while PATH~^ returns path of parent.

In your case you could then be using:
- [vao:origin, {mapping: subTripOrigin, join: [PATH~, PATH~^]}]

So join whenever the path of the current element is the same as the path of the parent of the element from the subTripOrigin mapping are the same.

(you can also simply use it like - [schema:path, "$PATH~)"] to see the paths themselves, for debugging reasons)

However in this project there is a bug in the conversion of yarrrml+ (which allows this join: [idx, ^idx]} shorthand, which doesn't exist in yarrrml) to yarrrml. This transformation is regex based and does not include the tilde ~ symbol in its regex, so the transformation of join: [PATH~, PATH~^] will fail. So you'd have to use the traditional yarrrml join method:

- [vao:origin, {mapping: subTripOrigin, condition:{function:equal,parameters:[[str1,"$(PATH~)"],[str2,"$(PATH~^)"]]}}]

(same for destination)
With that your mapping should do what it is supposed to.

BTW you are missing some semi colons in the last 3 mappings:
- [a schema:Place] --> - [a, schema:Place]

@sumutcan
Copy link
Author

very cool, thanks! this PATH~ is something you invented or is it part of jsonpath+ ? I know there is the ~ operator for getting the property names but have not seen any PATH~ syntax.

@ThibaultGerrier
Copy link
Contributor

It's something I invented. jsonpath doesn't have such a feature, so i added it. It is also available for xml and csv mappings. In xml it also returns the path to the current node, while in csv it returns the line number. Xpath does have a built-in feature to return the path (path()), but only in newer xpath versions. The default xpath lib in rocketrml does not support that feature, since it only supports "old" xpath features, while if you choose the fontoxpath version, you can use that xpath path() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants