Module: Hyrax::SolrDocumentBehavior
Overview
Hyrax extensions for Blacklight
‘s generated SolrDocument
.
Constant Summary
collapse
- ModelWrapper =
alias for backward compatibility
ActiveFedoraDummyModel
Hyrax::SolrDocument::Export::END_NOTE_MAPPINGS
Instance Method Summary
collapse
#alpha_channels, #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
#collection_type_gid ⇒ Object
#creator ⇒ Object
95
96
97
98
99
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 95
def creator
solr_term = hydra_model == AdminSet ? "creator_ssim" : "creator_tesim"
fetch(solr_term, [])
end
|
#depositor(default = '') ⇒ Object
90
91
92
93
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 90
def depositor(default = '')
val = first("depositor_tesim")
val.presence || default
end
|
#embargo_enforced? ⇒ Boolean
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 119
def embargo_enforced?
return false if embargo_release_date.blank?
indexed_embargo_visibility = first('visibility_during_embargo_ssim')
return true if indexed_embargo_visibility.blank?
self['visibility_ssi'] == indexed_embargo_visibility
end
|
#extensions_and_mime_types ⇒ Object
145
146
147
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 145
def extensions_and_mime_types
JSON.parse(self['extensions_and_mime_types_ssm'].first).map(&:with_indifferent_access) if self['extensions_and_mime_types_ssm']
end
|
#hydra_model(classifier: nil) ⇒ Object
Method to return the model
84
85
86
87
88
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 84
def hydra_model(classifier: nil)
model = first('has_model_ssim')&.safe_constantize
model = (first('has_model_ssim')&.+ 'Resource')&.safe_constantize if Hyrax.config.valkyrie_transition?
model || model_classifier(classifier).classifier(self).best_model
end
|
#itemtype ⇒ Object
Add a schema.org itemtype
26
27
28
29
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 26
def itemtype
types = resource_type || []
ResourceTypesService.microdata_type(types.first)
end
|
#lease_enforced? ⇒ Boolean
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 132
def lease_enforced?
return false if lease_expiration_date.blank?
indexed_lease_visibility = first('visibility_during_lease_ssim')
return true if indexed_lease_visibility.blank?
self['visibility_ssi'] == indexed_lease_visibility
end
|
#title_or_label ⇒ Object
31
32
33
34
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 31
def title_or_label
return label if title.blank?
title.join(', ')
end
|
#to_model ⇒ Object
Offer the source model to Rails for some of the Rails methods (e.g. link_to).
49
50
51
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 49
def to_model
@model ||= ActiveFedoraDummyModel.new(hydra_model, id)
end
|
#to_param ⇒ Object
36
37
38
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 36
def to_param
id
end
|
#to_s ⇒ Object
rubocop:disable Rails/Delegate
40
41
42
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 40
def to_s title_or_label.to_s
end
|
#valkyrie? ⇒ Boolean
79
80
81
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 79
def valkyrie?
self['valkyrie_bsi']
end
|
#visibility ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 101
def visibility
@visibility ||= if embargo_enforced?
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
elsif lease_enforced?
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
|