Module: Shared::Dwc::MediaExtensions
- Extended by:
- ActiveSupport::Concern
- Included in:
- Image::DwcMediaExtensions, Sound::DwcMediaExtensions
- Defined in:
- app/models/concerns/shared/dwc/media_extensions.rb
Overview
A concern on media items like images and sounds.
Constant Summary collapse
- DWC_MEDIA_SHARED_EXTENSION_MAP =
Shared implementation amongst all media sources.
{ identifier: :dwc_media_identifier, providerManagedID: :dwc_media_provider_managed_id, # TODO currently .id ?? 'dc:rights': :dwc_media_dc_rights, 'dcterms:rights': :dwc_media_dcterms_rights, Owner: :dwc_media_owner, Credit: :dwc_media_credit, 'dc:creator': :dwc_media_dc_creator, 'dcterms:creator': :dwc_media_dcterms_creator, furtherInformationURL: :dwc_media_further_information_url }.freeze
Instance Method Summary collapse
- #dwc_media_credit ⇒ Object
- #dwc_media_dc_creator ⇒ Object
- #dwc_media_dc_rights ⇒ Object
- #dwc_media_dcterms_creator ⇒ Object
- #dwc_media_dcterms_rights ⇒ Object
- #dwc_media_further_information_url ⇒ Object
- #dwc_media_identifier ⇒ Object
- #dwc_media_owner ⇒ Object
- #dwc_media_provider_managed_id ⇒ Object
Instance Method Details
#dwc_media_credit ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/concerns/shared/dwc/media_extensions.rb', line 51 def dwc_media_credit media = self.class .joins(attribution: :roles) .where(roles: {type: 'AttributionCopyrightHolder'}) .where(id: id) .includes(:attribution) .first return nil if media.nil? ApplicationController.helpers.attribution_copyright_label(media.attribution) end |
#dwc_media_dc_creator ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'app/models/concerns/shared/dwc/media_extensions.rb', line 64 def dwc_media_dc_creator self.class .joins(attribution: {roles: :person}) .where(roles: {type: 'AttributionCreator'}) .where(id: id) .pluck('people.cached') .join(CollectionObject::DWC_DELIMITER) end |
#dwc_media_dc_rights ⇒ Object
28 29 30 |
# File 'app/models/concerns/shared/dwc/media_extensions.rb', line 28 def dwc_media_dc_rights dwc_media_dcterms_rights end |
#dwc_media_dcterms_creator ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'app/models/concerns/shared/dwc/media_extensions.rb', line 73 def dwc_media_dcterms_creator self.class .joins(attribution: {roles: {person: :identifiers}}) .where(roles: {type: 'AttributionCreator'}) .where(id: id) .where("identifiers.type = 'Identifier::Global::Orcid' OR identifiers.type = 'Identifier::Global::Wikidata'") .pluck('identifiers.cached') .join(CollectionObject::DWC_DELIMITER) end |
#dwc_media_dcterms_rights ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/models/concerns/shared/dwc/media_extensions.rb', line 32 def dwc_media_dcterms_rights CREATIVE_COMMONS_LICENSES[ self.class .joins(:attribution) .where(id: id) .pluck('attributions.license') .first ]&.[](:link) end |
#dwc_media_further_information_url ⇒ Object
83 84 85 |
# File 'app/models/concerns/shared/dwc/media_extensions.rb', line 83 def dwc_media_further_information_url Shared::Api.(self) end |
#dwc_media_identifier ⇒ Object
18 19 20 21 22 |
# File 'app/models/concerns/shared/dwc/media_extensions.rb', line 18 def dwc_media_identifier # Images and sounds are unlikely to have a uuid or uri, so namespace with # class name (this field is suposed to be unique). "#{self.class.name.downcase}:#{uuid || uri || id}" end |
#dwc_media_owner ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'app/models/concerns/shared/dwc/media_extensions.rb', line 42 def dwc_media_owner self.class .joins(attribution: {roles: :person}) .where(roles: {type: 'AttributionOwner'}) .where(id: id) .pluck('people.cached') .join(CollectionObject::DWC_DELIMITER) end |
#dwc_media_provider_managed_id ⇒ Object
24 25 26 |
# File 'app/models/concerns/shared/dwc/media_extensions.rb', line 24 def dwc_media_provider_managed_id id end |