Class: ObjectFormats

ObjectFormats()

ObjectFormats represents the DataONE object format list found at https://cn.dataone.org/cn/v2/formats. This collection starts with built-in fallback definitions and refreshes from an injected formats service when available.

Constructor

new ObjectFormats()

Source:

Extends

  • Backbone.Collection

Methods

fetch(optionsopt) → {jqXHR}

Retrieve the formats from the Coordinating Node
Parameters:
Name Type Attributes Description
options object <optional>
Options to pass to Backbone fetch.
Source:
Returns:
Backbone fetch request.
Type
jqXHR

fetchPromise(optionsopt) → {Promise.<ObjectFormats>}

Fetch the formats and return a promise that settles with the Backbone sync or error event.
Parameters:
Name Type Attributes Description
options object <optional>
Options to pass to ObjectFormats#fetch
Since:
  • 2.39.0
Source:
Returns:
Promise resolving to this collection
Type
Promise.<ObjectFormats>

getFormatId(props) → {string}

Given a formatId, filename, and/or mediaType, return the best matching formatId from the collection.
Parameters:
Name Type Description
props object Format matching properties.
Properties
Name Type Attributes Description
formatId string <optional>
The formatId to match against the collection
existingFormatId string <optional>
Existing formatId to use when filename and mediaType are ambiguous
filename string <optional>
The filename to match against the collection
mediaType string <optional>
The mediaType to match against the collection
Since:
  • 2.39.0
Source:
Returns:
- The best matching formatId from the collection, or the default formatId if no match is found.
Type
string

getFormatType(props) → {string|null}

Determine the DataONE format type for a format signal.
Parameters:
Name Type Description
props object Format properties.
Properties
Name Type Attributes Description
formatType string <optional>
Explicit format type.
formatId string <optional>
DataONE format ID.
filename string <optional>
File name used for extension matching.
mediaType string <optional>
Media type used for format matching.
Since:
  • 2.39.0
Source:
Returns:
One of "RESOURCE", "METADATA", "DATA", or null when no match is available.
Type
string | null

getFriendlyFormat(formatId) → {string}

Convert a DataONE format ID into a human-readable format name.
Parameters:
Name Type Description
formatId string Format ID to convert.
Since:
  • 2.39.0
Source:
Returns:
Friendly format name, or the original value when no match is available.
Type
string

getType(propsopt) → {string}

Determine the general display type for an object.
Parameters:
Name Type Attributes Description
props object <optional>
Object format and provenance properties
Since:
  • 2.39.0
Source:
Returns:
A value from ObjectFormats#OBJECT_TYPES
Type
string

initialize(modelsopt, optionsopt)

Initialize fallback and remote-fetch state for the collection.
Parameters:
Name Type Attributes Description
models Array.<object> | Array.<Backbone.Model> <optional>
Initial format models.
options object <optional>
Collection options.
Properties
Name Type Attributes Description
remote boolean <optional>
Whether the models are remote formats.
fallback boolean <optional>
Set false to skip fallback formats.
formatsServiceUrl string <optional>
URL used to fetch formats
Since:
  • 2.39.0
Source:

isData(props) → {boolean}

Check whether format properties identify data.
Parameters:
Name Type Description
props object Format properties accepted by ObjectFormats#getFormatType.
Since:
  • 2.39.0
Source:
Returns:
True when the format type is DATA.
Type
boolean

isEML(props) → {boolean}

Check whether format properties identify an EML document.
Parameters:
Name Type Description
props object Format properties.
Properties
Name Type Attributes Description
formatId string <optional>
DataONE format ID.
filename string <optional>
File name used for extension matching.
mediaType string <optional>
Media type used for format matching.
Since:
  • 2.39.0
Source:
Returns:
True when the resolved format ID is an EML format.
Type
boolean

isImage(props) → {boolean}

Check whether format properties identify a previewable image.
Parameters:
Name Type Description
props object Object format and provenance properties accepted by ObjectFormats#getType
Since:
  • 2.39.0
Source:
Returns:
True when the object has an image display type
Type
boolean

isMetadata(props) → {boolean}

Check whether format properties identify science metadata.
Parameters:
Name Type Description
props object Format properties accepted by ObjectFormats#getFormatType.
Since:
  • 2.39.0
Source:
Returns:
True when the format type is METADATA.
Type
boolean

isResource(props) → {boolean}

Check whether format properties identify a resource object.
Parameters:
Name Type Description
props object Format properties accepted by ObjectFormats#getFormatType.
Since:
  • 2.39.0
Source:
Returns:
True when the format type is RESOURCE.
Type
boolean

isResourceMap(props) → {boolean}

Check whether format properties identify an ORE resource map.
Parameters:
Name Type Description
props object Format properties.
Properties
Name Type Attributes Description
formatId string <optional>
DataONE format ID.
filename string <optional>
File name used for extension matching.
mediaType string <optional>
Media type used for format matching.
Since:
  • 2.39.0
Source:
Returns:
True when the resolved format ID is the ORE format.
Type
boolean

parse(response) → {Array.<object>}

Parse the XML response from the CN
Parameters:
Name Type Description
response string | object XML response text, or parsed formats.
Source:
Returns:
Parsed object formats.
Type
Array.<object>

url() → {string|null}

The constructed URL of the collection (/cn/v2/formats)
Source:
Returns:
URL used during fetch
Type
string | null