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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/ddr/models/solr_document.rb', line 29
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
111
112
113
|
# File 'lib/ddr/models/solr_document.rb', line 111
def admin_policy
self.class.find(admin_policy_id) if has_admin_policy?
end
|
#admin_policy_id ⇒ Object
Also known as:
admin_policy_pid, admin_policy_uri
104
105
106
|
# File 'lib/ddr/models/solr_document.rb', line 104
def admin_policy_id
is_governed_by
end
|
#association(name) ⇒ Object
174
175
176
|
# File 'lib/ddr/models/solr_document.rb', line 174
def association(name)
get_pid(ActiveFedora::SolrService.solr_name(name, :symbol))
end
|
#attached_files ⇒ Object
87
88
89
|
# File 'lib/ddr/models/solr_document.rb', line 87
def attached_files
(get_json(Ddr::Index::Fields::ATTACHED_FILES) || {}).with_indifferent_access
end
|
#content_checksum ⇒ Object
158
159
160
|
# File 'lib/ddr/models/solr_document.rb', line 158
def content_checksum
content_ds["dsChecksum"] rescue nil
end
|
#content_ds ⇒ Object
148
149
150
|
# File 'lib/ddr/models/solr_document.rb', line 148
def content_ds
datastreams[Ddr::Models::File::CONTENT]
end
|
#content_mime_type ⇒ Object
Also known as:
content_type
152
153
154
|
# File 'lib/ddr/models/solr_document.rb', line 152
def content_mime_type
content_ds["mime_type"] rescue nil
end
|
#controller_name ⇒ Object
178
179
180
|
# File 'lib/ddr/models/solr_document.rb', line 178
def controller_name
active_fedora_model.tableize
end
|
#datastreams ⇒ Object
82
83
84
85
|
# File 'lib/ddr/models/solr_document.rb', line 82
def datastreams
Deprecation.warn(SolrDocument, "Use `attached_files` instead.")
attached_files
end
|
#effective_license ⇒ Object
182
183
184
|
# File 'lib/ddr/models/solr_document.rb', line 182
def effective_license
@effective_license ||= EffectiveLicense.call(self)
end
|
#effective_permissions(agents) ⇒ Object
#finding_aid ⇒ Object
228
229
230
231
232
|
# File 'lib/ddr/models/solr_document.rb', line 228
def finding_aid
if ead_id
FindingAid.new(ead_id)
end
end
|
#has_admin_policy? ⇒ Boolean
100
101
102
|
# File 'lib/ddr/models/solr_document.rb', line 100
def has_admin_policy?
admin_policy_id.present?
end
|
#has_attached_file?(file_id) ⇒ Boolean
96
97
98
|
# File 'lib/ddr/models/solr_document.rb', line 96
def has_attached_file?(file_id)
attached_files.key?(file_id)
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_attached_file?(Ddr::Models::File::CONTENT)
end
|
#has_datastream?(dsID) ⇒ Boolean
91
92
93
94
|
# File 'lib/ddr/models/solr_document.rb', line 91
def has_datastream?(dsID)
Deprecation.warn(SolrDocument, "Use `has_attached_file?` instead.")
has_attached_file?(dsID)
end
|
144
145
146
|
# File 'lib/ddr/models/solr_document.rb', line 144
def
has_attached_file?(Ddr::Datastreams::EXTRACTED_TEXT)
end
|
#has_parent? ⇒ Boolean
215
216
217
|
# File 'lib/ddr/models/solr_document.rb', line 215
def has_parent?
parent_id.present?
end
|
#has_target? ⇒ Boolean
170
171
172
|
# File 'lib/ddr/models/solr_document.rb', line 170
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_attached_file?(Ddr::Models::File::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
25
26
27
|
# File 'lib/ddr/models/solr_document.rb', line 25
def inspect
"#<#{self.class.name} id=#{id.inspect}>"
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(type = 'default') ⇒ Object
223
224
225
|
# File 'lib/ddr/models/solr_document.rb', line 223
def multires_image_file_paths(type='default')
struct_map_docs(type).map { |doc| doc.multires_image_file_path }.compact
end
|
#object_create_date ⇒ Object
66
67
68
|
# File 'lib/ddr/models/solr_document.rb', line 66
def object_create_date
parse_date(object_profile["objCreateDate"])
end
|
#object_modified_date ⇒ Object
70
71
72
|
# File 'lib/ddr/models/solr_document.rb', line 70
def object_modified_date
parse_date(object_profile["objLastModDate"])
end
|
#object_profile ⇒ Object
58
59
60
|
# File 'lib/ddr/models/solr_document.rb', line 58
def object_profile
@object_profile ||= get_json(Ddr::Index::Fields::OBJECT_PROFILE)
end
|
#object_state ⇒ Object
62
63
64
|
# File 'lib/ddr/models/solr_document.rb', line 62
def object_state
object_profile["objState"]
end
|
#parent ⇒ Object
219
220
221
|
# File 'lib/ddr/models/solr_document.rb', line 219
def parent
self.class.find(parent_id) if has_parent?
end
|
#parent_id ⇒ Object
Also known as:
parent_uri
209
210
211
|
# File 'lib/ddr/models/solr_document.rb', line 209
def parent_id
is_part_of || is_member_of_collection
end
|
#pid ⇒ Object
20
21
22
23
|
# File 'lib/ddr/models/solr_document.rb', line 20
def pid
Deprecation.warn(SolrDocument, "`pid` is deprecated; use `id` instead.")
id
end
|
#safe_id ⇒ Object
50
51
52
|
# File 'lib/ddr/models/solr_document.rb', line 50
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
|
#struct_map(type = 'default') ⇒ Object
196
197
198
|
# File 'lib/ddr/models/solr_document.rb', line 196
def struct_map(type='default')
struct_maps.present? ? struct_maps.fetch(type) : nil
end
|
#struct_maps ⇒ Object
190
191
192
193
194
|
# File 'lib/ddr/models/solr_document.rb', line 190
def struct_maps
JSON.parse(fetch(Ddr::Index::Fields::STRUCT_MAPS))
rescue
{}
end
|
#targets ⇒ Object
162
163
164
|
# File 'lib/ddr/models/solr_document.rb', line 162
def targets
@targets ||= ActiveFedora::SolrService.query(targets_query)
end
|
#targets_count ⇒ Object
166
167
168
|
# File 'lib/ddr/models/solr_document.rb', line 166
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
46
47
48
|
# File 'lib/ddr/models/solr_document.rb', line 46
def to_partial_path
'document'
end
|