hydra-pbcore 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/hydra-pbcore.gemspec +4 -3
- data/lib/custom_mapper.rb +40 -0
- data/lib/hydra-pbcore.rb +2 -1
- data/lib/hydra-pbcore/datastream/digital_document.rb +2 -120
- data/lib/hydra-pbcore/datastream/document.rb +165 -115
- data/lib/hydra-pbcore/datastream/instantiation.rb +112 -62
- data/lib/hydra-pbcore/methods.rb +1 -87
- data/lib/hydra-pbcore/templates.rb +58 -0
- data/lib/hydra-pbcore/version.rb +3 -0
- data/spec/custom_mapper_spec.rb +14 -0
- data/spec/digital_document_spec.rb +93 -11
- data/spec/document_spec.rb +114 -15
- data/spec/fixtures/pbcore_document_template.xml +8 -4
- data/spec/fixtures/pbcore_solr_digital_document_template.xml +605 -0
- data/spec/fixtures/pbcore_solr_document_template.xml +692 -0
- data/spec/fixtures/pbcore_solr_instantiation_template.xml +1481 -0
- data/spec/instantiation_spec.rb +73 -5
- data/spec/templates_spec.rb +0 -0
- metadata +19 -8
- data/spec/methods_spec.rb +0 -63
@@ -2,90 +2,140 @@ module HydraPbcore::Datastream
|
|
2
2
|
class Instantiation < ActiveFedora::NokogiriDatastream
|
3
3
|
|
4
4
|
include HydraPbcore::Methods
|
5
|
+
include HydraPbcore::Templates
|
5
6
|
|
6
7
|
# Note: this is not a complete PBCore document, just an instantiation node
|
7
8
|
set_terminology do |t|
|
8
|
-
t.root(:path=>"pbcoreDescriptionDocument"
|
9
|
-
|
10
|
-
t.pbcoreInstantiation(:namespace_prefix=>nil) {
|
11
|
-
|
12
|
-
t.instantiationIdentifier(:namespace_prefix=>nil, :attributes=>{ :annotation=>"Filename", :source=>"Rock and Roll Hall of Fame and Museum" })
|
13
|
-
t.instantiationDate(:namespace_prefix=>nil, :attributes=>{ :dateType=>"created" })
|
14
|
-
t.instantiationDigital(:namespace_prefix=>nil, :attributes=>{ :source=>"EBU file formats" })
|
15
|
-
t.instantiationStandard(:namespace_prefix=>nil)
|
16
|
-
t.instantiationLocation(:namespace_prefix=>nil)
|
17
|
-
t.instantiationGenerations(:namespace_prefix=>nil, :attributes=>{ :source=>"PBCore instantiationGenerations" })
|
18
|
-
t.instantiationFileSize(:namespace_prefix=>nil) {
|
19
|
-
t.units(:path=>{:attribute=>"unitsOfMeasure"}, :namespace_prefix=>nil)
|
20
|
-
}
|
21
|
-
t.instantiationColors(:namespace_prefix=>nil, :attributes=>{ :source=>"PBCore instantiationColors" })
|
22
|
-
t.instantiationMediaType(:namespace_prefix=>nil, :attributes=>{ :source=>"PBCore instantiationMediaType" })
|
23
|
-
t.instantiationLanguage(:namespace_prefix=>nil, :attributes=>{ :source=>"ISO 639.2", :ref=>"http://www.loc.gov/standards/iso639-2/php/code_list.php" })
|
24
|
-
t.instantiationDuration(:namespace_prefix=>nil)
|
9
|
+
t.root(:path=>"pbcoreDescriptionDocument")
|
25
10
|
|
26
|
-
|
27
|
-
t.rightsSummary(:namespace_prefix=>nil)
|
28
|
-
}
|
11
|
+
t.pbcoreInstantiation do
|
29
12
|
|
30
|
-
t.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
13
|
+
t.instantiationIdentifier(
|
14
|
+
:attributes=>{
|
15
|
+
:annotation=>"Filename",
|
16
|
+
:source=>"Rock and Roll Hall of Fame and Museum"
|
17
|
+
},
|
18
|
+
:index_as => [:displayable]
|
19
|
+
)
|
20
|
+
t.instantiationDate(:attributes=>{ :dateType=>"created" },
|
21
|
+
:index_as => [:displayable, :searchable]
|
22
|
+
)
|
23
|
+
t.instantiationDigital(:attributes=>{ :source=>"EBU file formats" },
|
24
|
+
:index_as => [:searchable, :facetable]
|
25
|
+
)
|
26
|
+
t.instantiationStandard(:index_as => [:displayable])
|
27
|
+
t.instantiationLocation(:index_as => [:displayable])
|
28
|
+
t.instantiationGenerations(:attributes=>{ :source=>"PBCore instantiationGenerations" },
|
29
|
+
:index_as => [:displayable]
|
30
|
+
)
|
31
|
+
t.instantiationFileSize(:index_as => [:displayable]) do
|
32
|
+
t.units(:path=>{:attribute=>"unitsOfMeasure"}, :index_as => [:displayable])
|
33
|
+
end
|
34
|
+
t.instantiationColors(:attributes=>{ :source=>"PBCore instantiationColors" },
|
35
|
+
:index_as => [:displayable]
|
36
|
+
)
|
37
|
+
t.instantiationMediaType(:attributes=>{ :source=>"PBCore instantiationMediaType" },
|
38
|
+
:index_as => [:facetable]
|
39
|
+
)
|
40
|
+
t.instantiationLanguage(
|
41
|
+
:attributes=>{
|
42
|
+
:source=>"ISO 639.2",
|
43
|
+
:ref=>"http://www.loc.gov/standards/iso639-2/php/code_list.php"
|
44
|
+
},
|
45
|
+
:index_as => [:searchable]
|
46
|
+
)
|
47
|
+
t.instantiationDuration(:index_as => [:displayable])
|
48
|
+
|
49
|
+
t.instantiationRights do
|
50
|
+
t.rightsSummary(:index_as => [:displayable])
|
51
|
+
end
|
52
|
+
|
53
|
+
t.instantiationEssenceTrack do
|
54
|
+
t.essenceTrackStandard(:index_as => [:displayable])
|
55
|
+
t.essenceTrackEncoding( :attributes=>{ :source=>"PBCore essenceTrackEncoding" },
|
56
|
+
:index_as => [:displayable]
|
57
|
+
)
|
58
|
+
t.essenceTrackDataRate(:index_as => [:displayable]) do
|
59
|
+
t.units(:path=>{:attribute=>"unitsOfMeasure"}, :index_as => [:displayable])
|
60
|
+
end
|
61
|
+
t.essenceTrackFrameRate(:attributes=>{ :unitsOfMeasure=>"fps" }, :index_as => [:displayable])
|
62
|
+
t.essenceTrackFrameSize(:attributes=>{ :source=>"PBCore essenceTrackFrameSize" }, :index_as => [:displayable])
|
63
|
+
t.essenceTrackBitDepth(:index_as => [:displayable])
|
64
|
+
t.essenceTrackAspectRatio(:attributes=>{ :source=>"PBCore essenceTrackAspectRatio" },
|
65
|
+
:index_as => [:displayable]
|
66
|
+
)
|
67
|
+
t.essenceTrackSamplingRate(:index_as => [:displayable]) do
|
68
|
+
t.units(:path=>{:attribute=>"unitsOfMeasure"}, :index_as => [:displayable])
|
69
|
+
end
|
70
|
+
t.essenceTrackAnnotation( :attributes=>{ :annotationType=>"Number of Audio Channels" },
|
71
|
+
:index_as => [:displayable]
|
72
|
+
)
|
73
|
+
end
|
45
74
|
t.video_essence(:ref => [:pbcoreInstantiation, :instantiationEssenceTrack],
|
46
|
-
:path=>'instantiationEssenceTrack[essenceTrackType="Video"]'
|
47
|
-
:namespace_prefix=>nil
|
75
|
+
:path=>'instantiationEssenceTrack[essenceTrackType="Video"]'
|
48
76
|
)
|
49
77
|
t.audio_essence(:ref => [:pbcoreInstantiation, :instantiationEssenceTrack],
|
50
|
-
:path=>'instantiationEssenceTrack[essenceTrackType="Audio"]'
|
51
|
-
:namespace_prefix=>nil
|
78
|
+
:path=>'instantiationEssenceTrack[essenceTrackType="Audio"]'
|
52
79
|
)
|
53
80
|
|
54
|
-
t.instantiationRelation
|
55
|
-
t.instantiationRelationIdentifier(:
|
56
|
-
|
81
|
+
t.instantiationRelation do
|
82
|
+
t.instantiationRelationIdentifier(:attributes=>{ :source=>"Rock and Roll Hall of Fame and Museum" })
|
83
|
+
end
|
57
84
|
# The file we're describing at the root of this document preceeds the file marked "next"
|
58
85
|
t.next_inst(:ref => [:pbcoreInstantiation, :instantiationRelation],
|
59
|
-
|
60
|
-
:namespace_prefix=>nil
|
86
|
+
:path=>'instantiationRelation[instantiationRelationType="Precedes in Sequence"]'
|
61
87
|
)
|
62
88
|
# The file we're describing at the root of this document comes after the file marked "previous"
|
63
89
|
t.previous_inst(:ref => [:pbcoreInstantiation, :instantiationRelation],
|
64
|
-
|
65
|
-
:namespace_prefix=>nil
|
90
|
+
:path=>'instantiationRelation[instantiationRelationType="Follows in Sequence"]'
|
66
91
|
)
|
67
92
|
|
68
93
|
# Instantitation annotiations
|
69
|
-
t.inst_chksum_type(:path=>"instantiationAnnotation", :
|
70
|
-
|
71
|
-
|
72
|
-
t.
|
73
|
-
|
74
|
-
|
75
|
-
t.
|
76
|
-
|
77
|
-
|
78
|
-
t.
|
79
|
-
|
80
|
-
|
81
|
-
t.
|
82
|
-
|
83
|
-
|
94
|
+
t.inst_chksum_type(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Checksum Type" },
|
95
|
+
:index_as => [:displayable]
|
96
|
+
)
|
97
|
+
t.inst_chksum_value(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Checksum Value" },
|
98
|
+
:index_as => [:displayable]
|
99
|
+
)
|
100
|
+
t.inst_device(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Playback Device" },
|
101
|
+
:index_as => [:displayable]
|
102
|
+
)
|
103
|
+
t.inst_capture_soft(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Capture Software" },
|
104
|
+
:index_as => [:displayable]
|
105
|
+
)
|
106
|
+
t.inst_trans_soft(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Transcoding Software" },
|
107
|
+
:index_as => [:displayable]
|
108
|
+
)
|
109
|
+
t.inst_operator(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Operator" },
|
110
|
+
:index_as => [:displayable]
|
111
|
+
)
|
112
|
+
t.inst_trans_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Transfer Notes" },
|
113
|
+
:index_as => [:displayable]
|
114
|
+
)
|
115
|
+
t.inst_vendor(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Vendor Name" },
|
116
|
+
:index_as => [:displayable]
|
117
|
+
)
|
118
|
+
t.inst_cond_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Condition Notes" },
|
119
|
+
:index_as => [:displayable]
|
120
|
+
)
|
121
|
+
t.inst_clean_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Cleaning Notes" },
|
122
|
+
:index_as => [:displayable]
|
123
|
+
)
|
124
|
+
t.inst_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Notes" },
|
125
|
+
:index_as => [:displayable]
|
126
|
+
)
|
127
|
+
t.inst_color_space(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Color Space" },
|
128
|
+
:index_as => [:displayable]
|
129
|
+
)
|
130
|
+
t.inst_chroma(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Chroma" },
|
131
|
+
:index_as => [:displayable]
|
132
|
+
)
|
133
|
+
|
134
|
+
end
|
84
135
|
|
85
136
|
#
|
86
137
|
# Here are the actual references to the fields
|
87
138
|
#
|
88
|
-
|
89
139
|
t.name(:proxy=>[:pbcoreInstantiation, :instantiationIdentifier])
|
90
140
|
t.location(:proxy=>[:pbcoreInstantiation, :instantiationLocation])
|
91
141
|
t.date(:proxy=>[:pbcoreInstantiation, :instantiationDate])
|
data/lib/hydra-pbcore/methods.rb
CHANGED
@@ -1,94 +1,8 @@
|
|
1
1
|
module HydraPbcore::Methods
|
2
2
|
|
3
|
-
# Module for inserting different types of PBcore xml nodes into
|
4
|
-
# an existing PBcore document
|
5
|
-
|
6
|
-
module ClassMethods
|
7
|
-
|
8
|
-
def publisher_template(opts={})
|
9
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
10
|
-
xml.pbcorePublisher {
|
11
|
-
xml.publisher
|
12
|
-
xml.publisherRole(:source=>"PBCore publisherRole")
|
13
|
-
}
|
14
|
-
end
|
15
|
-
return builder.doc.root
|
16
|
-
end
|
17
|
-
|
18
|
-
def contributor_template(opts={})
|
19
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
20
|
-
xml.pbcoreContributor {
|
21
|
-
xml.contributor
|
22
|
-
xml.contributorRole(:source=>"MARC relator terms")
|
23
|
-
}
|
24
|
-
end
|
25
|
-
return builder.doc.root
|
26
|
-
end
|
27
|
-
|
28
|
-
def previous_template(opts={})
|
29
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
30
|
-
xml.instantiationRelation {
|
31
|
-
xml.instantiationRelationType(:annotation=>"One of a multi-part instantiation") {
|
32
|
-
xml.text "Follows in Sequence"
|
33
|
-
}
|
34
|
-
xml.instantiationRelationIdentifier(:source=>"Rock and Roll Hall of Fame and Museum")
|
35
|
-
}
|
36
|
-
end
|
37
|
-
return builder.doc.root
|
38
|
-
end
|
39
|
-
|
40
|
-
def next_template(opts={})
|
41
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
42
|
-
xml.instantiationRelation {
|
43
|
-
xml.instantiationRelationType(:annotation=>"One of a multi-part instantiation") {
|
44
|
-
xml.text "Precedes in Sequence"
|
45
|
-
}
|
46
|
-
xml.instantiationRelationIdentifier(:source=>"Rock and Roll Hall of Fame and Museum")
|
47
|
-
}
|
48
|
-
end
|
49
|
-
return builder.doc.root
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.included(klass)
|
55
|
-
klass.extend(ClassMethods)
|
56
|
-
end
|
57
|
-
|
58
|
-
def insert_node(type, opts={})
|
59
|
-
|
60
|
-
unless self.class.respond_to?("#{type}_template".to_sym)
|
61
|
-
raise "No XML template is defined for a PBcore node of type #{type}."
|
62
|
-
end
|
63
|
-
|
64
|
-
node = self.class.send("#{type}_template".to_sym)
|
65
|
-
nodeset = self.find_by_terms(type.to_sym)
|
66
|
-
|
67
|
-
unless nodeset.nil?
|
68
|
-
if nodeset.empty?
|
69
|
-
if opts[:root]
|
70
|
-
self.find_by_terms(opts[:root].to_sym).first.add_child(node)
|
71
|
-
else
|
72
|
-
self.ng_xml.root.add_child(node)
|
73
|
-
end
|
74
|
-
index = 0
|
75
|
-
else
|
76
|
-
nodeset.after(node)
|
77
|
-
index = nodeset.length
|
78
|
-
end
|
79
|
-
self.dirty = true
|
80
|
-
end
|
81
|
-
|
82
|
-
return node, index
|
83
|
-
|
84
|
-
end
|
85
3
|
|
86
4
|
def remove_node(type, index)
|
87
|
-
|
88
|
-
self.find_by_terms(type.to_sym).slice(index.to_i).parent.remove
|
89
|
-
else
|
90
|
-
self.find_by_terms(type.to_sym).slice(index.to_i).remove
|
91
|
-
end
|
5
|
+
self.find_by_terms(type.to_sym).slice(index.to_i).remove
|
92
6
|
self.dirty = true
|
93
7
|
end
|
94
8
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module HydraPbcore::Templates
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
class_eval do
|
6
|
+
|
7
|
+
define_template :publisher do |xml, publisher, role|
|
8
|
+
xml.pbcorePublisher {
|
9
|
+
xml.publisher(publisher)
|
10
|
+
xml.publisherRole(role, :source=>"PBCore publisherRole")
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
define_template :contributor do |xml, author, role|
|
15
|
+
xml.pbcoreContributor {
|
16
|
+
xml.contributor(author)
|
17
|
+
xml.contributorRole(role, :source=>"MARC relator terms")
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
define_template :previous do |xml, pid|
|
22
|
+
xml.instantiationRelation {
|
23
|
+
xml.instantiationRelationType(:annotation=>"One of a multi-part instantiation") {
|
24
|
+
xml.text "Follows in Sequence"
|
25
|
+
}
|
26
|
+
xml.instantiationRelationIdentifier(pid, :source=>"Rock and Roll Hall of Fame and Museum")
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
define_template :next do |xml, pid|
|
31
|
+
xml.instantiationRelation {
|
32
|
+
xml.instantiationRelationType(:annotation=>"One of a multi-part instantiation") {
|
33
|
+
xml.text "Precedes in Sequence"
|
34
|
+
}
|
35
|
+
xml.instantiationRelationIdentifier(pid, :source=>"Rock and Roll Hall of Fame and Museum")
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def insert_contributor(author=nil, role=nil)
|
43
|
+
add_child_node(ng_xml.root, :contributor, author, role)
|
44
|
+
end
|
45
|
+
|
46
|
+
def insert_publisher(publisher=nil, role=nil)
|
47
|
+
add_child_node(ng_xml.root, :publisher, publisher, role)
|
48
|
+
end
|
49
|
+
|
50
|
+
def insert_next(pid)
|
51
|
+
add_child_node(find_by_terms(:pbcoreInstantiation).first, :next, pid)
|
52
|
+
end
|
53
|
+
|
54
|
+
def insert_previous(pid)
|
55
|
+
add_child_node(find_by_terms(:pbcoreInstantiation).first, :previous, pid)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Solrizer::FieldMapper::Default do
|
4
|
+
|
5
|
+
describe "#pbcore_date" do
|
6
|
+
|
7
|
+
it "should return valid dates from only partial ones" do
|
8
|
+
Solrizer::FieldMapper::Default.pbcore_date('2003').should == "2003-01-01"
|
9
|
+
Solrizer::FieldMapper::Default.pbcore_date('2009-07').should == "2009-07-01"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -29,7 +29,6 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
29
29
|
[:lc_subject_genre],
|
30
30
|
[:event_series],
|
31
31
|
[:event_place],
|
32
|
-
[:event_date],
|
33
32
|
[:contributor_name],
|
34
33
|
[:contributor_role],
|
35
34
|
[:publisher_name],
|
@@ -49,8 +48,8 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
49
48
|
end
|
50
49
|
|
51
50
|
it "should work for fields that require added xml nodes" do
|
52
|
-
@object_ds.
|
53
|
-
@object_ds.
|
51
|
+
@object_ds.insert_publisher
|
52
|
+
@object_ds.insert_contributor
|
54
53
|
[
|
55
54
|
[:publisher_name],
|
56
55
|
[:publisher_role],
|
@@ -65,8 +64,8 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
65
64
|
end
|
66
65
|
|
67
66
|
it "should differentiate between multiple added nodes" do
|
68
|
-
@object_ds.
|
69
|
-
@object_ds.
|
67
|
+
@object_ds.insert_contributor
|
68
|
+
@object_ds.insert_contributor
|
70
69
|
@object_ds.update_indexed_attributes( {[:contributor_name] => { 0 => "first contributor" }} )
|
71
70
|
@object_ds.update_indexed_attributes( {[:contributor_name] => { 1 => "second contributor" }} )
|
72
71
|
@object_ds.update_indexed_attributes( {[:contributor_role] => { 0 => "first contributor role" }} )
|
@@ -83,10 +82,10 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
83
82
|
describe "#xml_template" do
|
84
83
|
it "should return an empty xml document matching a valid exmplar" do
|
85
84
|
# insert additional nodes
|
86
|
-
@object_ds.
|
87
|
-
@object_ds.
|
88
|
-
@object_ds.
|
89
|
-
@object_ds.
|
85
|
+
@object_ds.insert_publisher
|
86
|
+
@object_ds.insert_contributor
|
87
|
+
@object_ds.insert_publisher
|
88
|
+
@object_ds.insert_contributor
|
90
89
|
|
91
90
|
# update additional nodes that OM will insert automatically
|
92
91
|
@object_ds.update_indexed_attributes({ [:alternative_title] => { 0 => "inserted" }} )
|
@@ -128,6 +127,7 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
128
127
|
|
129
128
|
describe ".insert_node" do
|
130
129
|
it "should return a node and index for a given template type" do
|
130
|
+
pending "Don't need this?"
|
131
131
|
["publisher", "contributor"].each do |type|
|
132
132
|
node, index = @object_ds.insert_node(type.to_s)
|
133
133
|
index.should == 0
|
@@ -145,8 +145,8 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
145
145
|
describe ".remove_node" do
|
146
146
|
it "should remove a node a given type and index" do
|
147
147
|
["publisher", "contributor"].each do |type|
|
148
|
-
@object_ds.
|
149
|
-
@object_ds.
|
148
|
+
@object_ds.send("insert_"+type)
|
149
|
+
@object_ds.send("insert_"+type)
|
150
150
|
@object_ds.find_by_terms(type.to_sym).count.should == 2
|
151
151
|
@object_ds.remove_node(type.to_sym, "1")
|
152
152
|
@object_ds.find_by_terms(type.to_sym).count.should == 1
|
@@ -166,4 +166,86 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
166
166
|
|
167
167
|
end
|
168
168
|
|
169
|
+
describe ".to_solr" do
|
170
|
+
|
171
|
+
before(:each) do
|
172
|
+
# insert additional nodes
|
173
|
+
@object_ds.insert_publisher
|
174
|
+
@object_ds.insert_contributor
|
175
|
+
[
|
176
|
+
"pbc_id",
|
177
|
+
"main_title",
|
178
|
+
"alternative_title",
|
179
|
+
"chapter",
|
180
|
+
"episode",
|
181
|
+
"label",
|
182
|
+
"segment",
|
183
|
+
"subtitle",
|
184
|
+
"track",
|
185
|
+
"translation",
|
186
|
+
"summary",
|
187
|
+
"parts_list",
|
188
|
+
"lc_subject",
|
189
|
+
"lc_name",
|
190
|
+
"rh_subject",
|
191
|
+
"getty_genre",
|
192
|
+
"lc_genre",
|
193
|
+
"lc_subject_genre",
|
194
|
+
"event_series",
|
195
|
+
"event_place",
|
196
|
+
"contributor_name",
|
197
|
+
"contributor_role",
|
198
|
+
"publisher_name",
|
199
|
+
"publisher_role",
|
200
|
+
"note",
|
201
|
+
"archival_collection",
|
202
|
+
"archival_series",
|
203
|
+
"collection_number",
|
204
|
+
"accession_number",
|
205
|
+
"usage"
|
206
|
+
].each do |field|
|
207
|
+
@object_ds.send("#{field}=".to_sym, field)
|
208
|
+
end
|
209
|
+
# update additional nodes that OM will insert automatically
|
210
|
+
@object_ds.update_indexed_attributes({ [:alternative_title] => { 0 => "inserted" }} )
|
211
|
+
@object_ds.update_indexed_attributes({ [:chapter] => { 0 => "inserted" }} )
|
212
|
+
@object_ds.update_indexed_attributes({ [:episode] => { 0 => "inserted" }} )
|
213
|
+
@object_ds.update_indexed_attributes({ [:label] => { 0 => "inserted" }} )
|
214
|
+
@object_ds.update_indexed_attributes({ [:segment] => { 0 => "inserted" }} )
|
215
|
+
@object_ds.update_indexed_attributes({ [:subtitle] => { 0 => "inserted" }} )
|
216
|
+
@object_ds.update_indexed_attributes({ [:track] => { 0 => "inserted" }} )
|
217
|
+
@object_ds.update_indexed_attributes({ [:translation] => { 0 => "inserted" }} )
|
218
|
+
@object_ds.update_indexed_attributes({ [:lc_subject] => { 0 => "inserted" }} )
|
219
|
+
@object_ds.update_indexed_attributes({ [:lc_name] => { 0 => "inserted" }} )
|
220
|
+
@object_ds.update_indexed_attributes({ [:rh_subject] => { 0 => "inserted" }} )
|
221
|
+
@object_ds.update_indexed_attributes({ [:getty_genre] => { 0 => "inserted" }} )
|
222
|
+
@object_ds.update_indexed_attributes({ [:lc_genre] => { 0 => "inserted" }} )
|
223
|
+
@object_ds.update_indexed_attributes({ [:lc_subject_genre] => { 0 => "inserted" }} )
|
224
|
+
@object_ds.update_indexed_attributes({ [:subject] => { 0 => "inserted" }} )
|
225
|
+
@object_ds.update_indexed_attributes({ [:genre] => { 0 => "inserted" }} )
|
226
|
+
|
227
|
+
# Use ISO 8601 dates
|
228
|
+
@object_ds.event_date = "2012-11-11"
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should match an exmplar" do
|
232
|
+
# Load example fixture
|
233
|
+
f = fixture "pbcore_solr_digital_document_template.xml"
|
234
|
+
ref_node = Nokogiri::XML(f)
|
235
|
+
f.close
|
236
|
+
|
237
|
+
# Nokogiri-fy our sample document
|
238
|
+
sample_node = Nokogiri::XML(@object_ds.to_solr.to_xml)
|
239
|
+
|
240
|
+
# Save this for later...
|
241
|
+
out = File.new("tmp/pbcore_solr_digital_document_sample.xml", "w")
|
242
|
+
out.write(sample_node.to_s)
|
243
|
+
out.close
|
244
|
+
|
245
|
+
EquivalentXml.equivalent?(ref_node, sample_node, opts = { :element_order => false, :normalize_whitespace => true }).should be_true
|
246
|
+
end
|
247
|
+
|
248
|
+
|
249
|
+
end
|
250
|
+
|
169
251
|
end
|