From 8fee4ee94bd0e361ccbf0086b5af105aeb81e30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esm=C3=A9=20Cowles?= Date: Thu, 22 Dec 2016 11:12:49 -0500 Subject: [PATCH] Using RelatedObject order by default --- app/models/concerns/mets_structure.rb | 6 +- spec/fixtures/pudl0076-2538011.mets | 140 ++++++++++++++++++++++++++ spec/models/mets_document_spec.rb | 17 ++++ 3 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/pudl0076-2538011.mets diff --git a/app/models/concerns/mets_structure.rb b/app/models/concerns/mets_structure.rb index d0e5ce837..67db6e84c 100644 --- a/app/models/concerns/mets_structure.rb +++ b/app/models/concerns/mets_structure.rb @@ -1,6 +1,6 @@ module MetsStructure def structure - structure_type('Logical') + structure_type('Logical') || default_structure end def structure_for_volume(volume_id) @@ -27,6 +27,10 @@ def structure_type(type) { nodes: structure_for_nodeset(top) } end + def default_structure + { nodes: structure_for_nodeset(structure_map('RelatedObjects').xpath("mets:div/mets:div[@TYPE = 'OrderedList']/mets:div")) } + end + def structure_for_nodeset(nodeset) nodes = [] nodeset.each do |node| diff --git a/spec/fixtures/pudl0076-2538011.mets b/spec/fixtures/pudl0076-2538011.mets new file mode 100644 index 000000000..a8d151f48 --- /dev/null +++ b/spec/fixtures/pudl0076-2538011.mets @@ -0,0 +1,140 @@ + + + +pudl0076/2538011.mets + + + + + + + + + + De l'espirit des loix + ou Du rapport que les loix doivent avoir avec la constitution de chaque gouvernemnent, les moeurs, + le climat, la religion, le commerce, & c., a quoi l'auteur a ajout e des recherches nouvelles, sur + les loix romaines touchant le successions, sur les loix francoises, & sur les loix feodales + + + Montesquieu, Charles de Secondat + baron de + 1689-1755 + + aut + + + + Varnet, Jean Jacob + 1698-1789 + + aut + + + text + + + Geneve + + Barrollot & fils + 1748 + + + fre + + + 2 v. in 1. fold. map (v. 2) 18 cm. + + Catalogue of the Bibliothe`que Nationale lists 4 issues of the 1st ed., 1748; with this t.p. and imprint + (save for spelling og francoises -- their error ?) The first 3 notes are 2 v., the 4, the 4th is 3 v., 12. + Later editions, 1748 etc., have different imprints, or notes of ed. on t.p. + Original ed., prepared at same time as that in 4 in 1748 containing the map for the illustration of the + text, which is lacking often": ms. note, back of v. 1. + First edition; edited by J.J. Varnet. cf. Brunet, Manuel du librarie. + + Political science + + + State, The + + + Law (Philosophical concept) + + + Jurisprudence + + + text + + The Sid Lapidus '59 Collection on Liberty and the American Revolution + + + http://pudl.princeton.edu/collections/pudl0076 + + + + Princeton University Library. Department of Rare Books and Special Collections. + NjP + + + ex + Lapidus 1.16 + + + + + NjP + http://catalog.princeton.edu/cgi-bin/Pwebrecon.cgi?BBID=2538011 + http://diglib.princeton.edu/mdata/pudl0076/2538011.mods + + eng + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/models/mets_document_spec.rb b/spec/models/mets_document_spec.rb index 5ee9c33cb..a98fec7fb 100644 --- a/spec/models/mets_document_spec.rb +++ b/spec/models/mets_document_spec.rb @@ -7,6 +7,7 @@ let(:mets_file_multi2) { Rails.root.join("spec", "fixtures", "pudl0058-616086.mets") } let(:mets_file_multi3) { Rails.root.join("spec", "fixtures", "pudl0134-170151.mets") } let(:tight_bound_mets_file) { Rails.root.join("spec", "fixtures", "pudl0075-6971526.mets") } + let(:no_logical_order_mets_file) { Rails.root.join("spec", "fixtures", "pudl0076-2538011.mets") } let(:tiff_file) { Rails.root.join("spec", "fixtures", "files", "color.tif") } let(:structure) { { nodes: [{ @@ -27,6 +28,14 @@ ] }] }} + let(:flat_structure) { { + nodes: [ + { proxy: "s45u4", label: "vol 1 front cover" }, + { proxy: "x04jf", label: "vol 1 pastedown" }, + { proxy: "iocby", label: "vol 1 front flyleaf 1" }, + { proxy: "jiots", label: "vol 1 front flyleaf 1v" } + ] + }} describe "identifiers" do subject { described_class.new mets_file } @@ -190,5 +199,13 @@ expect(subject.files_for_volume('v2log').length).to eq 492 end end + + context "an item with no logical structmap" do + subject { described_class.new no_logical_order_mets_file } + + it "defaults to the RelatedObjects order" do + expect(subject.structure).to eq flat_structure + end + end end end