diff --git a/src/js/models/metadata/eml211/EML211.js b/src/js/models/metadata/eml211/EML211.js index 65c2a69ff..5cebdb0aa 100644 --- a/src/js/models/metadata/eml211/EML211.js +++ b/src/js/models/metadata/eml211/EML211.js @@ -86,6 +86,7 @@ define([ methods: new EMLMethods(), // An EMLMethods objects project: null, // An EMLProject object, annotations: null, // Dataset-level annotations + canonicalDataset: null, dataSensitivityPropertyURI: "http://purl.dataone.org/odo/SENSO_00000005", nodeOrder: [ @@ -143,6 +144,13 @@ define([ this.set("synced", true); }); + this.stopListening(this, "change:canonicalDataset"); + this.listenTo( + this, + "change:canonicalDataset", + this.updateCanonicalDataset, + ); + //Create a Unit collection if (!this.units.length) this.createUnits(); }, @@ -160,6 +168,17 @@ define([ ); }, + updateCanonicalDataset() { + let uri = this.get("canonicalDataset"); + uri = uri?.length ? uri[0] : null; + let annotations = this.get("annotations"); + if (!annotations) { + annotations = new EMLAnnotations(); + this.set("annotations", annotations); + } + annotations.updateCanonicalDataset(uri); + }, + /* * Maps the lower-case EML node names (valid in HTML DOM) to the camel-cased EML node names (valid in EML). * Used during parse() and serialize() @@ -734,6 +753,16 @@ define([ } } + // Once all the nodes have been parsed, check if any of the annotations + // make up a canonical dataset reference + const annotations = modelJSON["annotations"]; + if (annotations) { + const canonicalDataset = annotations.getCanonicalURI(); + if (canonicalDataset) { + modelJSON["canonicalDataset"] = canonicalDataset; + } + } + return modelJSON; }, diff --git a/src/js/templates/metadata/metadataOverview.html b/src/js/templates/metadata/metadataOverview.html index a8f117c8b..9a8c46ace 100644 --- a/src/js/templates/metadata/metadataOverview.html +++ b/src/js/templates/metadata/metadataOverview.html @@ -94,3 +94,11 @@
Alternate Identifiers