trompamusic / ce-api

The Contributor Environment API for the TROMPA project
https://trompamusic.eu
Apache License 2.0
6 stars 1 forks source link

make ItemList json-ld render as an ldp:Container #175

Closed alastair closed 3 years ago

alastair commented 3 years ago

Lists of things in solid pods are stored as ldp containers. For simplicity in interoperability, it would be good if ItemLists, when serialised as json-ld would also look like ldp containers. To do this, make them also have the types ldp:BasicContainer and ldp:Container (ldp: http://www.w3.org/ns/ldp#).

ldp containers list the items contained in them at ldp:contains. This means we have to duplicate the members at ldp:contains and schema.org/item:

{
  "@context": { 
    "ldp": "http://www.w3.org/ns/ldp#",
    "schema": "http://schema.org"
  },
  "@id": "http://foo.bar/baz", 
  "@type": ["ldp:Container", "ldp:BasicContainer", "schema:ItemList"],
  "ldp:contains": [{"@id": "http://my.item/quux"}],
  "schema:item": [{"@id": "http://my.item/quux"}]
}

playground

alastair commented 3 years ago

I had hoped to implement this by adding another item to the types list for a field, e.g. https://github.com/trompamusic/ce-api/blob/24270a1f4d65bd3cc34a12b8dca0b9372454b34a/src/routes/helpers/jsonld/ItemList.json#L25-L28

however, this doesn't appear to work if I add two types to the definition for itemListElement. It's possible that there's some alternative logic when mapping relations which isn't working here. Need to look into why

alastair commented 3 years ago

ItemLists now look like this:

{
  "@context": [
    "https://schema.org",
    {
      "dc": "http://purl.org/dc/terms/",
      "prov": "http://www.w3.org/ns/prov#",
      "skos": "http://www.w3.org/2004/02/skos/core#",
      "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
      "bib": "https://bib.schema.org/",
      "trompa": "https://vocab.trompamusic.eu/vocab#",
      "ldp": "http://www.w3.org/ns/ldp#"
    }
  ],
  "@type": [
    "https://schema.org/ItemList",
    "http://www.w3.org/ns/ldp#Container",
    "http://www.w3.org/ns/ldp#BasicContainer"
  ],
  "dc:description": "foo",
  "description": "foo",
  "itemListElement": [
    {
      "@id": "http://localhost:4000/bfbb7ff2-ffbd-4b3e-bee8-a7cb0ffd560b"
    }
  ],
  "ldp:contains": [
    {
      "@id": "http://localhost:4000/bfbb7ff2-ffbd-4b3e-bee8-a7cb0ffd560b"
    }
  ],
  "dc:modified": "2021-04-10T22:53:17.482000000Z",
  "dc:identifier": "bb4c3e4b-2c5b-415d-be98-1e5cd89c24b7",
  "identifier": "bb4c3e4b-2c5b-415d-be98-1e5cd89c24b7",
  "dc:created": "2021-04-10T22:47:44.756000000Z",
  "name": "thelist"
}