• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / orangelight / 4c391e0e-519a-40cb-8ad3-354445f4ce03

12 Aug 2025 08:47PM UTC coverage: 85.348% (-10.0%) from 95.335%
4c391e0e-519a-40cb-8ad3-354445f4ce03

push

circleci

web-flow
[#5143] Use access restriction note as Aeon ItemInfo1 if available (#5173)

With this commit, if a user visits a record with an access
restrictions note and presses the Reading Room Request
button, they will get to an Aeon form with the 'Restrictions'
field pre-filled with the restriction note.

If the record does not have an access restrictions note,
the field will be pre-filled with 'Reading Room Access Only',
as it has been previously.

Closes #5143

5493 of 6436 relevant lines covered (85.35%)

251.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.65
/app/services/holding_requests_adapter.rb
1
# frozen_string_literal: false
2

3
# Adapter for SolrDocument instances and the Bibdata Class
4
class HoldingRequestsAdapter
1✔
5
  attr_reader :document
1✔
6

7
  # Construct the interface for the Solr Document and Bib. Data API
8
  # @param document [SolrDocument]
9
  # @param bib_data_service [Class] Class or singleton used for the bibliographic data service
10
  def initialize(document, bib_data_service)
1✔
11
    @document = document
66✔
12
    @bib_data_service = bib_data_service
66✔
13
  end
14

15
  # Retrieve the ID for the Solr Document
16
  # @return [String] the ID value
17
  def doc_id
1✔
18
    @document.fetch('id')
×
19
  end
20

21
  # Access the holding locations from Bib. Data
22
  # @return [Hash] location hash structure
23
  delegate :holding_locations, to: :@bib_data_service
1✔
24

25
  # Retrieve the holdings information from the Solr Document
26
  # @return [Hash] holdings values
27
  def doc_holdings
1✔
28
    @document.holdings_all_display
95✔
29
  rescue StandardError => error
30
    Rails.logger.warn error
×
31
    {}
×
32
  end
33

34
  # Retrieve the electronic access information
35
  # @return [String] electronic access value
36
  delegate :doc_electronic_access, to: :@document
1✔
37

38
  # Parse IIIF Manifest links from the electronic access information
39
  # @return [Hash] IIIF Manifests information
40
  delegate :iiif_manifests, to: :@document
1✔
41

42
  # Retrieve the electronic portfolio information
43
  # @return [String] electronic portfolio values
44
  delegate :electronic_portfolios, to: :@document
1✔
45
  delegate :sibling_electronic_portfolios, to: :@document
1✔
46

47
  # Retrieve only the ELF holding records
48
  # @return [Hash] ELF holding information
49
  def doc_holdings_elf
1✔
50
    doc_holdings.select do |_id, h|
29✔
51
      h.key?('location_code') && h['location_code'].start_with?('elf')
41✔
52
    end
53
  end
54

55
  # Retrieve only the records for physical holdings
56
  # @return [Hash] physical holding information
57
  def doc_holdings_physical
1✔
58
    doc_holdings.select do |_id, h|
66✔
59
      h.key?('location_code') && !h['location_code'].start_with?('elf')
90✔
60
    end
61
  end
62
  alias physical_holdings doc_holdings_physical
1✔
63

64
  # Retrieve the physical holdings records grouped by Library and Location
65
  # Returns an array of Requests::HoldingGroup objects
66
  def grouped_physical_holdings
1✔
67
    doc_holdings_physical
29✔
68
      .map { |id, data| Requests::Holding.new(mfhd_id: id, holding_data: data) }
41✔
69
      .group_by(&:full_location_name)
70
      .map { |group_name, holdings| Requests::HoldingGroup.new(group_name:, holdings:) }
34✔
71
      .sort
72
  end
73

74
  # Retrieve the restrictions placed upon physical holdings
75
  # @return [Array<String>]
76
  def restrictions
1✔
77
    doc_holdings_physical.each_value.map { |holding| restrictions_for_holding(holding) }
86✔
78
                         .flatten.compact.uniq
79
  end
80

81
  # Determine whether or not the catalog record is for a periodical
82
  # @return [TrueClass, FalseClass]
83
  def journal?
1✔
84
    @document.fetch('format', []).include?('Journal')
41✔
85
  end
86

87
  # Retrieve the publication date for the catalog record
88
  # @return [String] the date value
89
  def pub_date
1✔
90
    @document.key?('pub_date_start_sort') ? @document['pub_date_start_sort'] : 0
1✔
91
  end
92

93
  # Methods for holding values
94
  # Should these be refactored into static methods
95
  # (or should a decorator be used for holding values?)
96

97
  # Retrieve the location rules from holding values
98
  # @param holding [Hash] the holding values
99
  # @return [Hash] location values
100
  def holding_location_rules(holding)
1✔
101
    loc_code = holding.fetch('location_code', nil)
70✔
102
    return loc_code if loc_code.nil?
70✔
103
    @bib_data_service.holding_locations[loc_code.to_sym]
70✔
104
  end
105

106
  def temp_location_code(holding)
1✔
107
    holding['temp_location_code']
29✔
108
  end
109

110
  # Retrieve the call number from holding values
111
  # @param holding [Hash] the holding values
112
  # @return [String] the call number
113
  def call_number(holding)
1✔
114
    holding['call_number_browse'] || holding['call_number']
41✔
115
  end
116

117
  # Determine whether or not the holding is for a repository item
118
  # @return [TrueClass, FalseClass]
119
  def repository_holding?(holding)
1✔
120
    holding['dspace'] || holding['location_code'] == 'rare$num'
41✔
121
  end
122

123
  def sc_location_with_suppressed_button?(holding)
1✔
124
    additional_locations = ["rare$xmr", "mudd$scamudd", "rare$xrr", "rare$xgr", "rare$xcr", "mudd$phr"]
41✔
125
    holding['location_code'].start_with?('rare$sca') || additional_locations.include?(holding['location_code'])
41✔
126
  end
127

128
  # Determine whether or not the holding is for a SCSB items with ReCAP
129
  # @return [TrueClass, FalseClass]
130
  def scsb_holding?(holding)
1✔
131
    /^scsb.+/ =~ holding['location_code']
40✔
132
  end
133

134
  # Determine whether or not the holding has no child items
135
  # @return [TrueClass, FalseClass]
136
  def empty_holding?(holding)
1✔
137
    holding['items'].nil?
11✔
138
  end
139

140
  # Retrieve the restrictions for a given holding
141
  # Duplicates PhysicalHoldingsMarkupBuilder.scsb_list
142
  # @param holding [Hash]
143
  def restrictions_for_holding(holding)
1✔
144
    return [] unless holding.key? 'items'
49✔
145
    holding['items'].map { |values| values['use_statement'] }.compact_blank
1,786✔
146
  end
147

148
  # Determine whether or not the holding is explicitly marked as "Unavailable"
149
  # @return [TrueClass, FalseClass]
150
  def unavailable_holding?(holding)
1✔
151
    holding['dspace'] == false
70✔
152
  end
153

154
  # Determine whether or not the holding has a shelving title
155
  # @return [TrueClass, FalseClass]
156
  def shelving_title?(holding)
1✔
157
    !holding['shelving_title'].nil?
41✔
158
  end
159

160
  # Determine whether or not the holding has a location note
161
  # @return [TrueClass, FalseClass]
162
  def location_note?(holding)
1✔
163
    !holding['location_note'].nil?
41✔
164
  end
165

166
  # Determine whether or not the holding features a location
167
  # @return [TrueClass, FalseClass]
168
  def location_has?(holding)
1✔
169
    !holding['location_has'].nil?
41✔
170
  end
171

172
  # Determine whether or not the holding features a supplements note
173
  # @return [TrueClass, FalseClass]
174
  def supplements?(holding)
1✔
175
    holding['supplements']&.compact.present?
41✔
176
  end
177

178
  # Determine whether or not the holding features an index note
179
  # @return [TrueClass, FalseClass]
180
  def indexes?(holding)
1✔
181
    holding['indexes']&.compact.present?
41✔
182
  end
183

184
  # Determine whether or not the holding is for an Alma holding
185
  # @return [TrueClass, FalseClass]
186
  def alma_holding?(holding_id)
1✔
187
    return false if @document.fetch(:id, '').start_with?('SCSB')
41✔
188
    return false if %w[thesis numismatics visuals].include? holding_id
30✔
189
    true
29✔
190
  end
191
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc