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
88
89
90
91
92
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 88
def creator
solr_term = hydra_model == AdminSet ? "creator_ssim" : "creator_tesim"
fetch(solr_term, [])
end
|
#depositor(default = '') ⇒ Object
83
84
85
86
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 83
def depositor(default = '')
val = first("depositor_tesim")
val.presence || default
end
|
#embargo_enforced? ⇒ Boolean
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 112
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
|
#hydra_model(classifier: nil) ⇒ Object
Method to return the model
78
79
80
81
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 78
def hydra_model(classifier: nil)
first('has_model_ssim')&.safe_constantize ||
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
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 125
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
|
#visibility ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 94
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
|