Skip to content

Commit

Permalink
Merge pull request #48 from mlibrary/alma-digital
Browse files Browse the repository at this point in the history
adds logic to handle a digital holding
  • Loading branch information
niquerio authored Apr 3, 2023
2 parents a84cb42 + b678df6 commit 50a29ef
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 1 deletion.
1 change: 1 addition & 0 deletions umich_catalog_indexing/lib/umich_traject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

require 'umich_traject/enumcron_sorter'
require 'umich_traject/holdings'
require 'umich_traject/digital_holding'
require 'umich_traject/physical_holding'
require 'umich_traject/physical_item'

Expand Down
42 changes: 42 additions & 0 deletions umich_catalog_indexing/lib/umich_traject/digital_holding.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module Traject
module UMich
class DigitalHolding
def initialize(avd)
@avd = avd
end
def note
@avd["z"]
end
def link
URI::Parser.new.escape(@avd["u"].sub("01UMICH_INST:FLINT","01UMICH_INST:UMICH"))
end
def library
"ELEC"
end
def status
"Available"
end
def link_text
"Available online"
end
def description
""
end
def finding_aid
false
end
def to_h
{
finding_aid: finding_aid,
library: library,
link: link,
link_text: link_text,
note: note,
status: status,
description: description
}
end

end
end
end
16 changes: 15 additions & 1 deletion umich_catalog_indexing/lib/umich_traject/holdings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def run
inst_codes << 'MIFLIC'
hol[:link].sub!("openurl", "openurl-UMFL")
else # should't occur
logge@record.info "#{id} : can't process campus info for E56 (#{sub_c_list})"
logger @record.info "#{id} : can't process campus info for E56 (#{sub_c_list})"
end
has_e56 = true
end
Expand Down Expand Up @@ -132,6 +132,16 @@ def run

end
end
digital_holdings = avd.map do |field|
DigitalHolding.new(field)
end
digital_holdings.each do |holding|
hol_list << holding.to_h
locations << holding.library
inst_codes << "MIU"
availability << "avail_online"
end


physical_holdings = physical_holding_ids.map do |id|
PhysicalHolding.new(record: @record, holding_id: id)
Expand Down Expand Up @@ -190,6 +200,10 @@ def physical_holding_ids
@record.fields("852").any? {|f| f["8"] == h }
end
end

def avd
@avd ||= @record.fields("AVD")
end

def statusFromRights(rights, etas = false)

Expand Down
3 changes: 3 additions & 0 deletions umich_catalog_indexing/spec/fixtures/arborist_avd.xml

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions umich_catalog_indexing/spec/traject/umich/digital_holding_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
require "traject"
require "umich_traject"
describe Traject::UMich::DigitalHolding do
def get_record(path)
reader = MARC::XMLReader.new(path)
for r in reader
return r
end
end
let(:arborist) do
get_record('./spec/fixtures/arborist_avd.xml')
end
let(:avd) do
arborist.fields("AVD").first
end
subject do
described_class.new(avd)
end
context "#link" do
it "returns the link with the UMICH view" do
expect(subject.link).to eq("https://umich-psb.alma.exlibrisgroup.com/discovery/delivery/01UMICH_INST:UMICH/121230624780006381")
end
end
context "#note" do
it "returns the z field" do
expect(subject.note).to eq("This is a Public Note")
end
end
context "#library" do
it "shows ELEC" do
expect(subject.library).to eq("ELEC")
end
end
context "#status" do
it "shows Available" do
expect(subject.status).to eq("Available")
end
end
context "#link_text" do
it "shows Available online" do
expect(subject.link_text).to eq("Available online")
end
end
context "#description" do
it "shows empty string" do
expect(subject.description).to eq("")
end
end
context "#finding_aid" do
it "is false" do
expect(subject.finding_aid).to eq(false)
end
end
context "#to_h" do
it "returns expected hash" do
expect(subject.to_h).to eq(
{
finding_aid: false,
library: "ELEC",
link: "https://umich-psb.alma.exlibrisgroup.com/discovery/delivery/01UMICH_INST:UMICH/121230624780006381",
link_text: "Available online",
note: "This is a Public Note",
status: "Available",
description: ""
}
)
end
end
end

0 comments on commit 50a29ef

Please sign in to comment.