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



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

def abstract_or_scope
  abstract || scope
end

#children?Boolean

Returns:

  • (Boolean)


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

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



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

Returns:

  • (Boolean)


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

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

#collection_creatorObject



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

def collection_creator
  collection&.creator
end

#collection_nameObject



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

def collection_name
  collection&.normalized_title
end

#collection_unitidObject



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

def collection_unitid
  collection&.unitid
end

#component_levelObject



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

def component_level
  first('component_level_isim')
end

#containersObject



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_objectsObject



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

#downloadsDocumentDownloads

Factory method for constructing the Object modeling downloads

Returns:



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

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

#ead_fileObject



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

#eadidObject

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

#highlightsArray<String>

Returns with embedded highlights using .

Returns:

  • (Array<String>)

    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_pathObject



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

def nest_path
  self['_nest_path_']
end

#normalized_eadidObject



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_childrenObject



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

Returns:

  • (Boolean)


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

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

#parentsObject



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

#repositoryObject



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_unitidObject



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

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

#repository_configObject



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

Returns:

  • (Boolean)


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

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

#rootObject



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

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