Constructor
new EML211()
- Source:
Extends
Members
units
Get the units for the EML211 model.
- Source:
Methods
addAnnotation(attrs)
Creates and adds an
EMLAnnotation to this EML211 model with the
given annotation data in JSON form.
Parameters:
Name |
Type |
Description |
attrs |
object
|
The attribute data to set on the new
EMLAnnotation. See EMLAnnotation#defaults for details
on what attributes can be passed to the EMLAnnotation. In addition,
there is an `elementName` property.
Properties
Name |
Type |
Attributes |
Description |
elementName |
string
|
<optional>
|
The name of the EML
Element that this annotation should be applied to. e.g. dataset,
entity, attribute. Defaults to `dataset`. NOTE: Right now only dataset
annotations are supported until more annotation editing is added to the
EML Editor. |
allowDuplicates |
boolean
|
<optional>
|
If false, this
annotation will replace all annotations already set with the same
propertyURI. By default, more than one annotation with a given
propertyURI can be added (defaults to true) |
|
- Source:
addEntity(emlEntity, positionopt)
Add an entity into the entities collection
Parameters:
Name |
Type |
Attributes |
Description |
emlEntity |
EMLOtherEntity
|
object
|
|
The entity to add |
position |
number
|
<optional>
|
The position to add the entity at in the
entities array. If not provided, the entity will be added to the end. |
- Source:
addParty(partyModel, position) → {boolean}
Adds the given EMLParty model to this EML211 model in the appropriate
role array in the given position
Parameters:
Name |
Type |
Description |
partyModel |
EMLParty
|
The EMLParty model to add |
position |
number
|
The position in the role array in which to
insert this EMLParty |
- Source:
Returns:
- Returns true if the EMLParty was successfully
added, false if it was cancelled
-
Type
-
boolean
addTaxonomicCoverage(silentopt) → {Array.<EMLTaxonCoverage>|false}
Create a new taxon coverage model and add it to the EML model within an
array on the taxonCoverage attribute. If there is already a non-empty
array of taxon coverage models, this function will not add a new one
and will return false instead.
Parameters:
Name |
Type |
Attributes |
Description |
silent |
boolean
|
<optional>
|
Whether to suppress the change event when
adding the taxon coverage model to the EML model |
- Since:
- Source:
Returns:
- The new EMLTaxonCoverage model
that was added to the EML model, or false if a new model was not added
-
Type
-
Array.<EMLTaxonCoverage>
|
false
addToUploadQueue()
Updates the upload status attribute on this model and marks the collection as changed
- Inherited From:
- Source:
calculateChecksum(algorithmopt) → {string}
Calculate a checksum for the object
Parameters:
Name |
Type |
Attributes |
Description |
algorithm |
string
|
<optional>
|
The algorithm to use, defaults to MD5 |
- Inherited From:
- Source:
Returns:
A checksum plain JS object with value and algorithm attributes
-
Type
-
string
checkAuthority(actionopt, optionsopt) → {boolean}
Check if the current user is authorized to perform an action on this object. This function doesn't return
the result of the check, but it sends an XHR, updates this model, and triggers a change event.
Parameters:
Name |
Type |
Attributes |
Description |
action |
string
|
<optional>
|
The action (read, write, or changePermission) to check
if the current user has authorization to perform. By default checks for the highest level of permission. |
options |
object
|
<optional>
|
Additional options for this function. See the properties below. |
Properties:
Name |
Type |
Description |
options.onSuccess |
function
|
A function to execute when the checkAuthority API is successfully completed |
options.onError |
function
|
A function to execute when the checkAuthority API returns an error, or when no PID or SID can be found for this object. |
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
cleanUpXML(xmlString) → {string}
Replace elements named "source" with "sourced" due to limitations with
using $.parseHTML() rather than $.parseXML()
Parameters:
Name |
Type |
Description |
xmlString |
string
|
The XML string to make the replacement in |
- Source:
Returns:
The cleaned up XML string
-
Type
-
string
cleanXMLText(str) → {string}
Cleans up the given text so that it is XML-valid by escaping reserved
characters, trimming white space, etc.
Parameters:
Name |
Type |
Description |
str |
string
|
The string to clean up |
- Source:
Returns:
The cleaned up string
-
Type
-
string
createAccessPolicy(accessPolicyXMLopt) → {AccessPolicy}
Create an access policy for this DataONEObject using the default access
policy set in the AppModel.
Parameters:
Name |
Type |
Attributes |
Description |
accessPolicyXML |
Element
|
<optional>
|
An XML node
that contains a list of access rules. |
- Inherited From:
- Source:
Returns:
- an AccessPolicy collection that represents the
given XML or the default policy set in the AppModel.
-
Type
-
AccessPolicy
createEntity(dataONEObject) → {EMLOtherEntity}
Create an entity model for a given DataONEObject model and add it to the
entities collection
Parameters:
Name |
Type |
Description |
dataONEObject |
DataONEObject
|
The DataONEObject model to create
an entity for |
- Source:
Returns:
The entity model created
-
Type
-
EMLOtherEntity
Build a fresh system metadata document for this object when it is new
Return it as a DOM object
- Inherited From:
- Source:
createTextCopy() → {string}
Creates a text copy of the EML211 model
- Source:
Returns:
The text copy of the EML211 model
-
Type
-
string
createUnits()
Fetches the units for this EML211 model
- Source:
createViewURL() → {string}
Creates a URL for viewing more information about this object
- Inherited From:
- Source:
Returns:
-
Type
-
string
createXML() → {string}
Initialize the object XML for brand spankin' new EML objects
- Source:
Returns:
The initial XML string
-
Type
-
string
defaults() → {object}
Get the default attributes for the EML211 model.
- Source:
Returns:
The default attributes for the EML211 model.
-
Type
-
object
dereference(xmlString) → {string}
Dereference "reference" elements and replace them with a cloned copy of
the referenced content
Parameters:
Name |
Type |
Description |
xmlString |
string
|
The XML string with reference elements to
transform |
- Source:
Returns:
The transformed XML string
-
Type
-
string
downloadWithCredentials()
This method will download this object while
sending the user's auth token in the request.
- Inherited From:
- Source:
Returns:
None
fetch(optionsopt) → {xhr}
Fetch the EML from the MN object service
Parameters:
Name |
Type |
Attributes |
Description |
options |
object
|
<optional>
|
A set of options for this fetch()
Properties
Name |
Type |
Attributes |
Description |
systemMetadataOnly |
boolean
|
<optional>
|
If true, only
the system metadata will be fetched. If false, the system metadata AND
EML document will be fetched. |
|
- Overrides:
- Source:
Returns:
The jqXHR object created by the fetch request
-
Type
-
xhr
Sends an AJAX request to fetch the system metadata for this EML object.
Will not trigger a sync event since it does not use
Backbone.Model.fetch. Triggers a custom "sysMetaUpdated" event instead.
Parameters:
Name |
Type |
Description |
options |
object
|
options for the AJAX request
Properties
Name |
Type |
Description |
success |
function
|
The success callback function |
error |
function
|
The error callback function |
|
- Since:
- Source:
findLatestVersion(latestVersionopt, possiblyNeweropt)
Finds the latest version of this object by travesing the obsolescence chain
Parameters:
Name |
Type |
Attributes |
Description |
latestVersion |
string
|
<optional>
|
The identifier of the latest known object in the version chain.
If not supplied, this model's `id` will be used. |
possiblyNewer |
string
|
<optional>
|
The identifier of the object that obsoletes the latestVersion. It's "possibly" newer, because it may be private/inaccessible |
- Inherited From:
- Source:
A utility function that will format an XML string or XML nodes by camel-casing the node names, as necessary
Parameters:
Name |
Type |
Description |
xml |
string
|
Element
|
The XML to format |
- Inherited From:
- Source:
Returns:
The formatted XML string
-
Type
-
string
generateId() → {string}
Generate a unique identifier to be used as an XML id attribute
- Inherited From:
- Source:
Returns:
The identifier string that was generated
-
Type
-
string
getCanonicalDOIIRI() → {string|null}
Check if the seriesID or PID matches a DOI regex, and if so, return
a canonical IRI for the DOI.
- Since:
- Inherited From:
- Source:
Returns:
- The canonical IRI for the DOI, or null if
neither the seriesId nor the PID match a DOI regex.
-
Type
-
string
|
null
getDataSensitivity() → {Array.<EMLAnnotation>}
Finds annotations that are of the `data sensitivity` property from the
NCEAS SENSO ontology. Returns undefined if none are found. This
function returns EMLAnnotation models because the data sensitivity is
stored in the EML Model as EMLAnnotations and added to EML as semantic
annotations.
- Source:
Returns:
An array of EMLAnnotation models that are of
the `data sensitivity` property from the NCEAS SENSO ontology.
-
Type
-
Array.<EMLAnnotation>
getEMLPosition(eml, nodeName) → {jQuery|false}
Returns the node in the given EML document that the given node type
should be inserted after
Parameters:
Name |
Type |
Description |
eml |
jQuery
|
The EML document to search within |
nodeName |
string
|
The name of the node type to find |
- Source:
Returns:
Returns false if either the node is not found
in the document or if the node is not a valid EML node.
-
Type
-
jQuery
|
false
getEntity(dataONEObj) → {EMLOtherEntity|false}
Find the entity model for a given DataONEObject model
Parameters:
Name |
Type |
Description |
dataONEObj |
DataONEObject
|
The DataONEObject model to find an
entity for |
- Source:
Returns:
The entity model for the given
DataONEObject model or false if not found
-
Type
-
EMLOtherEntity
|
false
Looks up human readable format of the DataONE Object
- Since:
- Inherited From:
- Source:
Returns:
format String
Get the object format identifier for this object
- Inherited From:
- Source:
getPackageURL()
Create the URL string that is used to download this package
- Since:
- Inherited From:
- Source:
Returns:
PackageURL string for this DataONE Object
getPartiesByType(partyType) → {Array}
getPartiesByType - Gets an array of EMLParty members that have a
particular party type or role.
Parameters:
Name |
Type |
Description |
partyType |
string
|
A string that represents either the role or
the party type. For example, "contact", "creator",
"principalInvestigator", etc. |
- Since:
- Source:
Returns:
- An array of EMLParty models that match the given
party type or role.
-
Type
-
Array
getType()
Returns a plain-english version of the general format - either image, program, metadata, PDF, annotation or data
- Inherited From:
- Source:
getUniqueEntityId(dataONEObject) → {string}
Creates an XML-safe identifier that is unique to this EML document,
based on the given DataONEObject model. It is intended for EML entity
nodes in particular.
Parameters:
Name |
Type |
Description |
dataONEObject |
DataONEObject
|
a DataONEObject model that this
EML documents |
- Source:
Returns:
- an identifier string unique to this EML document
-
Type
-
string
getXMLSafeID(idopt) → {string}
Converts the identifier string to a string safe to use in an XML id attribute
Parameters:
Name |
Type |
Attributes |
Description |
id |
string
|
<optional>
|
The ID string |
- Inherited From:
- Source:
Returns:
- The XML-safe string
-
Type
-
string
handleChange(modelopt, options)
Set the changed flag on any system metadata or content attribute changes,
and set the hasContentChanges flag on content changes only
Parameters:
Name |
Type |
Attributes |
Description |
model |
DataONEObject
|
<optional>
|
|
options |
object
|
|
Furhter options for this function |
Properties:
Name |
Type |
Description |
options.force |
boolean
|
If true, a change will be handled regardless if the attribute actually changed |
- Inherited From:
- Source:
hasTaxonomicCoverage() → {boolean}
Checks if there is at least one taxon coverage model in the EML model
- Since:
- Source:
Returns:
- True if there is at least one taxon coverage model
in the EML model
-
Type
-
boolean
hasUpdates() → {boolean}
Checks if this model has updates that need to be synced with the
server.
- Overrides:
- Source:
Returns:
True if there are updates to sync, false otherwise.
-
Type
-
boolean
initialize()
- Source:
isDOI(customString) → {boolean}
Checks if the pid or sid or given string is a DOI
Parameters:
Name |
Type |
Description |
customString |
string
|
Optional. An identifier string to check instead of the id and seriesId attributes on the model |
- Inherited From:
- Source:
Returns:
True if it is a DOI
-
Type
-
boolean
isData() → {boolean}
Checks the formatId of this model and determines if it is a data file.
This determination is mostly used for display and the provenance editor. In the
DataONE API, many formatIds are considered `DATA` formatTypes, but they are categorized
as images
DataONEObject#isImage or software
DataONEObject#isSoftware.
- Inherited From:
- Source:
Returns:
true if this data object is a data file, false if it is other
-
Type
-
boolean
isDerivationField(field) → {boolean}
Returns true if this provenance field points to a derivation of this data or metadata object
Parameters:
Name |
Type |
Description |
field |
string
|
|
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
isImage() → {boolean}
Checks the formatId of this model and determines if it is an image.
- Inherited From:
- Source:
Returns:
true if this data object is an image, false if it is other
-
Type
-
boolean
isNew() → {boolean}
Returns true if this DataONE object is new. A DataONE object is new
if there is no upload date and it's been synced (i.e. been fetched)
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
isPDF() → {boolean}
Checks the formatId of this model and determines if it a PDF.
- Inherited From:
- Source:
Returns:
true if this data object is a pdf, false if it is other
-
Type
-
boolean
isSoftware() → {boolean}
Checks the formatId of this model and determines if it is a software file.
This determination is mostly used for display and the provenance editor. In the
DataONE API, many formatIds are considered `DATA` formatTypes, but they are categorized
as images
DataONEObject#isImage for display purposes.
- Inherited From:
- Source:
Returns:
true if this data object is a software file, false if it is other
-
Type
-
boolean
isSourceField(field) → {boolean}
Returns true if this provenance field points to a source of this data or metadata object
Parameters:
Name |
Type |
Description |
field |
string
|
|
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
isValidYearDate(value) → {boolean}
Returns a boolean for whether the argument 'value' is a valid value for
EML's yearDate type which is used in a few places. Note that this
method considers a zero-length String to be valid because the
EML211.serialize() method will properly handle a null or zero-length
String by serializing out the current year.
Parameters:
Name |
Type |
Description |
value |
string
|
The value to test. |
- Source:
Returns:
True if the value is a valid yearDate, false
otherwise.
-
Type
-
boolean
movePartyDown(partyModel)
Attempt to move a party one index forward within its sibling models
Parameters:
Name |
Type |
Description |
partyModel |
EMLParty
|
The EMLParty model we're moving |
- Source:
movePartyUp(partyModel)
Attempt to move a party one index forward within its sibling models
Parameters:
Name |
Type |
Description |
partyModel |
EMLParty
|
The EMLParty model we're moving |
- Source:
nodeNameMap() → {object}
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()
- Overrides:
- Source:
Returns:
A mapping of lower-case EML node names to camel-cased
EML node names.
-
Type
-
object
onSuccessfulSave(modelopt, responseopt, xhropt)
This function is executed when the XHR that saves this DataONEObject has
successfully completed. It can be called directly if a DataONEObject is saved
without directly using the DataONEObject.save() function.
Parameters:
Name |
Type |
Attributes |
Description |
model |
DataONEObject
|
<optional>
|
A reference to this DataONEObject model |
response |
XMLHttpRequest.response
|
<optional>
|
The XHR response object |
xhr |
XMLHttpRequest
|
<optional>
|
The XHR that was just completed successfully |
- Inherited From:
- Source:
parse(response)
This function is called by Backbone.Model.fetch.
It deserializes the incoming XML from the /meta REST endpoint and converts it into JSON.
Parameters:
Name |
Type |
Description |
response |
|
|
- Overrides:
- Source:
removeEntity(emlEntity)
Remove an entity from the entities collection
Parameters:
- Source:
Removes nodes from the EML that do not have an accompanying model (Were
probably removed from the EML by the user during editing)
Parameters:
Name |
Type |
Description |
nodes |
jQuery
|
The EML nodes to check. |
models |
Array
|
The array of models to compare against. |
- Source:
removeParty(partyModel)
removeParty - removes the given EMLParty model from this EML211 model's
attributes
Parameters:
Name |
Type |
Description |
partyModel |
EMLParty
|
The EMLParty model to remove |
- Source:
removeWhiteSpaceFromSolrFields(json)
Removes white space from string values returned by Solr when the white space causes issues.
For now this only effects the `resourceMap` field, which will index new line characters and spaces
when the RDF XML has those in the `identifier` XML element content. This was causing bugs where DataONEObject
models were created with `id`s with new line and white space characters (e.g. `\n urn:uuid:1234...`)
Parameters:
Name |
Type |
Description |
json |
object
|
The Solr document as a JS Object, which will be directly altered |
- Inherited From:
- Source:
resetID()
Resets the identifier for this model. This undos all of the changes made in {DataONEObject#updateID}
- Inherited From:
- Source:
save(attributes, options) → {boolean|null|xhr}
Saves the EML document to the server using the DataONE API
Parameters:
Name |
Type |
Description |
attributes |
object
|
Model attributes to save. |
options |
object
|
Options for the save operation. |
- Overrides:
- Source:
Returns:
False if the model is invalid, null if the
save operation is in progress, or the XHR object if the save operation
is successful.
-
Type
-
boolean
|
null
|
xhr
serialize() → {string}
Retrieves the model attributes and serializes into EML XML, to produce
the new or modified EML document. Returns the EML XML as a string.
- Source:
Returns:
The EML XML as a string.
-
Type
-
string
serializeKeywords(eml)
Serializes the keywords for the EML document.
Parameters:
Name |
Type |
Description |
eml |
jQuery
|
The EML DOM to update. |
- Source:
serializeParties(eml, type)
Given an EML DOM and party type, this function updated and/or adds the
EMLParties to the EML
Parameters:
Name |
Type |
Description |
eml |
jQuery
|
The EML DOM to update. |
type |
string
|
The type of party to update (e.g. "creator",
"contact"). |
- Source:
Using the attributes set on this DataONEObject model, serializes the system metadata XML
- Inherited From:
- Source:
Returns:
-
Type
-
string
setFileName()
Uses the EML `title` to set the `fileName` attribute on this model
- Source:
setMissingFileName()
Creates a file name for this DataONEObject and updates the `fileName` attribute
- Inherited From:
- Source:
setPossibleAuthMNs()
Creates an array of objects that represent Member Nodes that could possibly be this
object's authoritative MN. This function updates the `possibleAuthMNs` attribute on this model.
- Inherited From:
- Source:
setProvClass(className)
Set the DataONE ProvONE provenance class
param className - the shortened form of the actual classname value. The
shortname will be appened to the ProvONE namespace, for example,
the className "program" will result in the final class name
"http://purl.dataone.org/provone/2015/01/15/ontology#Program"
see https://github.com/DataONEorg/sem-prov-ontologies/blob/master/provenance/ProvONE/v1/provone.html
Parameters:
Name |
Type |
Description |
className |
string
|
|
- Inherited From:
- Source:
setSchemaLocation(eml) → {Element}
Sets the xsi:schemaLocation attribute on the passed-in Element
depending on the application configuration.
Parameters:
Name |
Type |
Description |
eml |
Element
|
The root eml:eml element to modify |
- Source:
Returns:
The element, possibly modified
-
Type
-
Element
toJson(xml)
A utility function for converting XML to JSON
Parameters:
Name |
Type |
Description |
xml |
|
|
- Inherited From:
- Source:
toXML(json, containerNode) → {Element}
Serialize the DataONE object JSON to XML
Parameters:
Name |
Type |
Description |
json |
object
|
the JSON object to convert to XML |
containerNode |
Element
|
an HTML element to insertt the resulting XML into |
- Inherited From:
- Source:
Returns:
The updated HTML Element
-
Type
-
Element
trickleUpChange()
Triggers a change event on the model and all its parents.
- Source:
updateCanonicalDataset()
Update the canonoical dataset URI in the annotations collection to
match the canonicalDataset value on this model.
- Source:
updateID(id)
Update identifiers for this object
Parameters:
Name |
Type |
Description |
id |
string
|
Optional identifier to update with. Generated
automatically when not given.
Note that this method caches the objects attributes prior to
updating so this.resetID() can be called in case of a failure
state.
Also note that this method won't run if theh oldPid attribute is
set. This enables knowing before this.save is called what the next
PID will be such as the case where we want to update a matching
EML entity when replacing files. |
- Inherited From:
- Source:
updateProgress(e)
Updates the progress percentage when the model is getting uploaded
Parameters:
Name |
Type |
Description |
e |
ProgressEvent
|
The ProgressEvent when this file is being uploaded |
- Inherited From:
- Source:
updateRelationships()
Updates the relationships with other models when this model has been updated
- Inherited From:
- Source:
Updates the DataONEObject System Metadata to the server
- Inherited From:
- Source:
url() → {string}
Returns the URL string where this DataONEObject can be fetched from or saved to
- Overrides:
- Source:
Returns:
-
Type
-
string
validate() → {boolean|object}
Checks if this EML model has all the required values necessary to save
to the server
- Source:
Returns:
True if the model is valid, or an object
containing validation errors.
-
Type
-
boolean
|
object