Skip to content

Commit

Permalink
Make EML system attribute configurable in AppModel
Browse files Browse the repository at this point in the history
Fixes #441
  • Loading branch information
robyngit committed Aug 3, 2023
1 parent cf7f6a1 commit b10ff03
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/js/models/AppModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,21 @@ define(['jquery', 'underscore', 'backbone'],
* @since 2.13.0
*/
editorSchemaLocation: "https://eml.ecoinformatics.org/eml-2.2.0 https://eml.ecoinformatics.org/eml-2.2.0/eml.xsd",

/**
* The text to use for the eml system attribute. The system attribute
* indicates the data management system within which an identifier is in
* scope and therefore unique. This is typically a URL (Uniform Resource
* Locator) that indicates a data management system. All identifiers that
* share a system must be unique. In other words, if the same identifier
* is used in two locations with identical systems, then by definition the
* objects at which they point are in fact the same object.
* @type {string}
* @since x.x.x
* @link https://eml.ecoinformatics.org/schema/eml-resource_xsd#SystemType
* @link https://eml.ecoinformatics.org/schema/eml_xsd
*/
emlSystem: "knb",

/**
* This error message is displayed when the Editor encounters an error saving
Expand Down
6 changes: 5 additions & 1 deletion src/js/models/metadata/eml211/EML211.js
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,10 @@ define(['jquery', 'underscore', 'backbone', 'uuid',

/* Initialize the object XML for brand spankin' new EML objects */
createXML: function() {

let emlSystem = MetacatUI.appModel.get("emlSystem");
emlSystem = (!emlSystem || typeof emlSystem != "string") ? "knb" : emlSystem;

var xml = "<eml:eml xmlns:eml=\"https://eml.ecoinformatics.org/eml-2.2.0\"></eml:eml>",
eml = $($.parseHTML(xml));

Expand All @@ -2103,7 +2107,7 @@ define(['jquery', 'underscore', 'backbone', 'uuid',
eml.attr("xmlns:stmml", "http://www.xml-cml.org/schema/stmml-1.1");
eml.attr("xsi:schemaLocation", "https://eml.ecoinformatics.org/eml-2.2.0 https://eml.ecoinformatics.org/eml-2.2.0/eml.xsd");
eml.attr("packageId", this.get("id"));
eml.attr("system", "knb"); // We could make this configurable at some point
eml.attr("system", emlSystem);

// Add the dataset
eml.append(document.createElement("dataset"));
Expand Down

0 comments on commit b10ff03

Please sign in to comment.