Module: Hyrax::SolrDocumentBehavior
Defined Under Namespace
Classes: ModelWrapper
Instance Method Summary
collapse
#byte_order, #capture_device, #color_map, #color_space, #compression, #duration, #file_size, #file_title, #filename, #format_label, #gps_timestamp, #height, #image_producer, #last_modified, #latitude, #longitude, #orientation, #original_checksum, #page_count, #profile_name, #profile_version, #sample_rate, #scanning_software, #well_formed, #width
#end_note_format, #endnote_filename, #export_as_endnote, #persistent_url
#private?, #public?, #registered?
Instance Method Details
#admin_set ⇒ Object
221
222
223
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 221
def admin_set
fetch(Solrizer.solr_name('admin_set'), [])
end
|
#based_near ⇒ Object
197
198
199
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 197
def based_near
self[Solrizer.solr_name('based_near')]
end
|
#collection? ⇒ Boolean
63
64
65
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 63
def collection?
hydra_model == ::Collection
end
|
#collection_ids ⇒ Object
217
218
219
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 217
def collection_ids
fetch('collection_ids_tesim', [])
end
|
#collections ⇒ Object
Find the solr documents for the collections this object belongs to TODO: can we remove this method now?
227
228
229
230
231
232
233
234
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 227
def collections
return @collections if @collections
query = 'id:' + collection_ids.map { |id| '"' + id + '"' }.join(' OR ')
result = Blacklight.default_index.connection.select(params: { q: query })
@collections = result['response']['docs'].map do |hash|
::SolrDocument.new(hash)
end
end
|
#contributor ⇒ Object
122
123
124
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 122
def contributor
fetch(Solrizer.solr_name('contributor'), [])
end
|
#create_date ⇒ Object
189
190
191
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 189
def create_date
date_field('system_create')
end
|
#creator ⇒ Object
117
118
119
120
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 117
def creator
descriptor = hydra_model.index_config[:creator].behaviors.first
fetch(Solrizer.solr_name('creator', descriptor), [])
end
|
#date_created ⇒ Object
Date created indexed as a string. This allows users to enter values like: ‘Circa 1840-1844’
185
186
187
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 185
def date_created
fetch(Solrizer.solr_name("date_created"), [])
end
|
#date_modified ⇒ Object
88
89
90
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 88
def date_modified
date_field('date_modified')
end
|
#date_uploaded ⇒ Object
92
93
94
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 92
def date_uploaded
date_field('date_uploaded')
end
|
#depositor(default = '') ⇒ Object
96
97
98
99
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 96
def depositor(default = '')
val = first(Solrizer.solr_name('depositor'))
val.present? ? val : default
end
|
#description ⇒ Object
105
106
107
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 105
def description
fetch(Solrizer.solr_name('description'), [])
end
|
#edit_groups ⇒ Object
209
210
211
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 209
def edit_groups
fetch(::Ability.edit_group_field, [])
end
|
#edit_people ⇒ Object
213
214
215
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 213
def edit_people
fetch(::Ability.edit_user_field, [])
end
|
#embargo_release_date ⇒ Object
142
143
144
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 142
def embargo_release_date
self[Hydra.config.permissions.embargo.release_date]
end
|
113
114
115
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 113
def file_format
first(Solrizer.solr_name('file_format'))
end
|
#human_readable_type ⇒ Object
76
77
78
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 76
def human_readable_type
first(Solrizer.solr_name('human_readable_type', :stored_searchable))
end
|
#hydra_model ⇒ Object
Method to return the ActiveFedora model
72
73
74
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 72
def hydra_model
first(Solrizer.solr_name('has_model', :symbol)).constantize
end
|
#identifier ⇒ Object
193
194
195
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 193
def identifier
self[Solrizer.solr_name('identifier')]
end
|
#itemtype ⇒ Object
Add a schema.org itemtype
#keyword ⇒ Object
138
139
140
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 138
def keyword
fetch(Solrizer.solr_name('keyword'), [])
end
|
#label ⇒ Object
109
110
111
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 109
def label
first(Solrizer.solr_name('label'))
end
|
#language ⇒ Object
134
135
136
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 134
def language
fetch(Solrizer.solr_name('language'), [])
end
|
#lease_expiration_date ⇒ Object
146
147
148
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 146
def lease_expiration_date
self[Hydra.config.permissions.lease.expiration_date]
end
|
#member_of_collection_ids ⇒ Object
236
237
238
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 236
def member_of_collection_ids
fetch(Solrizer.solr_name('member_of_collection_ids', :symbol), [])
end
|
#mime_type ⇒ Object
154
155
156
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 154
def mime_type
self[Solrizer.solr_name('mime_type', :stored_sortable)]
end
|
#publisher ⇒ Object
130
131
132
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 130
def publisher
fetch(Solrizer.solr_name('publisher'), [])
end
|
#read_groups ⇒ Object
158
159
160
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 158
def read_groups
fetch(::Ability.read_group_field, [])
end
|
201
202
203
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 201
def related_url
self[Solrizer.solr_name('related_url')]
end
|
#representative_id ⇒ Object
80
81
82
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 80
def representative_id
first(Solrizer.solr_name('hasRelatedMediaFragment', :symbol))
end
|
#resource_type ⇒ Object
205
206
207
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 205
def resource_type
fetch(Solrizer.solr_name("resource_type"), [])
end
|
#rights ⇒ Object
150
151
152
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 150
def rights
fetch(Solrizer.solr_name('rights'), [])
end
|
#source ⇒ Object
162
163
164
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 162
def source
fetch(Solrizer.solr_name('source'), [])
end
|
#subject ⇒ Object
126
127
128
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 126
def subject
fetch(Solrizer.solr_name('subject'), [])
end
|
#suppressed? ⇒ Boolean
67
68
69
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 67
def suppressed?
first(Solrizer.solr_name('suppressed', stored_boolean_field))
end
|
#thumbnail_id ⇒ Object
84
85
86
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 84
def thumbnail_id
first(Solrizer.solr_name('hasRelatedImage', :symbol))
end
|
#title ⇒ Object
101
102
103
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 101
def title
fetch(Solrizer.solr_name('title'), [])
end
|
#title_or_label ⇒ Object
15
16
17
18
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 15
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).
59
60
61
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 59
def to_model
@model ||= ModelWrapper.new(hydra_model, id)
end
|
#to_param ⇒ Object
20
21
22
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 20
def to_param
id
end
|
#to_s ⇒ Object
24
25
26
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 24
def to_s
title_or_label
end
|
#visibility ⇒ Object
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 166
def visibility
@visibility ||= if embargo_release_date.present?
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
elsif lease_expiration_date.present?
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE
elsif public?
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
elsif registered?
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
else
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
end
end
|
#workflow_state ⇒ Object
180
181
182
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 180
def workflow_state
first(Solrizer.solr_name('workflow_state_name', :symbol))
end
|