Class: DataONEObject

DataONEObject()

A DataONEObject represents a DataONE object, such as a data file, a science metadata object, or a resource map. It stores the system metadata attributes for the object, performs updates to the system metadata, and other basic DataONE API functions. This model can be extended to provide specific functionality for different object types, such as the ScienceMetadata model and the EML211 model.

Constructor

new DataONEObject()

Source:

Extends

  • Backbone.Model

Methods

addToUploadQueue()

Updates the upload status attribute on this model and marks the collection as changed
Source:

bytesToSize()

Converts the number of bytes into a human readable format and updates the `sizeStr` attribute
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
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 Default Description
action string <optional>
changePermission 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.
Source:
Returns:
Type
boolean

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.
Source:
Returns:
- an AccessPolicy collection that represents the given XML or the default policy set in the AppModel.
Type
AccessPolicy

createSysMeta()

Build a fresh system metadata document for this object when it is new Return it as a DOM object
Source:

createViewURL() → {string}

Creates a URL for viewing more information about this object
Source:
Returns:
Type
string

downloadWithCredentials()

This method will download this object while sending the user's auth token in the request.
Source:
Returns:
None

fetch()

Overload Backbone.Model.fetch, so that we can set custom options for each fetch() request
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
Source:

formatXML(xml) → {string}

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
Source:
Returns:
The formatted XML string
Type
string

generateId() → {string}

Generate a unique identifier to be used as an XML id attribute
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:
  • 2.26.0
Source:
Returns:
- The canonical IRI for the DOI, or null if neither the seriesId nor the PID match a DOI regex.
Type
string | null

getFormat()

Looks up human readable format of the DataONE Object
Since:
  • 2.28.0
Source:
Returns:
format String

getFormatId()

Get the object format identifier for this object
Source:

getPackageURL()

Create the URL string that is used to download this package
Since:
  • 2.28.0
Source:
Returns:
PackageURL string for this DataONE Object

getType()

Returns a plain-english version of the general format - either image, program, metadata, PDF, annotation or data
Source:

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
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
Source:

hasUpdates() → {boolean}

Checks if this system metadata XML has updates that need to be synced with the server.
Source:
Returns:
Type
boolean

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
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.
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
Source:
Returns:
Type
boolean

isImage() → {boolean}

Checks the formatId of this model and determines if it is an image.
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)
Source:
Returns:
Type
boolean

isPDF() → {boolean}

Checks the formatId of this model and determines if it a PDF.
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.
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
Source:
Returns:
Type
boolean

nodeNameMap()

Maps the lower-case sys meta node names (valid in HTML DOM) to the camel-cased sys meta node names (valid in DataONE). Used during parse() and serialize()
Source:

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
Source:

parse()

This function is called by Backbone.Model.fetch. It deserializes the incoming XML from the /meta REST endpoint and converts it into JSON.
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
Source:

resetID()

Resets the identifier for this model. This undos all of the changes made in {DataONEObject#updateID}
Source:

save()

Saves the DataONEObject System Metadata to the server
Source:

serializeSysMeta() → {string}

Using the attributes set on this DataONEObject model, serializes the system metadata XML
Source:
Returns:
Type
string

setMissingFileName()

Creates a file name for this DataONEObject and updates the `fileName` attribute
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.
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
Source:

toJson()

A utility function for converting XML to JSON
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
Source:
Returns:
The updated HTML Element
Type
Element

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.
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
Source:

updateRelationships()

Updates the relationships with other models when this model has been updated
Source:

updateSysMeta()

Updates the DataONEObject System Metadata to the server
Source:

url() → {string}

Returns the URL string where this DataONEObject can be fetched from or saved to
Source:
Returns:
Type
string