From 43c3062527d69b7c6dc03994a19a2ad0cc451691 Mon Sep 17 00:00:00 2001 From: robyngit Date: Tue, 15 Oct 2024 17:13:23 -0400 Subject: [PATCH] Add input for canoncial dataset in EML editor - Add logic to identify the canonical dataset while parsing EML - Update the Annotations collection with the value in the canonical dataset input changes Issue #2542 --- src/js/models/metadata/eml211/EML211.js | 29 +++++++++++++++++++ .../templates/metadata/metadataOverview.html | 8 +++++ src/js/views/metadata/EML211View.js | 26 +++++++++++++---- 3 files changed, 58 insertions(+), 5 deletions(-) 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