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

Instance Method Details

#abstract_or_scopeObject



80
81
82
# File 'app/models/concerns/arclight/solr_document.rb', line 80

def abstract_or_scope
  abstract || scope
end

#children?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'app/models/concerns/arclight/solr_document.rb', line 96

def children?
  number_of_children.positive?
end

#collectionSolrDocument

Returns a SolrDocument representing the EAD collection that this document belongs to.

Returns:

  • (SolrDocument)

    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

Returns:

  • (Boolean)


104
105
106
# File 'app/models/concerns/arclight/solr_document.rb', line 104

def collection?
  level&.parameterize == 'collection'
end

#collection_creatorObject



84
85
86
# File 'app/models/concerns/arclight/solr_document.rb', line 84

def collection_creator
  collection&.creator
end

#collection_nameObject



72
73
74
# File 'app/models/concerns/arclight/solr_document.rb', line 72

def collection_name
  collection&.normalized_title
end

#collection_unitidObject



76
77
78
# File 'app/models/concerns/arclight/solr_document.rb', line 76

def collection_unitid
  collection&.unitid
end

#component_levelObject



100
101
102
# File 'app/models/concerns/arclight/solr_document.rb', line 100

def component_level
  first('component_level_isim')
end

#containersObject



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_objectsObject



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

#downloadsDocumentDownloads

Factory method for constructing the Object modeling downloads

Returns:



134
135
136
# File 'app/models/concerns/arclight/solr_document.rb', line 134

def downloads
  @downloads ||= DocumentDownloads.new(self)
end

#ead_fileObject



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

#eadidObject

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

#highlightsArray<String>

Returns with embedded highlights using .

Returns:

  • (Array<String>)

    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_pathObject



147
148
149
# File 'app/models/concerns/arclight/solr_document.rb', line 147

def nest_path
  self['_nest_path_']
end

#normalized_eadidObject



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_childrenObject



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

Returns:

  • (Boolean)


88
89
90
# File 'app/models/concerns/arclight/solr_document.rb', line 88

def online_content?
  first('has_online_content_ssim') == 'true'
end

#parentsObject



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

#repositoryObject



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_unitidObject



60
61
62
# File 'app/models/concerns/arclight/solr_document.rb', line 60

def repository_and_unitid
  [repository, unitid].compact.join(': ')
end

#repository_configObject



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

Returns:

  • (Boolean)


155
156
157
# File 'app/models/concerns/arclight/solr_document.rb', line 155

def requestable?
  repository_config&.request_types&.any?
end

#rootObject



151
152
153
# File 'app/models/concerns/arclight/solr_document.rb', line 151

def root
  self['_root_'] || self['id']
end