Class: Datacite::Mapping::Resource

Inherits:
Object
  • Object
show all
Includes:
XML::Mapping
Defined in:
lib/datacite/mapping/resource.rb

Overview

A collection of metadata properties chosen for the accurate and consistent identification of a resource for citation and retrieval purposes, along with recommended use instructions. The resource that is being identified can be of any kind, but it is typically a dataset.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier:, creators:, titles:, publisher:, publication_year:, subjects: [], contributors: [], dates: [], language: 'en', resource_type: nil, alternate_identifiers: [], related_identifiers: [], sizes: [], formats: [], version: nil, rights_list: [], descriptions: [], geo_locations: []) ⇒ Resource

Initialies a new Datacite::Mapping::Resource

Parameters:

  • identifier (Identifier) —

    a persistent identifier that identifies a resource.

  • creators (Array<Creator>) —

    the main researchers involved working on the data, or the authors of the publication in priority order.

  • titles (Array<Title>) —

    the names or titles by which a resource is known.

  • publisher (String) —

    the name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource.

  • publication_year (Integer) —

    year when the resource is made publicly available.

  • subjects (Array<Subject>) (defaults to: []) —

    subjects, keywords, classification codes, or key phrases describing the resource.

  • contributors (Array<Contributor>) (defaults to: []) —

    institutions or persons responsible for collecting, creating, or otherwise contributing to the developement of the dataset.

  • dates (Array<Date>) (defaults to: []) —

    different dates relevant to the work.

  • language (String) (defaults to: 'en') —

    Primary language of the resource: an IETF BCP 47, ISO 639-1 language code. It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.

  • resource_type (ResourceType, nil) (defaults to: nil) —

    the type of the resource

  • alternate_identifiers (Array<AlternateIdentifier>) (defaults to: []) —

    an identifier or identifiers other than the primary Identifier applied to the resource being registered.

  • related_identifiers (Array<RelatedIdentifier>) (defaults to: []) —

    identifiers of related resources.

  • sizes (Array<String>) (defaults to: []) —

    unstructured size information about the resource.

  • formats (Array<String>) (defaults to: []) —

    technical format of the resource, e.g. file extension or MIME type.

  • version (String) (defaults to: nil) —

    version number of the resource.

  • rights_list (Array<Rights>) (defaults to: []) —

    rights information for this resource.

  • descriptions (Array<Description>) (defaults to: []) —

    all additional information that does not fit in any of the other categories.

  • geo_locations (Array<GeoLocations>) (defaults to: []) —

    spatial region or named place where the data was gathered or about which the data is focused.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/datacite/mapping/resource.rb', line 114

def initialize(identifier:, creators:, titles:, publisher:, publication_year:, subjects: [], contributors: [], dates: [], language: 'en', resource_type: nil, alternate_identifiers: [], related_identifiers: [], sizes: [], formats: [], version: nil, rights_list: [], descriptions: [], geo_locations: []) # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists, Metrics/AbcSize
  self.identifier = identifier
  self.creators = creators
  self.titles = titles
  self.publisher = publisher
  self.publication_year = publication_year
  self.subjects = subjects
  self.contributors = contributors
  self.dates = dates
  self.language = language
  self.resource_type = resource_type
  self.alternate_identifiers = alternate_identifiers
  self.related_identifiers = related_identifiers
  self.sizes = sizes
  self.formats = formats
  self.version = version
  self.rights_list = rights_list
  self.descriptions = descriptions
  self.geo_locations = geo_locations
end

Instance Attribute Details

#alternate_identifiers ⇒ Array<AlternateIdentifier>

Returns an identifier or identifiers other than the primary Identifier applied to the resource being registered.

Returns:



63
# File 'lib/datacite/mapping/resource.rb', line 63

array_node :alternate_identifiers, 'alternateIdentifiers', 'alternateIdentifier', class: AlternateIdentifier, default_value: []

#contributors ⇒ Array<Contributor>

Returns institutions or persons responsible for collecting, creating, or otherwise contributing to the developement of the dataset.

Returns:

  • (Array<Contributor>) —

    institutions or persons responsible for collecting, creating, or otherwise contributing to the developement of the dataset.



46
# File 'lib/datacite/mapping/resource.rb', line 46

array_node :contributors, 'contributors', 'contributor', class: Contributor, default_value: []

#creators ⇒ Array<Creator>

Returns the main researchers involved working on the data, or the authors of the publication in priority order.

Returns:

  • (Array<Creator>) —

    the main researchers involved working on the data, or the authors of the publication in priority order.



26
# File 'lib/datacite/mapping/resource.rb', line 26

array_node :creators, 'creators', 'creator', class: Creator

#dates ⇒ Array<Date>

Returns different dates relevant to the work.

Returns:

  • (Array<Date>) —

    different dates relevant to the work.



50
# File 'lib/datacite/mapping/resource.rb', line 50

array_node :dates, 'dates', 'date', class: Date, default_value: []

#descriptions ⇒ Array<Description>

Returns all additional information that does not fit in any of the other categories.

Returns:

  • (Array<Description>) —

    all additional information that does not fit in any of the other categories.



87
# File 'lib/datacite/mapping/resource.rb', line 87

array_node :descriptions, 'descriptions', 'description', class: Description, default_value: []

#formats ⇒ Array<String>

Returns technical format of the resource, e.g. file extension or MIME type.

Returns:

  • (Array<String>) —

    technical format of the resource, e.g. file extension or MIME type.



75
# File 'lib/datacite/mapping/resource.rb', line 75

array_node :formats, 'formats', 'format', class: String, default_value: []

#geo_locations ⇒ Array<GeoLocations>

Returns spatial region or named place where the data was gathered or about which the data is focused.

Returns:

  • (Array<GeoLocations>) —

    spatial region or named place where the data was gathered or about which the data is focused.



91
# File 'lib/datacite/mapping/resource.rb', line 91

array_node :geo_locations, 'geoLocations', 'geoLocation', class: GeoLocation, default_value: []

#identifier ⇒ Identifier

Returns a persistent identifier that identifies a resource.

Returns:

  • (Identifier) —

    a persistent identifier that identifies a resource.



22
# File 'lib/datacite/mapping/resource.rb', line 22

object_node :identifier, 'identifier', class: Identifier

#language ⇒ String

It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.

Returns:

  • (String) —

    Primary language of the resource: an IETF BCP 47, ISO 639-1 language code.



55
# File 'lib/datacite/mapping/resource.rb', line 55

text_node :language, 'language'

#publication_year ⇒ Integer

Returns year when the resource is made publicly available.

Returns:

  • (Integer) —

    year when the resource is made publicly available.



38
# File 'lib/datacite/mapping/resource.rb', line 38

numeric_node :publication_year, 'publicationYear'

#publisher ⇒ String

Returns the name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource.

Returns:

  • (String) —

    the name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource.



34
# File 'lib/datacite/mapping/resource.rb', line 34

text_node :publisher, 'publisher'

Returns identifiers of related resources.

Returns:



67
# File 'lib/datacite/mapping/resource.rb', line 67

array_node :related_identifiers, 'relatedIdentifiers', 'relatedIdentifier', class: RelatedIdentifier, default_value: []

#resource_type ⇒ ResourceType?

Returns the type of the resource. Optional.

Returns:

  • (ResourceType, nil) —

    the type of the resource. Optional.



59
# File 'lib/datacite/mapping/resource.rb', line 59

object_node :resource_type, 'resourceType', class: ResourceType, default_value: nil

#rights_list ⇒ Array<Rights>

Returns rights information for this resource.

Returns:

  • (Array<Rights>) —

    rights information for this resource.



83
# File 'lib/datacite/mapping/resource.rb', line 83

array_node :rights_list, 'rightsList', 'rights', class: Rights, default_value: []

#sizes ⇒ Array<String>

Returns unstructured size information about the resource.

Returns:

  • (Array<String>) —

    unstructured size information about the resource.



71
# File 'lib/datacite/mapping/resource.rb', line 71

array_node :sizes, 'sizes', 'size', class: String, default_value: []

#subjects ⇒ Array<Subject>

Returns subjects, keywords, classification codes, or key phrases describing the resource.

Returns:

  • (Array<Subject>) —

    subjects, keywords, classification codes, or key phrases describing the resource.



42
# File 'lib/datacite/mapping/resource.rb', line 42

array_node :subjects, 'subjects', 'subject', class: Subject, default_value: []

#titles ⇒ Array<Title>

Returns the names or titles by which a resource is known.

Returns:

  • (Array<Title>) —

    the names or titles by which a resource is known.



30
# File 'lib/datacite/mapping/resource.rb', line 30

array_node :titles, 'titles', 'title', class: Title

#version ⇒ String

Returns version number of the resource. Optional.

Returns:

  • (String) —

    version number of the resource. Optional.



79
# File 'lib/datacite/mapping/resource.rb', line 79

text_node :version, 'version', default_value: nil

Instance Method Details

#pre_save(options = { mapping: :_default })

Overrides ::XML::Mapping.pre_save to write namespace information. Used for writing.



191
192
193
194
195
196
197
# File 'lib/datacite/mapping/resource.rb', line 191

def pre_save(options = { mapping: :_default })
  xml = super(options)
  xml.add_namespace('http://datacite.org/schema/kernel-3')
  xml.add_namespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance')
  xml.add_attribute('xsi:schemaLocation', 'http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd')
  xml
end