Class: CocinaDisplay::CocinaRecord
- Inherits:
-
JsonBackedRecord
- Object
- JsonBackedRecord
- CocinaDisplay::CocinaRecord
- Includes:
- CocinaDisplay::Concerns::Accesses, CocinaDisplay::Concerns::Contributors, CocinaDisplay::Concerns::Events, CocinaDisplay::Concerns::Forms, CocinaDisplay::Concerns::Geospatial, CocinaDisplay::Concerns::Identifiers, CocinaDisplay::Concerns::Languages, CocinaDisplay::Concerns::Notes, CocinaDisplay::Concerns::RelatedResources, CocinaDisplay::Concerns::Structural, CocinaDisplay::Concerns::Subjects, CocinaDisplay::Concerns::Titles, CocinaDisplay::Concerns::UrlHelpers
- Defined in:
- lib/cocina_display/cocina_record.rb
Overview
Public Cocina metadata for an SDR object, as fetched from PURL.
Instance Attribute Summary
Attributes inherited from JsonBackedRecord
Class Method Summary collapse
-
.fetch(druid, deep_compact: true) ⇒ CocinaDisplay::CocinaRecord
Fetch a public Cocina document from PURL and create a CocinaRecord.
-
.from_json(cocina_json, deep_compact: false) ⇒ CocinaDisplay::CocinaRecord
Create a CocinaRecord from a JSON string.
Instance Method Summary collapse
-
#collection? ⇒ Boolean
True if the object is a collection.
-
#content_type ⇒ String?
SDR content type of the object.
-
#copyright ⇒ String?
Copyright statement from Cocina access metadata.
-
#created_time ⇒ Time
Timestamp when the Cocina was created.
-
#label ⇒ String?
Primary processing label for the object.
-
#license ⇒ String?
License URI.
-
#license_description ⇒ String?
Description of the license.
-
#modified_time ⇒ Time
Timestamp when the Cocina was last modified.
-
#use_and_reproduction ⇒ String?
Use and reproduction statement from Cocina access metadata.
Methods included from CocinaDisplay::Concerns::RelatedResources
#related_resource_display_data, #related_resources
Methods included from CocinaDisplay::Concerns::Structural
#file_mime_types, #files, #total_file_size_int, #total_file_size_str
Methods included from CocinaDisplay::Concerns::Geospatial
#coordinates, #coordinates_as_envelope, #coordinates_as_point, #coordinates_as_wkt, #geonames_ids
Methods included from CocinaDisplay::Concerns::Languages
#language_display_data, #languages, #searchworks_language_names
Methods included from CocinaDisplay::Concerns::Forms
#archived_website?, #cartographic?, #dataset?, #extents, #form_display_data, #form_note_display_data, #forms, #genre_display_data, #genres, #genres_search, #map_display_data, #mods_resource_types, #periodical?, #searchworks_resource_types
Methods included from CocinaDisplay::Concerns::Subjects
#subject_all, #subject_all_display, #subject_display_data, #subject_genres, #subject_names, #subject_occupations, #subject_other, #subject_places, #subject_temporal, #subject_temporal_genre, #subject_titles, #subject_topics, #subject_topics_other
Methods included from CocinaDisplay::Concerns::UrlHelpers
#download_url, #iiif_manifest_url, #oembed_url, #purl_url
Methods included from CocinaDisplay::Concerns::Titles
#additional_titles, #all_titles, #display_title, #full_title, #main_title, #primary_title, #secondary_titles, #sort_title, #title_display_data
Methods included from CocinaDisplay::Concerns::Notes
#abstract_display_data, #general_note_display_data, #notes, #preferred_citation_display_data, #table_of_contents_display_data
Methods included from CocinaDisplay::Concerns::Identifiers
#bare_druid, #doi, #doi_url, #druid, #folio_hrid, #identifier_display_data, #identifiers, #searchworks_id
Methods included from CocinaDisplay::Concerns::Contributors
#additional_contributor_names, #additional_contributors, #conference_contributor_names, #contributor_display_data, #contributor_names_by_role, #contributors, #contributors_by_role, #impersonal_contributor_names, #main_contributor, #main_contributor_name, #organization_contributor_names, #person_contributor_names, #publisher_contributors, #publisher_names, #sort_contributor_name
Methods included from CocinaDisplay::Concerns::Events
#admin_creation_event, #earliest_preferred_date, #event_date_display_data, #event_dates, #event_note_display_data, #events, #imprint_events, #imprint_str, #pub_date, #pub_date_edtf, #pub_year_int, #pub_year_int_range, #pub_year_str, #publication_events, #publication_places
Methods included from CocinaDisplay::Concerns::Accesses
#access_contacts, #access_display_data, #accesses, #contact_email_display_data, #copyright_display_data, #license_display_data, #urls, #use_and_reproduction_display_data
Methods inherited from JsonBackedRecord
Constructor Details
This class inherits a constructor from CocinaDisplay::JsonBackedRecord
Class Method Details
.fetch(druid, deep_compact: true) ⇒ CocinaDisplay::CocinaRecord
This is intended to be used in development or testing only.
Fetch a public Cocina document from PURL and create a CocinaRecord. :nocov:
26 27 28 |
# File 'lib/cocina_display/cocina_record.rb', line 26 def self.fetch(druid, deep_compact: true) from_json(Net::HTTP.get(URI("https://purl.stanford.edu/#{druid}.json")), deep_compact: deep_compact) end |
.from_json(cocina_json, deep_compact: false) ⇒ CocinaDisplay::CocinaRecord
Create a CocinaRecord from a JSON string.
35 36 37 38 |
# File 'lib/cocina_display/cocina_record.rb', line 35 def self.from_json(cocina_json, deep_compact: false) cocina_doc = JSON.parse(cocina_json) deep_compact ? new(Utils.deep_compact_blank(cocina_doc)) : new(cocina_doc) end |
Instance Method Details
#collection? ⇒ Boolean
True if the object is a collection.
73 74 75 |
# File 'lib/cocina_display/cocina_record.rb', line 73 def collection? content_type == "collection" end |
#content_type ⇒ String?
RelatedResources may not have a content type.
SDR content type of the object.
60 61 62 |
# File 'lib/cocina_display/cocina_record.rb', line 60 def content_type cocina_doc["type"].delete_prefix("https://cocina.sul.stanford.edu/models/") end |
#copyright ⇒ String?
Copyright statement from Cocina access metadata.
79 80 81 |
# File 'lib/cocina_display/cocina_record.rb', line 79 def copyright cocina_doc.dig("access", "copyright") end |
#created_time ⇒ Time
This is for the metadata itself, not the object.
Timestamp when the Cocina was created.
43 44 45 |
# File 'lib/cocina_display/cocina_record.rb', line 43 def created_time Time.parse(cocina_doc["created"]) end |
#label ⇒ String?
This may or may not be the same as the title.
Primary processing label for the object.
67 68 69 |
# File 'lib/cocina_display/cocina_record.rb', line 67 def label cocina_doc["label"] end |
#license ⇒ String?
License URI
98 99 100 |
# File 'lib/cocina_display/cocina_record.rb', line 98 def license cocina_doc.dig("access", "license") end |
#license_description ⇒ String?
Description of the license
91 92 93 94 |
# File 'lib/cocina_display/cocina_record.rb', line 91 def license_description @license_description ||= license ? License.new(url: license).description : nil end |
#modified_time ⇒ Time
This is for the metadata itself, not the object.
Timestamp when the Cocina was last modified.
50 51 52 |
# File 'lib/cocina_display/cocina_record.rb', line 50 def modified_time Time.parse(cocina_doc["modified"]) end |
#use_and_reproduction ⇒ String?
Use and reproduction statement from Cocina access metadata.
85 86 87 |
# File 'lib/cocina_display/cocina_record.rb', line 85 def use_and_reproduction cocina_doc.dig("access", "useAndReproductionStatement") end |