Module: Ddr::Models::SolrDocument
- Extended by:
- ActiveSupport::Concern, Deprecation
- Defined in:
- lib/ddr/models/solr_document.rb
Defined Under Namespace
Modules: ClassMethods
Classes: NotFound
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/ddr/models/solr_document.rb', line 38
def method_missing(name, *args, &block)
if args.empty? && !block
begin
field = Ddr::Index::Fields.get(name)
rescue NameError
else
val = self[field]
return val.is_a?(Array) ? val.join(", ") : val
end
end
super
end
|
Instance Method Details
#admin_policy ⇒ Object
109
110
111
112
113
|
# File 'lib/ddr/models/solr_document.rb', line 109
def admin_policy
if has_admin_policy?
self.class.find(admin_policy_uri)
end
end
|
#admin_policy_pid ⇒ Object
Also known as:
admin_policy_id
103
104
105
106
|
# File 'lib/ddr/models/solr_document.rb', line 103
def admin_policy_pid
uri = admin_policy_uri
uri &&= ActiveFedora::Base.pid_from_uri(uri)
end
|
#admin_policy_uri ⇒ Object
99
100
101
|
# File 'lib/ddr/models/solr_document.rb', line 99
def admin_policy_uri
is_governed_by
end
|
#association(name) ⇒ Object
178
179
180
|
# File 'lib/ddr/models/solr_document.rb', line 178
def association(name)
get_pid(ActiveFedora::SolrService.solr_name(name, :symbol))
end
|
#caption_extension ⇒ Object
273
274
275
276
277
278
279
280
281
282
|
# File 'lib/ddr/models/solr_document.rb', line 273
def caption_extension
if captionable?
extensions = Ddr::Models.preferred_file_extensions
if extensions.include? caption_type
extensions[caption_type]
else
caption_extension_default
end
end
end
|
#caption_type ⇒ Object
267
268
269
270
271
|
# File 'lib/ddr/models/solr_document.rb', line 267
def caption_type
if captionable?
datastreams[Ddr::Datastreams::CAPTION]["dsMIME"]
end
end
|
#captionable? ⇒ Boolean
263
264
265
|
# File 'lib/ddr/models/solr_document.rb', line 263
def captionable?
has_datastream?(Ddr::Datastreams::CAPTION)
end
|
#children ⇒ Object
322
323
324
|
# File 'lib/ddr/models/solr_document.rb', line 322
def children
children_query.docs rescue []
end
|
#content_checksum ⇒ Object
162
163
164
|
# File 'lib/ddr/models/solr_document.rb', line 162
def content_checksum
content_ds["dsChecksum"] rescue nil
end
|
#content_ds ⇒ Object
152
153
154
|
# File 'lib/ddr/models/solr_document.rb', line 152
def content_ds
datastreams[Ddr::Datastreams::CONTENT]
end
|
#content_mime_type ⇒ Object
Also known as:
content_type
156
157
158
|
# File 'lib/ddr/models/solr_document.rb', line 156
def content_mime_type
content_ds["dsMIME"] rescue nil
end
|
#controller_name ⇒ Object
182
183
184
|
# File 'lib/ddr/models/solr_document.rb', line 182
def controller_name
active_fedora_model.tableize
end
|
#datastreams ⇒ Object
87
88
89
|
# File 'lib/ddr/models/solr_document.rb', line 87
def datastreams
object_profile["datastreams"]
end
|
#effective_permissions(agents) ⇒ Object
#finding_aid ⇒ Object
234
235
236
237
238
|
# File 'lib/ddr/models/solr_document.rb', line 234
def finding_aid
if ead_id
FindingAid.new(ead_id)
end
end
|
#has_admin_policy? ⇒ Boolean
95
96
97
|
# File 'lib/ddr/models/solr_document.rb', line 95
def has_admin_policy?
admin_policy_uri.present?
end
|
#has_children? ⇒ Boolean
115
116
117
|
# File 'lib/ddr/models/solr_document.rb', line 115
def has_children?
ActiveFedora::SolrService.class_from_solr_document(self).reflect_on_association(:children).present?
end
|
#has_content? ⇒ Boolean
140
141
142
|
# File 'lib/ddr/models/solr_document.rb', line 140
def has_content?
has_datastream?(Ddr::Datastreams::CONTENT)
end
|
#has_datastream?(dsID) ⇒ Boolean
91
92
93
|
# File 'lib/ddr/models/solr_document.rb', line 91
def has_datastream?(dsID)
datastreams[dsID].present?
end
|
#has_parent? ⇒ Boolean
215
216
217
|
# File 'lib/ddr/models/solr_document.rb', line 215
def has_parent?
parent_uri.present?
end
|
#has_target? ⇒ Boolean
174
175
176
|
# File 'lib/ddr/models/solr_document.rb', line 174
def has_target?
targets_count > 0
end
|
#has_thumbnail? ⇒ Boolean
136
137
138
|
# File 'lib/ddr/models/solr_document.rb', line 136
def has_thumbnail?
has_datastream?(Ddr::Datastreams::THUMBNAIL)
end
|
#identifier ⇒ Object
127
128
129
130
|
# File 'lib/ddr/models/solr_document.rb', line 127
def identifier
self[ActiveFedora::SolrService.solr_name(:identifier, :stored_searchable, type: :text)]
end
|
#inspect ⇒ Object
34
35
36
|
# File 'lib/ddr/models/solr_document.rb', line 34
def inspect
"#<#{self.class.name} id=#{id.inspect}>"
end
|
252
253
254
255
256
257
258
259
260
261
|
# File 'lib/ddr/models/solr_document.rb', line 252
def intermediate_extension
if has_intermediate_file?
extensions = Ddr::Models.preferred_file_extensions
if extensions.include? intermediate_type
extensions[intermediate_type]
else
intermediate_extension_default
end
end
end
|
240
241
242
243
244
|
# File 'lib/ddr/models/solr_document.rb', line 240
def intermediate_type
if has_intermediate_file?
datastreams[Ddr::Datastreams::INTERMEDIATE_FILE]["dsMIME"]
end
end
|
#label ⇒ Object
119
120
121
|
# File 'lib/ddr/models/solr_document.rb', line 119
def label
object_profile["objLabel"]
end
|
#last_fixity_check_on ⇒ Object
#last_virus_check_on ⇒ Object
#multires_image_file_paths ⇒ Object
225
226
227
228
229
230
231
|
# File 'lib/ddr/models/solr_document.rb', line 225
def multires_image_file_paths
if structure
structure_docs.map { |doc| doc.multires_image_file_path }.compact
else
[]
end
end
|
#object_create_date ⇒ Object
71
72
73
|
# File 'lib/ddr/models/solr_document.rb', line 71
def object_create_date
parse_date(object_profile["objCreateDate"])
end
|
#object_modified_date ⇒ Object
75
76
77
|
# File 'lib/ddr/models/solr_document.rb', line 75
def object_modified_date
parse_date(object_profile["objLastModDate"])
end
|
#object_profile ⇒ Object
63
64
65
|
# File 'lib/ddr/models/solr_document.rb', line 63
def object_profile
@object_profile ||= get_json(Ddr::Index::Fields::OBJECT_PROFILE)
end
|
#object_state ⇒ Object
67
68
69
|
# File 'lib/ddr/models/solr_document.rb', line 67
def object_state
object_profile["objState"]
end
|
#parent ⇒ Object
219
220
221
222
223
|
# File 'lib/ddr/models/solr_document.rb', line 219
def parent
if has_parent?
self.class.find(parent_uri)
end
end
|
#parent_uri ⇒ Object
211
212
213
|
# File 'lib/ddr/models/solr_document.rb', line 211
def parent_uri
is_part_of || is_member_of_collection
end
|
#rights ⇒ Object
FIXME - Probably need a more general solution mapping object reader methods to index field names.
318
319
320
|
# File 'lib/ddr/models/solr_document.rb', line 318
def rights
self["rights_tesim"]
end
|
#rights_statement ⇒ Object
Also known as:
effective_license
186
187
188
|
# File 'lib/ddr/models/solr_document.rb', line 186
def rights_statement
@rights_statement ||= RightsStatement.call(self)
end
|
#safe_id ⇒ Object
59
60
61
|
# File 'lib/ddr/models/solr_document.rb', line 59
def safe_id
id.sub(/:/, "-")
end
|
#source ⇒ Object
132
133
134
|
# File 'lib/ddr/models/solr_document.rb', line 132
def source
self[ActiveFedora::SolrService.solr_name(:source, :stored_searchable, type: :text)]
end
|
294
295
296
297
298
299
300
301
302
303
|
# File 'lib/ddr/models/solr_document.rb', line 294
def streamable_media_extension
if streamable?
extensions = Ddr::Models.preferred_file_extensions
if extensions.include? streamable_media_type
extensions[streamable_media_type]
else
streamable_media_extension_default
end
end
end
|
305
306
307
308
309
|
# File 'lib/ddr/models/solr_document.rb', line 305
def streamable_media_type
if streamable?
datastreams[Ddr::Datastreams::STREAMABLE_MEDIA]["dsMIME"]
end
end
|
#structure ⇒ Object
196
197
198
199
200
|
# File 'lib/ddr/models/solr_document.rb', line 196
def structure
JSON.parse(fetch(Ddr::Index::Fields::STRUCTURE))
rescue
nil
end
|
#targets ⇒ Object
166
167
168
|
# File 'lib/ddr/models/solr_document.rb', line 166
def targets
@targets ||= ActiveFedora::SolrService.query(targets_query)
end
|
#targets_count ⇒ Object
170
171
172
|
# File 'lib/ddr/models/solr_document.rb', line 170
def targets_count
@targets_count ||= ActiveFedora::SolrService.count(targets_query)
end
|
#title_display ⇒ Object
123
124
125
|
# File 'lib/ddr/models/solr_document.rb', line 123
def title_display
title
end
|
#to_partial_path ⇒ Object
55
56
57
|
# File 'lib/ddr/models/solr_document.rb', line 55
def to_partial_path
'document'
end
|