hydra-pbcore 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hydra_pbcore/conversions.rb +32 -8
- data/lib/hydra_pbcore/version.rb +1 -1
- data/spec/fixtures/converted_digital_document_rrhof_1904.xml +8 -0
- data/spec/fixtures/converted_digital_document_rrhof_2405.xml +8 -0
- data/spec/fixtures/integration/digital_document_rrhof_1904.xml +4 -0
- data/spec/fixtures/integration/digital_document_rrhof_2405.xml +4 -0
- data/spec/integration/conversions_spec.rb +11 -8
- metadata +4 -4
@@ -39,18 +39,16 @@ module HydraPbcore::Conversions
|
|
39
39
|
self.ng_xml = self.ng_xml.xpath("//pbcoreInstantiation").to_xml
|
40
40
|
end
|
41
41
|
|
42
|
-
# Corrects errors in HydraPbcore::Datastream::Deprecated::Document
|
42
|
+
# Corrects errors in HydraPbcore::Datastream::Deprecated::Document
|
43
43
|
# - removes all pbcoreRelation nodes, except those that define event_series
|
44
44
|
# - removes orphaned pbcoreRelationIdentifier nodes
|
45
45
|
# - corrects invalid usage of event_place and event_series terms
|
46
|
-
#
|
47
|
-
# Note: Since pbcoreRelation is used to indicated archival collection and series, this information should be copied to another kind
|
48
|
-
# of datastream using an RDF relationship in Hydra.
|
49
46
|
def clean_document xml = self.ng_xml
|
50
47
|
xml.search("//pbcoreRelation").each do |node|
|
51
|
-
node.remove unless
|
48
|
+
node.remove unless is_relation?("Event Series", node)
|
52
49
|
end
|
53
50
|
xml.search("/pbcoreDescriptionDocument/pbcoreRelationIdentifier").collect {|n| n.remove}
|
51
|
+
xml.search("/pbcoreDescriptionDocument/instantiationRelationIdentifier").collect {|n| n.remove}
|
54
52
|
xml.search("//pbcoreCoverage").each do |node|
|
55
53
|
node.children.each do |c|
|
56
54
|
if c.attribute("annotation").nil? and c.name == "coverage"
|
@@ -61,10 +59,36 @@ module HydraPbcore::Conversions
|
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
64
|
-
#
|
65
|
-
|
62
|
+
# Corrects errors in HydraPbcore::Datastream::Deprecated::DigitalDocument
|
63
|
+
# - finds the current archival collection
|
64
|
+
# - removes all pbcoreRelation nodes, except those that define event_series
|
65
|
+
# - re-inserts the collection
|
66
|
+
# - removes orphaned pbcoreRelationIdentifier nodes
|
67
|
+
# - corrects invalid usage of event_place and event_series terms
|
68
|
+
def clean_digital_document xml = self.ng_xml
|
69
|
+
collection = xml.search("//pbcoreRelationIdentifier[@annotation='Archival Collection']").text
|
70
|
+
xml.search("//pbcoreRelation").each do |node|
|
71
|
+
unless is_relation?("Accession Number", node) or is_relation?("Event Series", node)
|
72
|
+
node.remove
|
73
|
+
end
|
74
|
+
end
|
75
|
+
xml.search("/pbcoreDescriptionDocument/pbcoreRelationIdentifier").collect {|n| n.remove}
|
76
|
+
xml.search("/pbcoreDescriptionDocument/instantiationRelationIdentifier").collect {|n| n.remove}
|
77
|
+
self.insert_relation(collection, "Archival Collection") unless collection.nil?
|
78
|
+
xml.search("//pbcoreCoverage").each do |node|
|
79
|
+
node.children.each do |c|
|
80
|
+
if c.attribute("annotation").nil? and c.name == "coverage"
|
81
|
+
self.send(("insert_"+coverage_type(node)), c.text)
|
82
|
+
c.remove
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Determines if the given node defines a relation of a give type
|
89
|
+
def is_relation? type, node
|
66
90
|
unless node.at_xpath("pbcoreRelationIdentifier").nil?
|
67
|
-
if node.at_xpath("pbcoreRelationIdentifier").attribute("annotation").to_s ==
|
91
|
+
if node.at_xpath("pbcoreRelationIdentifier").attribute("annotation").to_s == type
|
68
92
|
return true
|
69
93
|
end
|
70
94
|
end
|
data/lib/hydra_pbcore/version.rb
CHANGED
@@ -7,6 +7,14 @@
|
|
7
7
|
<pbcoreRelationType ref="http://pbcore.org/vocabularies/relationType#is-part-of" source="PBCore relationType">Is Part Of</pbcoreRelationType>
|
8
8
|
<pbcoreRelationIdentifier annotation="Event Series">Oral history project (Rock and Roll Hall of Fame and Museum)</pbcoreRelationIdentifier>
|
9
9
|
</pbcoreRelation>
|
10
|
+
<pbcoreRelation>
|
11
|
+
<pbcoreRelationType source="PBCore relationType" ref="http://pbcore.org/vocabularies/relationType#is-part-of">Is Part Of</pbcoreRelationType>
|
12
|
+
<pbcoreRelationIdentifier annotation="Archival Collection">Rock and Roll Hall of Fame and Museum records. Education and Public Programs Division. </pbcoreRelationIdentifier>
|
13
|
+
</pbcoreRelation>
|
14
|
+
<pbcoreRelation>
|
15
|
+
<pbcoreRelationType ref="http://pbcore.org/vocabularies/relationType#is-part-of" source="PBCore relationType">Is Part Of</pbcoreRelationType>
|
16
|
+
<pbcoreRelationIdentifier annotation="Accession Number"/>
|
17
|
+
</pbcoreRelation>
|
10
18
|
<pbcoreCoverage>
|
11
19
|
<coverage annotation="Event Place">Oklahoma City, OK</coverage>
|
12
20
|
<coverageType>Spatial</coverageType>
|
@@ -7,6 +7,14 @@
|
|
7
7
|
<pbcoreRelationType ref="http://pbcore.org/vocabularies/relationType#is-part-of" source="PBCore relationType">Is Part Of</pbcoreRelationType>
|
8
8
|
<pbcoreRelationIdentifier annotation="Event Series">Oral history project (Rock and Roll Hall of Fame and Museum)</pbcoreRelationIdentifier>
|
9
9
|
</pbcoreRelation>
|
10
|
+
<pbcoreRelation>
|
11
|
+
<pbcoreRelationType ref="http://pbcore.org/vocabularies/relationType#is-part-of" source="PBCore relationType">Is Part Of</pbcoreRelationType>
|
12
|
+
<pbcoreRelationIdentifier annotation="Accession Number">LA.2012.05.024</pbcoreRelationIdentifier>
|
13
|
+
</pbcoreRelation>
|
14
|
+
<pbcoreRelation>
|
15
|
+
<pbcoreRelationType ref="http://pbcore.org/vocabularies/relationType#is-part-of" source="PBCore relationType">Is Part Of</pbcoreRelationType>
|
16
|
+
<pbcoreRelationIdentifier annotation="Archival Collection">Rock and Roll Hall of Fame and Museum records. Education and Public Programs Division.</pbcoreRelationIdentifier>
|
17
|
+
</pbcoreRelation>
|
10
18
|
<pbcoreCoverage>
|
11
19
|
<coverage annotation="Event Place">Pound Ridge, New York</coverage>
|
12
20
|
<coverageType>Spatial</coverageType>
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
<pbcoreDescriptionDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html">
|
2
3
|
<pbcoreIdentifier annotation="PID" source="Rock and Roll Hall of Fame and Museum"></pbcoreIdentifier>
|
3
4
|
<pbcoreTitle titleType="Main">Oral history project. Wanda Jackson.</pbcoreTitle>
|
@@ -60,4 +61,7 @@
|
|
60
61
|
<pbcoreRelationIdentifier annotation="Archival Collection">Rock and Roll Hall of Fame and Museum records. Education and Public Programs Division. </pbcoreRelationIdentifier>
|
61
62
|
<pbcoreRelationIdentifier annotation="Collection Number">RG.0004</pbcoreRelationIdentifier>
|
62
63
|
<pbcoreSubject ref="http://id.loc.gov/authorities/subjects.html" source="Library of Congress Subject Headings">Inductee</pbcoreSubject>
|
64
|
+
<instantiationRelationIdentifier annotation="Archival collection">Rock and Roll Hall of Fame and Museum records. Education and Public Programs Division</instantiationRelationIdentifier>
|
65
|
+
<instantiationRelationIdentifier annotation="Archival Series">Oral history project</instantiationRelationIdentifier>
|
66
|
+
<instantiationRelationIdentifier annotation="Collection Number">RG.0004</instantiationRelationIdentifier>
|
63
67
|
</pbcoreDescriptionDocument>
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
<pbcoreDescriptionDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html">
|
2
3
|
<pbcoreIdentifier annotation="PID" source="Rock and Roll Hall of Fame and Museum"></pbcoreIdentifier>
|
3
4
|
<pbcoreTitle titleType="Main">Oral History project. Clive Davis.</pbcoreTitle>
|
@@ -59,4 +60,7 @@
|
|
59
60
|
<contributorRole source="MARC relator terms">producer</contributorRole>
|
60
61
|
</pbcoreContributor>
|
61
62
|
<pbcoreSubject ref="http://id.loc.gov/authorities/subjects.html" source="Library of Congress Subject Headings">Inductee</pbcoreSubject>
|
63
|
+
<instantiationRelationIdentifier annotation="Archival collection">Rock and Roll Hall of Fame and Museum records. Education and Public Programs Division</instantiationRelationIdentifier>
|
64
|
+
<instantiationRelationIdentifier annotation="Archival Series">Oral history project</instantiationRelationIdentifier>
|
65
|
+
<instantiationRelationIdentifier annotation="Collection Number">RG.0004</instantiationRelationIdentifier>
|
62
66
|
</pbcoreDescriptionDocument>
|
@@ -47,9 +47,10 @@ describe "Converting" do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "#clean_document" do
|
50
|
-
it "should correct invalid
|
51
|
-
["
|
52
|
-
doc = HydraPbcore::Datastream::Deprecated::
|
50
|
+
it "should correct invalid pbcoreDocuments" do
|
51
|
+
["document_rrhof_524.xml","document_rrhof_2439.xml"].each do |file|
|
52
|
+
doc = HydraPbcore::Datastream::Deprecated::Document.from_xml(integration_fixture file)
|
53
|
+
doc.to_document
|
53
54
|
doc.clean_document
|
54
55
|
save_template doc.to_xml, ("converted_"+file)
|
55
56
|
tmp_file_should_match_exemplar(("converted_"+file))
|
@@ -57,11 +58,13 @@ describe "Converting" do
|
|
57
58
|
doc.valid?.should == []
|
58
59
|
end
|
59
60
|
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#clean_digital_document" do
|
64
|
+
it "should correct invalid pbcoreDigitalDocuments" do
|
65
|
+
["digital_document_rrhof_1904.xml","digital_document_rrhof_2405.xml"].each do |file|
|
66
|
+
doc = HydraPbcore::Datastream::Deprecated::DigitalDocument.from_xml(integration_fixture file)
|
67
|
+
doc.clean_digital_document
|
65
68
|
save_template doc.to_xml, ("converted_"+file)
|
66
69
|
tmp_file_should_match_exemplar(("converted_"+file))
|
67
70
|
save_template doc.to_pbcore_xml, "valid_pbcore.xml"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-pbcore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active-fedora
|
@@ -219,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
219
|
version: '0'
|
220
220
|
segments:
|
221
221
|
- 0
|
222
|
-
hash:
|
222
|
+
hash: 3882171645005853524
|
223
223
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
224
|
none: false
|
225
225
|
requirements:
|
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
228
|
version: '0'
|
229
229
|
segments:
|
230
230
|
- 0
|
231
|
-
hash:
|
231
|
+
hash: 3882171645005853524
|
232
232
|
requirements: []
|
233
233
|
rubyforge_project:
|
234
234
|
rubygems_version: 1.8.23
|