Module: CurationConcerns::SolrDocumentBehavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- Hydra::Works::MimeTypes
- Defined in:
- app/models/concerns/curation_concerns/solr_document_behavior.rb
Instance Method Summary collapse
- #collection? ⇒ Boolean
- #contributor ⇒ Object
- #creator ⇒ Object
-
#date_created ⇒ Object
Date created is indexed as a string.
- #date_modified ⇒ Object
- #date_uploaded ⇒ Object
- #depositor(default = '') ⇒ Object
- #description ⇒ Object
- #embargo_release_date ⇒ Object
- #file_format ⇒ Object
- #human_readable_type ⇒ Object
-
#hydra_model ⇒ Object
Method to return the ActiveFedora model.
- #keyword ⇒ Object
- #label ⇒ Object
- #language ⇒ Object
- #lease_expiration_date ⇒ Object
- #mime_type ⇒ Object
- #publisher ⇒ Object
- #read_groups ⇒ Object
- #representative_id ⇒ Object
- #rights ⇒ Object
- #source ⇒ Object
- #subject ⇒ Object
- #title ⇒ Object
- #title_or_label ⇒ Object
-
#to_model ⇒ Object
Offer the source (ActiveFedora-based) model to Rails for some of the Rails methods (e.g. link_to).
- #to_param ⇒ Object
- #to_s ⇒ Object
- #visibility ⇒ Object
Instance Method Details
#collection? ⇒ Boolean
31 32 33 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 31 def collection? hydra_model == ::Collection end |
#contributor ⇒ Object
86 87 88 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 86 def contributor fetch(Solrizer.solr_name('contributor'), []) end |
#creator ⇒ Object
82 83 84 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 82 def creator fetch(Solrizer.solr_name('creator'), []) end |
#date_created ⇒ Object
Date created is indexed as a string. This allows users to enter values like: ‘Circa 1840-1844’
49 50 51 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 49 def date_created first(Solrizer.solr_name("date_created")) end |
#date_modified ⇒ Object
53 54 55 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 53 def date_modified date_field('date_modified') end |
#date_uploaded ⇒ Object
57 58 59 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 57 def date_uploaded date_field('date_uploaded') end |
#depositor(default = '') ⇒ Object
61 62 63 64 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 61 def depositor(default = '') val = first(Solrizer.solr_name('depositor')) val.present? ? val : default end |
#description ⇒ Object
70 71 72 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 70 def description Array.wrap(self[Solrizer.solr_name('description')]) end |
#embargo_release_date ⇒ Object
106 107 108 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 106 def self[Hydra.config...release_date] end |
#file_format ⇒ Object
78 79 80 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 78 def file_format first(Solrizer.solr_name('file_format')) end |
#human_readable_type ⇒ Object
40 41 42 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 40 def human_readable_type first(Solrizer.solr_name('human_readable_type', :stored_searchable)) end |
#hydra_model ⇒ Object
Method to return the ActiveFedora model
36 37 38 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 36 def hydra_model first(Solrizer.solr_name('has_model', :symbol)).constantize end |
#keyword ⇒ Object
102 103 104 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 102 def keyword fetch(Solrizer.solr_name('keyword'), []) end |
#label ⇒ Object
74 75 76 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 74 def label first(Solrizer.solr_name('label')) end |
#language ⇒ Object
98 99 100 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 98 def language fetch(Solrizer.solr_name('language'), []) end |
#lease_expiration_date ⇒ Object
110 111 112 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 110 def lease_expiration_date self[Hydra.config..lease.expiration_date] end |
#mime_type ⇒ Object
118 119 120 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 118 def mime_type self[Solrizer.solr_name('mime_type', :stored_sortable)] end |
#publisher ⇒ Object
94 95 96 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 94 def publisher fetch(Solrizer.solr_name('publisher'), []) end |
#read_groups ⇒ Object
122 123 124 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 122 def read_groups fetch(Hydra.config..read.group, []) end |
#representative_id ⇒ Object
44 45 46 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 44 def representative_id first(Solrizer.solr_name('hasRelatedMediaFragment', :symbol)) end |
#rights ⇒ Object
114 115 116 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 114 def rights fetch(Solrizer.solr_name('rights'), []) end |
#source ⇒ Object
126 127 128 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 126 def source fetch(Solrizer.solr_name('source'), []) end |
#subject ⇒ Object
90 91 92 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 90 def subject fetch(Solrizer.solr_name('subject'), []) end |
#title ⇒ Object
66 67 68 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 66 def title Array.wrap(self[Solrizer.solr_name('title')]) end |
#title_or_label ⇒ Object
6 7 8 9 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 6 def title_or_label return label if title.blank? title.join(', ') end |
#to_model ⇒ Object
Offer the source (ActiveFedora-based) model to Rails for some of the Rails methods (e.g. link_to).
24 25 26 27 28 29 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 24 def to_model @model ||= begin m = ActiveFedora::Base.load_instance_from_solr(id, self) m.class == ActiveFedora::Base ? self : m end end |
#to_param ⇒ Object
11 12 13 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 11 def to_param id end |
#to_s ⇒ Object
15 16 17 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 15 def to_s title_or_label end |
#visibility ⇒ Object
130 131 132 133 134 135 136 137 138 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 130 def visibility @visibility ||= if read_groups.include? Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC elsif read_groups.include? Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED else Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE end end |