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
80 81 82 |
# File 'app/models/concerns/arclight/solr_document.rb', line 80 def abstract_or_scope abstract || scope end |
#children? ⇒ Boolean
96 97 98 |
# File 'app/models/concerns/arclight/solr_document.rb', line 96 def children? number_of_children.positive? end |
#collection ⇒ SolrDocument
Returns a SolrDocument representing the EAD collection that this document belongs to.
66 67 68 69 70 |
# File 'app/models/concerns/arclight/solr_document.rb', line 66 def collection return self if collection? @collection ||= self.class.new(self['collection']&.dig('docs', 0), @response) end |
#collection? ⇒ Boolean
104 105 106 |
# File 'app/models/concerns/arclight/solr_document.rb', line 104 def collection? level&.parameterize == 'collection' end |
#collection_creator ⇒ Object
84 85 86 |
# File 'app/models/concerns/arclight/solr_document.rb', line 84 def collection_creator collection&.creator end |
#collection_name ⇒ Object
72 73 74 |
# File 'app/models/concerns/arclight/solr_document.rb', line 72 def collection_name collection&.normalized_title end |
#collection_unitid ⇒ Object
76 77 78 |
# File 'app/models/concerns/arclight/solr_document.rb', line 76 def collection_unitid collection&.unitid end |
#component_level ⇒ Object
100 101 102 |
# File 'app/models/concerns/arclight/solr_document.rb', line 100 def component_level first('component_level_isim') end |
#containers ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'app/models/concerns/arclight/solr_document.rb', line 117 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
108 109 110 111 112 113 114 115 |
# File 'app/models/concerns/arclight/solr_document.rb', line 108 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
134 135 136 |
# File 'app/models/concerns/arclight/solr_document.rb', line 134 def downloads @downloads ||= DocumentDownloads.new(self) end |
#ead_file ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'app/models/concerns/arclight/solr_document.rb', line 138 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.
47 48 49 |
# File 'app/models/concerns/arclight/solr_document.rb', line 47 def eadid first('ead_ssi')&.strip || collection&.first('ead_ssi')&.strip end |
#highlights ⇒ Array<String>
Returns with embedded highlights using ….
128 129 130 |
# File 'app/models/concerns/arclight/solr_document.rb', line 128 def highlights highlight_field(CatalogController.blacklight_config.highlight_field) end |
#nest_path ⇒ Object
147 148 149 |
# File 'app/models/concerns/arclight/solr_document.rb', line 147 def nest_path self['_nest_path_'] end |
#normalized_eadid ⇒ Object
51 52 53 |
# File 'app/models/concerns/arclight/solr_document.rb', line 51 def normalized_eadid Arclight::NormalizedId.new(eadid).to_s end |
#number_of_children ⇒ Object
92 93 94 |
# File 'app/models/concerns/arclight/solr_document.rb', line 92 def number_of_children first('child_component_count_isi') || 0 end |
#online_content? ⇒ Boolean
88 89 90 |
# File 'app/models/concerns/arclight/solr_document.rb', line 88 def online_content? first('has_online_content_ssim') == 'true' end |
#parents ⇒ Object
41 42 43 |
# File 'app/models/concerns/arclight/solr_document.rb', line 41 def parents @parents ||= Arclight::Parents.from_solr_document(self).as_parents end |
#repository ⇒ Object
56 57 58 |
# File 'app/models/concerns/arclight/solr_document.rb', line 56 def repository first('repository_ssm') || collection&.first('repository_ssm') end |
#repository_and_unitid ⇒ Object
60 61 62 |
# File 'app/models/concerns/arclight/solr_document.rb', line 60 def repository_and_unitid [repository, unitid].compact.join(': ') end |
#repository_config ⇒ Object
35 36 37 38 39 |
# File 'app/models/concerns/arclight/solr_document.rb', line 35 def repository_config return unless repository @repository_config ||= Arclight::Repository.find_by(name: repository) end |
#requestable? ⇒ Boolean
155 156 157 |
# File 'app/models/concerns/arclight/solr_document.rb', line 155 def requestable? repository_config&.request_types&.any? end |
#root ⇒ Object
151 152 153 |
# File 'app/models/concerns/arclight/solr_document.rb', line 151 def root self['_root_'] || self['id'] end |