Class: CitationModel

CitationModel()

A Citation Model represents a single Citation Object returned by the metrics-service. A citation model can alternatively be populated with a SolrResultsModel or a DataONEObjectModel, or an extension of either of those models. A Citation Model can represent a citation to a local MetacatUI object, or an external document or publication.

Extends

  • Backbone.Model

Members

defaults :Object

The default Citation fields
Type:
  • Object
Properties:
Name Type Description
origin string text of authors who published the source dataset / document / article
originArray Array.<string> array of authors who published the source dataset / document / article. Same as origin, but split on commas and trimmed.
title string Title of the source dataset / document / article
year_of_publishing number Year in which the source dataset / document / article was published
source_url string URL to the source dataset / document / article. This is usually an external publication that cites one or more DataONE datasets.
source_id string Unique identifier for the source dataset / document / article that cited the target dataset. This is usually an external publication that cites one or more DataONE datasets.
target_id string Unique identifier to the target DATAONE dataset. This is the dataset that was cited by the "source" document.
publisher string Publisher for the source dataset / document / article
journal string The journal where the the document was published
volume number | string The volume of the journal where the document was published
page number The page of the journal where the document was published
citationMetadata Citations When this Citation Model refers to an external document, citationMetadata is a collection of DataONE datasets that the external document cites. This info is retrieved by the metrics service, then parsed and stored as a collection of Citation Models. This attribute is used in the Portals view, for example, where we display a list of external publications that cite the portal data. In this case, each publication's citationMetadata is the list of local MetacatUI data packages cited in the publication.
sourceModel Backbone.Model The model to use to populate this citation model. This can be a SolrResultsModel, a DataONEObjectModel, or an extension of either of those models. Do not set this attribute directly. Instead, use the setSourceModel() method.
pid string The pid or unique identifier of the object being cited.
seriesId string The seriesId of the object being cited
view_url string For citations that are in the local MetacatUI repository, this is the URL to the metadata view page for the object being cited.
pid_url string If the pid is a DOI, then this is the URL to the DOI landing page for the object being cited. This will automatically be set when the pid attribute is set.
seriesId_url string If the seriesId is a DOI, then this is the URL to the DOI landing page for the object being cited. This will automatically be set when the seriesId attribute is set.
Source:

type :string

The name of this type of model
Type:
  • string
Source:

Methods

DOItoURL(stropt) → {string}

Get the URL for the online location of the object being cited when it has a DOI. If the DOI is not passed to the function, or if the string is not a DOI, then an empty string is returned.
Parameters:
Name Type Attributes Description
str string <optional>
The DOI string with or without the "doi:" prefix. It may already be a URL, or it may be a DOI string. It also handles the case where the DOI is already a URL.
Since:
  • 2.23.0
Source:
Returns:
- The DOI URL
Type
string

URLtoDOI(url) → {string}

Get the DOI from a DOI URL. The URL can be http or https, can include the "doi:" prefix or not, and can use "dx.doi.org" or "doi.org" as the domain. If a string is not passed to the function, or if the string is not for a DOI URL, then an empty string is returned.
Parameters:
Name Type Description
url string The DOI URL
Since:
  • 2.23.0
Source:
Returns:
- The DOI string, including the "doi:" prefix
Type
string

archivedContentIsIndexed() → {boolean}

Checks if archived content is available in the search index.
Since:
  • 2.23.0
Source:
See:
  • AppModel#archivedContentIsIndexed
Returns:
- True if archived content is available in the search index.
Type
boolean

attrGetters() → {Object}

Get the attribute getters for this model. "Attribute getters" are functions that return the value of an attribute for this Citation Model given a source model. The source model can be a SolrResultsModel, a DataONEObjectModel, or an extension of either of those models.
Source:
Returns:
- An object that maps the name of the CitationModel attribute to the function that returns the value for that attribute.
Type
Object

findDOI() → {string}

Checks if the citation has a DOI in the seriesId or pid attributes.
Since:
  • 2.23.0
Source:
Returns:
- The DOI of the seriesID, if it is a DOI, or the DOI of the pid, if it is a DOI. Otherwise, returns null.
Type
string

formatAuthor(author) → {string}

Format an individual author for display within a citation.
Parameters:
Name Type Description
author string | EMLParty The author to format
Source:
Returns:
Returns the author as a string if it was an EMLParty with any incorrectly escaped characters corrected.
Type
string

formatMetricsServiceString(str) → {string}

Cleans up the metrics service string for display within a citation. Replaces "NULL" with an empty string, removes a period from the end of the string if it exists, removes curly braces, and trims whitespace.
Parameters:
Name Type Description
str string The metrics service string to format
Since:
  • 2.23.0
Source:
Returns:
Returns the metrics service string with "NULL" replaced with an empty string.
Type
string

formatTitle(title) → {string}

Cleans up the title for display within a citation. Removes a period from the end of the title if it exists and trims whitespace.This method is called any time a title is set on the Citation model.
Parameters:
Name Type Description
title string The title to format
Since:
  • 2.23.0
Source:
Returns:
Returns the title with a period removed from the end if it exists.
Type
string

getID() → {string}

Get the main identifier for the citation. This will check the model for the following attributes and return the first that is not empty: pid, seriesId, source_url.
Since:
  • 2.23.0
Source:
Returns:
Returns the main identifier for the citation or an empty string.
Type
string

getJournalFromSourceModel(sourceModel) → {String}

Get the journal (datasource/node) from the sourceModel. If there is a datasource attribute on the sourceModel, then get the name of the member node that has that datasource ID. If we can't find a member node that matches the datasource, then check if the datasource is the current node. If it is, then use the repository name. If there is no datasource attribute, then use the current member node's name.
Parameters:
Name Type Description
sourceModel Backbone.Model The model to get the journal from
Since:
  • 2.23.0
Source:
Returns:
- The journal
Type
String

getOriginArrayFromSourceModel(sourceModel) → {Array}

Get the array of authors ("origin") from the sourceModel. First look for creator (EML), then origin (science metadata & solr results), then rightsHolder & submitter (base D1 object model). Convert EML parties to strings & check for incorrectly escaped characters.
Parameters:
Name Type Description
sourceModel Backbone.Model The model to get the originArray from
Since:
  • 2.23.0
Source:
Returns:
- The originArray
Type
Array

getPidFromSourceModel(sourceModel) → {String}

Get the pid from the sourceModel. First look for id, then identifier.
Parameters:
Name Type Description
sourceModel Backbone.Model The model to get the pid from
Since:
  • 2.23.0
Source:
Returns:
- The pid
Type
String

getSeriesIdFromSourceModel(sourceModel) → {String}

Get the seriesId from the sourceModel. Simply looks for the seriesId attribute.
Parameters:
Name Type Description
sourceModel Backbone.Model The model to get the seriesId from
Since:
  • 2.23.0
Source:
Returns:
- The seriesId
Type
String

getTitleFromSourceModel(sourceModel) → {String}

Get the title from the sourceModel
Parameters:
Name Type Description
sourceModel Backbone.Model The model to get the title from
Since:
  • 2.23.0
Source:
Returns:
- The title
Type
String

getURL() → {string}

Get the URL for the citation. This will check the model for the following attributes and return the first that is not empty: view_url, source_url, sid_url, pid_url.
Since:
  • 2.23.0
Source:
Returns:
Returns the URL for the citation or an empty string.
Type
string

getUploadStatus() → {string}

If this citation has a source model, and if that source model is a DataONEObject, then return the results of the DataONEObject's `getUploadStatus` function
Since:
  • 2.23.0
Source:
See:
  • DataONEObject#getUploadStatus
Returns:
- The upload status of the source model, if it is a DataONEObject, or null if it is not.
Type
string

getViewUrlFromSourceModel(sourceModel) → {String}

Use the sourceModel's createViewURL() method to get the viewUrl for the citation. This method is built into DataONEObject models, SolrResult models, as well as Portal models. If the sourceModel doesn't have a createViewURL() method, then use the default viewUrl (null)
Parameters:
Name Type Description
sourceModel Backbone.Model The model to get the viewUrl from
Since:
  • 2.23.0
Source:
Returns:
- The viewUrl, or null if the sourceModel doesn't have a createViewURL() method.
Type
String

getYearFromSourceModel(sourceModel) → {Number}

Get the year from the sourceModel. First look for pubDate, then dateUploaded (both in SolrResult & ScienceMetadata/EML models). Lastly check datePublished (found in ScienceMetadata/EML models only.)
Parameters:
Name Type Description
sourceModel Backbone.Model The model to get the year from
Since:
  • 2.23.0
Source:
Returns:
- The year
Type
Number

hasDOI() → {boolean}

Checks if the citation has a DOI in the seriesId or pid attributes.
Since:
  • 2.23.0
Source:
Returns:
- True if the citation has a DOI
Type
boolean

isArchived() → {boolean}

Checks if the object being cited is archived, according to the `archived` attribute of the source model.
Since:
  • 2.23.0
Source:
Returns:
- True if the source model has an `archived` attribute that is true.
Type
boolean

isArchivedAndNotIndexed() → {boolean}

Returns true if the citation is for a DataONE object that has been archived and archived content is not available in the search index.
Since:
  • 2.23.0
Source:
See:
  • AppModel#archivedContentIsIndexed
Returns:
- True if the citation has no content because it is archived and archived content is not indexed.
Type
boolean

isDOI(doi) → {boolean}

Check if a string is a valid DOI.
Parameters:
Name Type Description
doi string The string to check.
Since:
  • 2.23.0
Source:
Returns:
- True if the string is a valid DOI, false otherwise.
Type
boolean

isFromNode(node) → {boolean}

Checks if the citation is for a DataONE object from a specific node (e.g. PANGAEA)
Parameters:
Name Type Description
node string The node id to check, e.g. "urn:node:PANGAEA"
Since:
  • 2.23.0
Source:
Returns:
- True if the citation is for a DataONE object from the given node
Type
boolean

isOrcid(orcid) → {boolean}

Check if a string is a valid ORCID.
Parameters:
Name Type Description
orcid string The ORCID to check
Since:
  • 2.23.0
Source:
Returns:
Returns true if the ORCID is valid, false otherwise
Type
boolean

nameStrToCSLJSON(author) → {Object}

Convert the author string that is returned from the metrics service into CSL JSON format. Author strings that come from the metrics service take many formats, which might include full given and last names, middle initials, first initials, etc. Here are a few example strings: "Chelsea Wegner Koch", "Lee W. Cooper", "J. Wiktor", "Sei-Ichi Saitoh", "William K. W. Li", "J.R. Lovvorn". Last name prefixes like "van" or "de" are stored as a "non-dropping particle". See: https://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html#name-variables
Parameters:
Name Type Description
author str The author string to convert
Since:
  • 2.23.0
Source:
Returns:
Returns an object with the author's name in CSL JSON format.
Type
Object

originArrayFromOrcid(orcid)

Use the App Lookup model's get Accounts method to get the name of the author from their ORCID, then asynchronously set the originArray to contain that name.
Parameters:
Name Type Description
orcid string The ORCID to get the name for
Since:
  • 2.23.0
Source:

originArrayToString() → {string}

Convert the origin array to a string.
Since:
  • 2.23.0
Source:
Returns:
- The origin string. If a falsy value is passed in, then the default origin attribute of the model is returned.
Type
string

originToArray(origin) → {Array}

Convert the comma-separated origin string to an array of authors.
Parameters:
Name Type Description
origin string The origin string to convert to an array. If a falsy value is passed in, then the default originArray attribute of the model is returned.
Since:
  • 2.23.0
Source:
Returns:
- An array of authors
Type
Array

parse(response, options) → {Object}

Override the default Backbone.Model.parse() method to convert the citationMetadata object into a nested collection of CitationModels.
Parameters:
Name Type Description
response Object The response from the metrics-service API
options Object Options to pass to the parse() method.
Source:
Returns:
The parsed response
Type
Object

populateFromModel(model)

Do not call this method directly. Instead, call setSourceModel(), which will update listeners and then call this method. This method will populate this citation model's attributes from another model, such as a SolrResult model or a DataONEObject model. This will reset and overwrite any existing attributes on this model.
Parameters:
Name Type Description
model Backbone.Model The model to populate from, accepts SolrResult or a model that is a DataONEObject or an extended DataONEObject. If no model is passed, then the model will be reset to the default attributes.
Since:
  • 2.23.0
Source:

removeAllDOIPrefixes(str) → {string}

Remove all DOI prefixes from a DOI string, including https, http, doi.org, dx.doi.org, and doi:.
Parameters:
Name Type Description
str string The DOI string to remove prefixes from.
Since:
  • 2.23.0
Source:
Returns:
- The DOI string without any prefixes.
Type
string

set(key, val, options)

Override the default Backbone.Model.set() method to format the title, page, and volume attributes before setting them, and ensure that attributes that are different formats of the same value are in sync, including: origin and originArray; pid and pid_url; seriesId and seriesId_url. This method will prevent the sourceModel attribute from being set here.
Parameters:
Name Type Description
key string | Object The attribute name to set, or an object of attribute names and values to set.
val string | number | Object The value to set the attribute to.
options Object Options to pass to the set() method.
Since:
  • 2.23.0
Source:
See:

setSourceModel(newSourceModel)

Sets the sourceModel attribute and calls the method to populate the Citation Model with the sourceModel attributes. Also removes any existing listeners on the previous sourceModel and readds them to the new sourceModel. Use this method to set or change the sourceModel attribute.
Parameters:
Name Type Description
newSourceModel Backbone.Model The new sourceModel
Since:
  • 2.23.0
Source:

yearFromDate(date) → {Number}

Given a date, extract the year as a number.
Parameters:
Name Type Description
date Date | String | Number The date to extract the year from
Since:
  • 2.23.0
Source:
Returns:
Returns the year as a number, or null if the date is invalid.
Type
Number