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.
- #label ⇒ Object
- #language ⇒ Object
- #lease_expiration_date ⇒ Object
- #mime_type ⇒ Object
- #publisher ⇒ Object
- #read_groups ⇒ Object
- #representative_id ⇒ Object
- #rights ⇒ Object
- #subject ⇒ Object
- #tags ⇒ 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
30 31 32 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 30 def collection? hydra_model == 'Collection' end |
#contributor ⇒ Object
85 86 87 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 85 def contributor fetch(Solrizer.solr_name('contributor'), []) end |
#creator ⇒ Object
81 82 83 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 81 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’
48 49 50 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 48 def date_created fetch(Solrizer.solr_name("date_created"), []).first end |
#date_modified ⇒ Object
52 53 54 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 52 def date_modified date_field('date_modified') end |
#date_uploaded ⇒ Object
56 57 58 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 56 def date_uploaded date_field('date_uploaded') end |
#depositor(default = '') ⇒ Object
60 61 62 63 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 60 def depositor(default = '') val = Array(self[Solrizer.solr_name('depositor')]).first val.present? ? val : default end |
#description ⇒ Object
69 70 71 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 69 def description Array(self[Solrizer.solr_name('description')]).first end |
#embargo_release_date ⇒ Object
105 106 107 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 105 def self[Hydra.config...release_date] end |
#file_format ⇒ Object
77 78 79 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 77 def file_format Array(self[Solrizer.solr_name('file_format')]).first end |
#human_readable_type ⇒ Object
39 40 41 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 39 def human_readable_type Array(self[Solrizer.solr_name('human_readable_type', :stored_searchable)]).first end |
#hydra_model ⇒ Object
Method to return the ActiveFedora model
35 36 37 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 35 def hydra_model self[Solrizer.solr_name('active_fedora_model', Solrizer::Descriptor.new(:string, :stored, :indexed))] end |
#label ⇒ Object
73 74 75 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 73 def label Array(self[Solrizer.solr_name('label')]).first end |
#language ⇒ Object
97 98 99 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 97 def language fetch(Solrizer.solr_name('language'), []) end |
#lease_expiration_date ⇒ Object
109 110 111 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 109 def lease_expiration_date self[Hydra.config..lease.expiration_date] end |
#mime_type ⇒ Object
117 118 119 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 117 def mime_type self[Solrizer.solr_name('mime_type', :stored_sortable)] end |
#publisher ⇒ Object
93 94 95 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 93 def publisher fetch(Solrizer.solr_name('publisher'), []) end |
#read_groups ⇒ Object
121 122 123 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 121 def read_groups fetch(Hydra.config..read.group, []) end |
#representative_id ⇒ Object
43 44 45 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 43 def representative_id fetch(Solrizer.solr_name('hasRelatedMediaFragment', :symbol), []).first end |
#rights ⇒ Object
113 114 115 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 113 def rights self[Solrizer.solr_name('rights')] end |
#subject ⇒ Object
89 90 91 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 89 def subject fetch(Solrizer.solr_name('subject'), []) end |
#tags ⇒ Object
101 102 103 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 101 def fetch(Solrizer.solr_name('tag'), []) end |
#title ⇒ Object
65 66 67 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 65 def title Array(self[Solrizer.solr_name('title')]).first end |
#title_or_label ⇒ Object
6 7 8 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 6 def title_or_label title || label end |
#to_model ⇒ Object
Offer the source (ActiveFedora-based) model to Rails for some of the Rails methods (e.g. link_to).
23 24 25 26 27 28 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 23 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
10 11 12 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 10 def to_param id end |
#to_s ⇒ Object
14 15 16 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 14 def to_s title_or_label end |
#visibility ⇒ Object
125 126 127 128 129 130 131 132 133 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 125 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 |