UTS-eResearch / ro-crate-js

Research Object Crate (RO-Crate) utilities
GNU General Public License v3.0
2 stars 5 forks source link

Error: "There is no pointer to the root dataset" #2

Closed marcolarosa closed 4 years ago

marcolarosa commented 4 years ago

I'm now seeing the above error when I wasn't a week or so ago and my templates haven't changed.

I'm using the feature/objectify branch and this is happening when I try to objectify a crate.

Here's an example:

{
    "@graph": [
        {
            "@id": "./",
            "@type": [
                "http://schema.org/Dataset",
                "http://pcdm.org/models#object"
            ],
            "http://paradisec.org.au/adminComment": "",
            "http://paradisec.org.au/bornDigital": "0",
            "http://paradisec.org.au/citeAs": "",
            "http://paradisec.org.au/contentLanguages": { "@id": "_:b0" },
            "http://paradisec.org.au/dialect": "",
            "http://paradisec.org.au/digitisedOn": "2006-02-02T13:00:00.000Z",
            "http://paradisec.org.au/discourseType": "",
            "http://paradisec.org.au/external": "0",
            "http://paradisec.org.au/ingestNotes": "A)  3 3/4ips, NAB eq, 1track of 1/2trk.  Field recordings, speech.  Some high-freq whistle, possibly from dub?\r\nLength: Side A: 0:19:07.\r\nB)  BLANK\r\n",
            "http://paradisec.org.au/languageAsGiven": "Luganda",
            "http://paradisec.org.au/originatedOn": "1958-12-23",
            "http://paradisec.org.au/originatedOnNarrative": "",
            "http://paradisec.org.au/private": "0",
            "http://paradisec.org.au/receivedOn": "",
            "http://paradisec.org.au/subjectLanguages": { "@id": "_:b1" },
            "http://schema.org/additionalType": "item",
            "http://schema.org/contentLocation": { "@id": "_:b2" },
            "http://schema.org/contentUrl": "./",
            "http://schema.org/contributor": [
                { "@id": "_:b4" },
                { "@id": "_:b6" },
                { "@id": "_:b8" }
            ],
            "http://schema.org/dateCreated": "2005-02-27T13:00:00.000Z",
            "http://schema.org/dateModified": "2018-04-05T05:30:59.000Z",
            "http://schema.org/description": "Luganda (Fr Kibéngere)\r\n\r\nside B: blank",
            "http://schema.org/hasPart": [
                { "@id": "AC1-001-A.mp3" },
                { "@id": "AC1-001-A.wav" },
                { "@id": "AC1-001-IMG_02.tif" },
                { "@id": "AC1-001-IMG_02.jpg" },
                { "@id": "AC1-001-IMG_01.tif" },
                { "@id": "AC1-001-IMG_01.jpg" },
                { "@id": "AC1-001-IMG_03.tif" },
                { "@id": "AC1-001-IMG_03.jpg" }
            ],
            "http://schema.org/identifier": [
                { "@id": "_:b10" },
                { "@id": "_:b11" },
                { "@id": "_:b12" },
                { "@id": "_:b13" },
                { "@id": "_:b14" },
                { "@id": "_:b15" }
            ],
            "http://schema.org/license": { "@id": "_:b16" },
            "http://schema.org/memberOf": { "@id": "/paradisec.org.au/AC1" },
            "http://schema.org/name": "Luganda (Fr Kibéngere)",
            "http://schema.org/publisher": { "@id": "_:b17" }
        },
        {
            "@id": "AC1-001-A.mp3",
            "@type": "http://schema.org/MediaObject",
            "http://schema.org/bitrate": "127727",
            "http://schema.org/contentSize": "18327680",
            "http://schema.org/dateCreated": "2005-02-27T13:00:00.000Z",
            "http://schema.org/dateModified": "2017-09-08T02:00:55.000Z",
            "http://schema.org/duration": "1147.93",
            "http://schema.org/encodingFormat": "audio/mpeg",
            "http://schema.org/name": "AC1-001-A.mp3"
        },
        {
            "@id": "AC1-001-A.wav",
            "@type": "http://schema.org/MediaObject",
            "http://schema.org/bitrate": "4609811",
            "http://schema.org/contentSize": "661449946",
            "http://schema.org/dateCreated": "2005-02-27T13:00:00.000Z",
            "http://schema.org/dateModified": "2017-09-08T02:01:13.000Z",
            "http://schema.org/duration": "1147.9",
            "http://schema.org/encodingFormat": "audio/x-wav",
            "http://schema.org/name": "AC1-001-A.wav"
        },
        {
            "@id": "AC1-001-IMG_01.jpg",
            "@type": "http://schema.org/MediaObject",
            "http://schema.org/bitrate": "",
            "http://schema.org/contentSize": "1157474",
            "http://schema.org/dateCreated": "2016-10-11T22:06:34.000Z",
            "http://schema.org/dateModified": "2016-10-12T15:00:26.000Z",
            "http://schema.org/duration": "",
            "http://schema.org/encodingFormat": "image/jpeg",
            "http://schema.org/name": "AC1-001-IMG_01.jpg"
        },
        {
            "@id": "AC1-001-IMG_01.tif",
            "@type": "http://schema.org/MediaObject",
            "http://schema.org/bitrate": "",
            "http://schema.org/contentSize": "29972116",
            "http://schema.org/dateCreated": "2016-10-11T22:06:33.000Z",
            "http://schema.org/dateModified": "2016-10-12T15:00:22.000Z",
            "http://schema.org/duration": "",
            "http://schema.org/encodingFormat": "image/tiff",
            "http://schema.org/name": "AC1-001-IMG_01.tif"
        },
        {
            "@id": "AC1-001-IMG_02.jpg",
            "@type": "http://schema.org/MediaObject",
            "http://schema.org/bitrate": "",
            "http://schema.org/contentSize": "1192048",
            "http://schema.org/dateCreated": "2016-10-11T22:03:26.000Z",
            "http://schema.org/dateModified": "2016-10-12T15:00:17.000Z",
            "http://schema.org/duration": "",
            "http://schema.org/encodingFormat": "image/jpeg",
            "http://schema.org/name": "AC1-001-IMG_02.jpg"
        },
        {
            "@id": "AC1-001-IMG_02.tif",
            "@type": "http://schema.org/MediaObject",
            "http://schema.org/bitrate": "",
            "http://schema.org/contentSize": "29971726",
            "http://schema.org/dateCreated": "2016-10-11T22:03:25.000Z",
            "http://schema.org/dateModified": "2016-10-12T15:00:13.000Z",
            "http://schema.org/duration": "",
            "http://schema.org/encodingFormat": "image/tiff",
            "http://schema.org/name": "AC1-001-IMG_02.tif"
        },
        {
            "@id": "AC1-001-IMG_03.jpg",
            "@type": "http://schema.org/MediaObject",
            "http://schema.org/bitrate": "",
            "http://schema.org/contentSize": "1206492",
            "http://schema.org/dateCreated": "2016-10-11T22:07:13.000Z",
            "http://schema.org/dateModified": "2016-10-12T15:00:34.000Z",
            "http://schema.org/duration": "",
            "http://schema.org/encodingFormat": "image/jpeg",
            "http://schema.org/name": "AC1-001-IMG_03.jpg"
        },
        {
            "@id": "AC1-001-IMG_03.tif",
            "@type": "http://schema.org/MediaObject",
            "http://schema.org/bitrate": "",
            "http://schema.org/contentSize": "29973228",
            "http://schema.org/dateCreated": "2016-10-11T22:07:12.000Z",
            "http://schema.org/dateModified": "2016-10-12T15:00:30.000Z",
            "http://schema.org/duration": "",
            "http://schema.org/encodingFormat": "image/tiff",
            "http://schema.org/name": "AC1-001-IMG_03.tif"
        },
        {
            "@id": "_:b0",
            "@type": "http://schema.org/Language",
            "http://schema.org/alternateName": "lug",
            "http://schema.org/name": "Ganda"
        },
        {
            "@id": "_:b1",
            "@type": "http://schema.org/Language",
            "http://schema.org/alternateName": "lug",
            "http://schema.org/name": "Ganda"
        },
        {
            "@id": "_:b10",
            "@type": "http://schema.org/PropertyValue",
            "http://schema.org/name": "domain",
            "http://schema.org/value": "paradisec.org.au"
        },
        {
            "@id": "_:b11",
            "@type": "http://schema.org/PropertyValue",
            "http://schema.org/name": "id",
            "http://schema.org/value": "/paradisec.org.au/AC1/001"
        },
        {
            "@id": "_:b12",
            "@type": "http://schema.org/PropertyValue",
            "http://schema.org/name": "hashId",
            "http://schema.org/value": "b75a47e81fd8b8de947bbc50bd8487e96b9ba9b0370107905f81d3632358a1156842a698df1320b18943359b771d8a049c4581754fa719058091a703b9ce1e35"
        },
        {
            "@id": "_:b13",
            "@type": "http://schema.org/PropertyValue",
            "http://schema.org/name": "itemIdentifier",
            "http://schema.org/value": "001"
        },
        {
            "@id": "_:b14",
            "@type": "http://schema.org/PropertyValue",
            "http://schema.org/name": "collectionIdentifier",
            "http://schema.org/value": "AC1"
        },
        {
            "@id": "_:b15",
            "@type": "http://schema.org/PropertyValue",
            "http://schema.org/name": "doi",
            "http://schema.org/value": "10.4225/72/56E97C3321C5D"
        },
        {
            "@id": "_:b16",
            "http://schema.org/description": "",
            "http://schema.org/name": "Open (subject to agreeing to PDSC access conditions)"
        },
        {
            "@id": "_:b17",
            "http://schema.org/identifier": "http://nla.gov.au/nla.party-593941",
            "http://schema.org/name": "University of Sydney"
        },
        {
            "@id": "_:b2",
            "@type": "http://schema.org/Place",
            "http://schema.org/geo": { "@id": "_:b3" },
            "http://schema.org/name": ""
        },
        {
            "@id": "_:b3",
            "@type": "http://schema.org/GeoShape",
            "http://schema.org/box": "31.03,-0.995 33.396,1.612"
        },
        {
            "@id": "_:b4",
            "@type": "http://schema.org/Role",
            "http://schema.org/contributor": { "@id": "_:b5" },
            "http://schema.org/name": "collector"
        },
        {
            "@id": "_:b5",
            "@type": "http://schema.org/Person",
            "http://schema.org/givenName": "Arthur",
            "http://schema.org/name": "Arthur Capell"
        },
        {
            "@id": "_:b6",
            "@type": "http://schema.org/Role",
            "http://schema.org/contributor": { "@id": "_:b7" },
            "http://schema.org/name": "operator"
        },
        {
            "@id": "_:b7",
            "@type": "http://schema.org/Person",
            "http://schema.org/givenName": "Frank",
            "http://schema.org/name": "Frank Davey"
        },
        {
            "@id": "_:b8",
            "@type": "http://schema.org/Role",
            "http://schema.org/contributor": { "@id": "_:b9" },
            "http://schema.org/name": "recorder"
        },
        {
            "@id": "_:b9",
            "@type": "http://schema.org/Person",
            "http://schema.org/givenName": "Arthur",
            "http://schema.org/name": "Arthur Capell"
        },
        {
            "@id": "ro-crate-metadata.jsonld",
            "@type": "http://schema.org/CreativeWork",
            "http://schema.org/about": { "@id": "./" },
            "http://schema.org/identifier": "ro-crate-metadata.jsonld",
            "http://schema.org/license": {
                "@id": "https://creativecommons.org/licenses/by-sa/3.0"
            }
        }
    ]
}

Note the last entry in the graph - isn't that the pointer to the root dataset?

marcolarosa commented 4 years ago

So it looks like lines 58 and 59 in lib/rocrate.js are the issue in that they don't handle the fully qualified properties. So, when I change those lines to:

58                 if (t === "http://schema.org/CreativeWork" && item.hasOwnProperty("http://schema.org/identifier")  && item['http://schema.org/identifier'] === this.defaults.roCrateMetadataID) {
 59                     this._rootId = item['http://schema.org/about']["@id"];

The pointer is identified. Thoughts?

The context is that when i write the templates, I use jsonld to flatten them but that's it. Should I also be compacting them to shorten those refs or is the rocrate library supposed to handle crates in that form?

marcolarosa commented 4 years ago

Ok - this is not an issue with the lib. I think what's happened is that (using an earlier version of jsonld) my crates were being compacted at the same time as they were flattened. Looking at the API for jsonld now it seems I need to flatten then compact the crates before writing them out.

You can close this ticket when you're ready.