Module: Arclight::SolrDocument
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/arclight/solr_document.rb
Overview
Extends Blacklight::Solr::Document to provide Arclight specific behavior
Instance Method Summary collapse
- #abstract_or_scope ⇒ Object
- #children? ⇒ Boolean
-
#collection ⇒ SolrDocument
A SolrDocument representing the EAD collection that this document belongs to.
- #collection? ⇒ Boolean
- #collection_creator ⇒ Object
- #collection_name ⇒ Object
- #collection_unitid ⇒ Object
- #component_level ⇒ Object
- #containers ⇒ Object
- #digital_objects ⇒ Object
-
#downloads ⇒ DocumentDownloads
Factory method for constructing the Object modeling downloads.
- #ead_file ⇒ Object
-
#eadid ⇒ Object
Get this document’s EAD ID, or fall back to the collection (especially for components that may not have their own..
-
#highlights ⇒ Array<String>
With embedded highlights using ….
- #nest_path ⇒ Object
- #normalized_eadid ⇒ Object
- #number_of_children ⇒ Object
- #online_content? ⇒ Boolean
- #parents ⇒ Object
- #repository ⇒ Object
- #repository_and_unitid ⇒ Object
- #repository_config ⇒ Object
- #requestable? ⇒ Boolean
- #root ⇒ Object
Instance Method Details
#abstract_or_scope ⇒ Object
81 82 83 |
# File 'app/models/concerns/arclight/solr_document.rb', line 81 def abstract_or_scope abstract || scope end |
#children? ⇒ Boolean
97 98 99 |
# File 'app/models/concerns/arclight/solr_document.rb', line 97 def children? number_of_children.positive? end |
#collection ⇒ SolrDocument
Returns a SolrDocument representing the EAD collection that this document belongs to.
67 68 69 70 71 |
# File 'app/models/concerns/arclight/solr_document.rb', line 67 def collection return self if collection? @collection ||= self.class.new(self['collection']&.dig('docs', 0), @response) end |
#collection? ⇒ Boolean
105 106 107 |
# File 'app/models/concerns/arclight/solr_document.rb', line 105 def collection? level&.parameterize == 'collection' end |
#collection_creator ⇒ Object
85 86 87 |
# File 'app/models/concerns/arclight/solr_document.rb', line 85 def collection_creator collection&.creator end |
#collection_name ⇒ Object
73 74 75 |
# File 'app/models/concerns/arclight/solr_document.rb', line 73 def collection_name collection&.normalized_title end |
#collection_unitid ⇒ Object
77 78 79 |
# File 'app/models/concerns/arclight/solr_document.rb', line 77 def collection_unitid collection&.unitid end |
#component_level ⇒ Object
101 102 103 |
# File 'app/models/concerns/arclight/solr_document.rb', line 101 def component_level first('component_level_isim') end |
#containers ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'app/models/concerns/arclight/solr_document.rb', line 118 def containers # NOTE: Keep uppercase characters if present, but upcase the first if not already containers_field = fetch('containers_ssim', []).reject(&:empty?) return [] if containers_field.blank? containers_field.map do |container| container.dup.sub!(/\A./, &:upcase) end end |
#digital_objects ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'app/models/concerns/arclight/solr_document.rb', line 109 def digital_objects digital_objects_field = fetch('digital_objects_ssm', []).reject(&:empty?) return [] if digital_objects_field.blank? digital_objects_field.map do |object| Arclight::DigitalObject.from_json(object) end end |
#downloads ⇒ DocumentDownloads
Factory method for constructing the Object modeling downloads
135 136 137 |
# File 'app/models/concerns/arclight/solr_document.rb', line 135 def downloads @downloads ||= DocumentDownloads.new(self) end |
#ead_file ⇒ Object
139 140 141 142 143 144 145 146 |
# File 'app/models/concerns/arclight/solr_document.rb', line 139 def ead_file @ead_file ||= begin files = Arclight::DocumentDownloads.new(self, collection_unitid).files files.find do |file| file.type == 'ead' end end end |
#eadid ⇒ Object
Get this document’s EAD ID, or fall back to the collection (especially for components that may not have their own.
48 49 50 |
# File 'app/models/concerns/arclight/solr_document.rb', line 48 def eadid first('ead_ssi')&.strip || collection&.first('ead_ssi')&.strip end |
#highlights ⇒ Array<String>
Returns with embedded highlights using ….
129 130 131 |
# File 'app/models/concerns/arclight/solr_document.rb', line 129 def highlights highlight_field(CatalogController.blacklight_config.highlight_field) end |
#nest_path ⇒ Object
148 149 150 |
# File 'app/models/concerns/arclight/solr_document.rb', line 148 def nest_path self['_nest_path_'] end |
#normalized_eadid ⇒ Object
52 53 54 |
# File 'app/models/concerns/arclight/solr_document.rb', line 52 def normalized_eadid Arclight::NormalizedId.new(eadid).to_s end |
#number_of_children ⇒ Object
93 94 95 |
# File 'app/models/concerns/arclight/solr_document.rb', line 93 def number_of_children first('child_component_count_isi') || 0 end |
#online_content? ⇒ Boolean
89 90 91 |
# File 'app/models/concerns/arclight/solr_document.rb', line 89 def online_content? first('has_online_content_ssim') == 'true' end |
#parents ⇒ Object
42 43 44 |
# File 'app/models/concerns/arclight/solr_document.rb', line 42 def parents @parents ||= Arclight::Parents.from_solr_document(self).as_parents end |
#repository ⇒ Object
57 58 59 |
# File 'app/models/concerns/arclight/solr_document.rb', line 57 def repository first('repository_ssm') || collection&.first('repository_ssm') end |
#repository_and_unitid ⇒ Object
61 62 63 |
# File 'app/models/concerns/arclight/solr_document.rb', line 61 def repository_and_unitid [repository, unitid].compact.join(': ') end |
#repository_config ⇒ Object
36 37 38 39 40 |
# File 'app/models/concerns/arclight/solr_document.rb', line 36 def repository_config return unless repository @repository_config ||= Arclight::Repository.find_by(name: repository) end |
#requestable? ⇒ Boolean
156 157 158 |
# File 'app/models/concerns/arclight/solr_document.rb', line 156 def requestable? repository_config&.request_types&.any? end |
#root ⇒ Object
152 153 154 |
# File 'app/models/concerns/arclight/solr_document.rb', line 152 def root self['_root_'] || self['id'] end |