hydra-pbcore 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Rakefile +6 -0
- data/lib/hydra-pbcore.rb +60 -1
- data/lib/hydra-pbcore/behaviors.rb +4 -2
- data/lib/hydra-pbcore/conversions.rb +88 -0
- data/lib/hydra-pbcore/datastream/{digital_document.rb → deprecated/digital_document.rb} +3 -2
- data/lib/hydra-pbcore/datastream/deprecated/document.rb +310 -0
- data/lib/hydra-pbcore/datastream/deprecated/instantiation.rb +261 -0
- data/lib/hydra-pbcore/datastream/document.rb +37 -139
- data/lib/hydra-pbcore/datastream/instantiation.rb +184 -223
- data/lib/hydra-pbcore/methods.rb +23 -2
- data/lib/hydra-pbcore/templates.rb +116 -0
- data/lib/hydra-pbcore/version.rb +1 -1
- data/spec/{digital_document_spec.rb → deprecated/digital_document_spec.rb} +6 -26
- data/spec/deprecated/document_spec.rb +282 -0
- data/spec/deprecated/instantiation_spec.rb +214 -0
- data/spec/document_spec.rb +71 -194
- data/spec/fixtures/converted_digital_document_rrhof_1904.xml +53 -0
- data/spec/fixtures/converted_digital_document_rrhof_2405.xml +46 -0
- data/spec/fixtures/converted_document_rrhof_2439.xml +19 -0
- data/spec/fixtures/converted_document_rrhof_524.xml +45 -0
- data/spec/fixtures/converted_instantiation_rrhof_1184.xml +39 -0
- data/spec/fixtures/converted_rrhof_524.xml +45 -0
- data/spec/fixtures/converted_rrhof_524_instantiation.xml +18 -0
- data/spec/fixtures/{pbcore_digital_document_template.xml → deprecated/pbcore_digital_document_template.xml} +0 -0
- data/spec/fixtures/{pbcore_document_template.xml → deprecated/pbcore_document_template.xml} +0 -0
- data/spec/fixtures/{pbcore_instantiation_template.xml → deprecated/pbcore_instantiation_template.xml} +0 -0
- data/spec/fixtures/{pbcore_solr_digital_document_template.xml → deprecated/pbcore_solr_digital_document_template.xml} +0 -0
- data/spec/fixtures/{pbcore_solr_document_template.xml → deprecated/pbcore_solr_document_template.xml} +0 -0
- data/spec/fixtures/{pbcore_solr_instantiation_template.xml → deprecated/pbcore_solr_instantiation_template.xml} +0 -0
- data/spec/fixtures/digital_instantiation.xml +56 -0
- data/spec/fixtures/digital_instantiation_solr.xml +1913 -0
- data/spec/fixtures/digital_instantiation_template.xml +33 -0
- data/spec/fixtures/document.xml +72 -0
- data/spec/fixtures/document_solr.xml +582 -0
- data/spec/fixtures/document_template.xml +30 -0
- data/spec/fixtures/integration/digital_document_rrhof_1904.xml +63 -0
- data/spec/fixtures/integration/digital_document_rrhof_2405.xml +62 -0
- data/spec/fixtures/integration/document_rrhof_2439.xml +54 -0
- data/spec/fixtures/integration/document_rrhof_524.xml +80 -0
- data/spec/fixtures/integration/instantiation_rrhof_1184.xml +44 -0
- data/spec/fixtures/physical_instantiation.xml +20 -0
- data/spec/fixtures/physical_instantiation_solr.xml +441 -0
- data/spec/fixtures/physical_instantiation_template.xml +18 -0
- data/spec/instantiation_spec.rb +180 -132
- data/spec/integration/conversions_spec.rb +73 -0
- data/spec/spec_helper.rb +37 -9
- data/spec/templates_spec.rb +31 -0
- metadata +68 -17
@@ -36,6 +36,24 @@ module HydraPbcore::Templates
|
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
39
|
+
define_template :event_place do |xml, location|
|
40
|
+
xml.pbcoreCoverage {
|
41
|
+
xml.coverage(location, :annotation=>"Event Place")
|
42
|
+
xml.coverageType {
|
43
|
+
xml.text "Spatial"
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
define_template :event_date do |xml, date|
|
49
|
+
xml.pbcoreCoverage {
|
50
|
+
xml.coverage(date, :annotation=>"Event Date")
|
51
|
+
xml.coverageType {
|
52
|
+
xml.text "Temporal"
|
53
|
+
}
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
39
57
|
end
|
40
58
|
end
|
41
59
|
|
@@ -55,4 +73,102 @@ module HydraPbcore::Templates
|
|
55
73
|
add_child_node(find_by_terms(:pbcoreInstantiation).first, :previous, file)
|
56
74
|
end
|
57
75
|
|
76
|
+
def insert_place(location)
|
77
|
+
add_child_node(ng_xml.root, :event_place, location)
|
78
|
+
end
|
79
|
+
|
80
|
+
def insert_date(date)
|
81
|
+
add_child_node(ng_xml.root, :event_date, date)
|
82
|
+
end
|
83
|
+
|
84
|
+
def digital_instantiation
|
85
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
86
|
+
|
87
|
+
xml.pbcoreInstantiation {
|
88
|
+
|
89
|
+
xml.instantiationIdentifier(:annotation=>"Filename", :source=>"Rock and Roll Hall of Fame and Museum")
|
90
|
+
xml.instantiationDate(:dateType=>"created")
|
91
|
+
xml.instantiationDigital(:source=>"EBU file formats")
|
92
|
+
xml.instantiationLocation
|
93
|
+
xml.instantiationMediaType(:source=>"PBCore instantiationMediaType") {
|
94
|
+
xml.text "Moving image"
|
95
|
+
}
|
96
|
+
xml.instantiationGenerations(:source=>"PBCore instantiationGenerations")
|
97
|
+
xml.instantiationFileSize(:unitsOfMeasure=>"")
|
98
|
+
xml.instantiationDuration
|
99
|
+
xml.instantiationColors(:source=>"PBCore instantiationColors") {
|
100
|
+
xml.text "Color"
|
101
|
+
}
|
102
|
+
|
103
|
+
xml.instantiationEssenceTrack {
|
104
|
+
xml.essenceTrackType {
|
105
|
+
xml.text "Video"
|
106
|
+
}
|
107
|
+
xml.essenceTrackStandard
|
108
|
+
xml.essenceTrackEncoding(:source=>"PBCore essenceTrackEncoding")
|
109
|
+
xml.essenceTrackDataRate(:unitsOfMeasure=>"")
|
110
|
+
xml.essenceTrackFrameRate(:unitsOfMeasure=>"fps")
|
111
|
+
xml.essenceTrackBitDepth
|
112
|
+
xml.essenceTrackFrameSize(:source=>"PBCore essenceTrackFrameSize")
|
113
|
+
xml.essenceTrackAspectRatio(:source=>"PBCore essenceTrackAspectRatio")
|
114
|
+
}
|
115
|
+
|
116
|
+
xml.instantiationEssenceTrack {
|
117
|
+
xml.essenceTrackType {
|
118
|
+
xml.text "Audio"
|
119
|
+
}
|
120
|
+
xml.essenceTrackStandard
|
121
|
+
xml.essenceTrackEncoding(:source=>"PBCore essenceTrackEncoding")
|
122
|
+
xml.essenceTrackDataRate(:unitsOfMeasure=>"")
|
123
|
+
xml.essenceTrackSamplingRate(:unitsOfMeasure=>"")
|
124
|
+
xml.essenceTrackBitDepth
|
125
|
+
xml.essenceTrackAnnotation(:annotationType=>"Number of Audio Channels")
|
126
|
+
}
|
127
|
+
|
128
|
+
xml.instantiationRights {
|
129
|
+
xml.rightsSummary
|
130
|
+
}
|
131
|
+
|
132
|
+
}
|
133
|
+
|
134
|
+
end
|
135
|
+
return builder.doc
|
136
|
+
end
|
137
|
+
|
138
|
+
def physical_instantiation
|
139
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
140
|
+
|
141
|
+
xml.pbcoreInstantiation {
|
142
|
+
|
143
|
+
# Item details
|
144
|
+
xml.instantiationIdentifier(:annotation=>"Barcode", :source=>"Rock and Roll Hall of Fame and Museum")
|
145
|
+
xml.instantiationDate(:dateType=>"created")
|
146
|
+
xml.instantiationPhysical(:source=>"PBCore instantiationPhysical")
|
147
|
+
xml.instantiationStandard
|
148
|
+
xml.instantiationLocation {
|
149
|
+
xml.text "Rock and Roll Hall of Fame and Museum,\n2809 Woodland Ave.,\nCleveland, OH, 44115\n216-515-1956\nlibrary@rockhall.org"
|
150
|
+
}
|
151
|
+
xml.instantiationMediaType(:source=>"PBCore instantiationMediaType") {
|
152
|
+
xml.text "Moving image"
|
153
|
+
}
|
154
|
+
xml.instantiationGenerations(:source=>"PBCore instantiationGenerations") {
|
155
|
+
xml.text "Original"
|
156
|
+
}
|
157
|
+
xml.instantiationColors(:source=>"PBCore instantiationColors") {
|
158
|
+
xml.text "Color"
|
159
|
+
}
|
160
|
+
xml.instantiationLanguage(:source=>"ISO 639.2", :ref=>"http://www.loc.gov/standards/iso639-2/php/code_list.php") {
|
161
|
+
xml.text "eng"
|
162
|
+
}
|
163
|
+
xml.instantiationRights {
|
164
|
+
xml.rightsSummary
|
165
|
+
}
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
end
|
170
|
+
return builder.doc
|
171
|
+
end
|
172
|
+
|
173
|
+
|
58
174
|
end
|
data/lib/hydra-pbcore/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe HydraPbcore::Datastream::DigitalDocument do
|
3
|
+
describe HydraPbcore::Datastream::Deprecated::DigitalDocument do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@object_ds = HydraPbcore::Datastream::DigitalDocument.new(nil, nil)
|
6
|
+
@object_ds = HydraPbcore::Datastream::Deprecated::DigitalDocument.new(nil, nil)
|
7
7
|
end
|
8
8
|
|
9
9
|
describe ".update_indexed_attributes" do
|
@@ -105,8 +105,8 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
105
105
|
@object_ds.update_indexed_attributes({ [:subject] => { 0 => "inserted" }} )
|
106
106
|
@object_ds.update_indexed_attributes({ [:genre] => { 0 => "inserted" }} )
|
107
107
|
|
108
|
-
# Load example
|
109
|
-
f =
|
108
|
+
# Load example deprecated_fixture
|
109
|
+
f = deprecated_fixture "pbcore_digital_document_template.xml"
|
110
110
|
ref_node = Nokogiri::XML(f)
|
111
111
|
f.close
|
112
112
|
|
@@ -126,17 +126,6 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
describe ".insert_node" do
|
129
|
-
it "should return a node and index for a given template type" do
|
130
|
-
pending "Don't need this?"
|
131
|
-
["publisher", "contributor"].each do |type|
|
132
|
-
node, index = @object_ds.insert_node(type.to_s)
|
133
|
-
index.should == 0
|
134
|
-
@object_ds.dirty?.should be_true
|
135
|
-
node, index = @object_ds.insert_node(type.to_s)
|
136
|
-
index.should == 1
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
129
|
it "should raise an exception for non-exisitent templates" do
|
141
130
|
lambda { @object_ds.insert_node("blarg") }.should raise_error
|
142
131
|
end
|
@@ -157,15 +146,6 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
157
146
|
|
158
147
|
end
|
159
148
|
|
160
|
-
describe "default fields" do
|
161
|
-
|
162
|
-
it "such as media type should be 'Moving image'" do
|
163
|
-
pending "No default fields defined yet"
|
164
|
-
@object_ds.get_values([:media_type]).first.should == "Moving image"
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
149
|
describe ".to_solr" do
|
170
150
|
|
171
151
|
before(:each) do
|
@@ -229,8 +209,8 @@ describe HydraPbcore::Datastream::DigitalDocument do
|
|
229
209
|
end
|
230
210
|
|
231
211
|
it "should match an exmplar" do
|
232
|
-
# Load example
|
233
|
-
f =
|
212
|
+
# Load example deprecated_fixture
|
213
|
+
f = deprecated_fixture "pbcore_solr_digital_document_template.xml"
|
234
214
|
ref_node = Nokogiri::XML(f)
|
235
215
|
f.close
|
236
216
|
|
@@ -0,0 +1,282 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe HydraPbcore::Datastream::Deprecated::Document do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@object_ds = HydraPbcore::Datastream::Deprecated::Document.new(nil, nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".update_indexed_attributes" do
|
10
|
+
it "should update all of the fields in #xml_template and fields not requiring additional inserted nodes" do
|
11
|
+
[
|
12
|
+
[:pbc_id],
|
13
|
+
[:main_title],
|
14
|
+
[:alternative_title],
|
15
|
+
[:chapter],
|
16
|
+
[:episode],
|
17
|
+
[:label],
|
18
|
+
[:segment],
|
19
|
+
[:subtitle],
|
20
|
+
[:track],
|
21
|
+
[:translation],
|
22
|
+
[:summary],
|
23
|
+
[:parts_list],
|
24
|
+
[:lc_subject],
|
25
|
+
[:lc_name],
|
26
|
+
[:rh_subject],
|
27
|
+
[:getty_genre],
|
28
|
+
[:lc_genre],
|
29
|
+
[:lc_subject_genre],
|
30
|
+
[:event_series],
|
31
|
+
[:event_place],
|
32
|
+
[:contributor_name],
|
33
|
+
[:contributor_role],
|
34
|
+
[:publisher_name],
|
35
|
+
[:publisher_role],
|
36
|
+
[:note],
|
37
|
+
[:barcode],
|
38
|
+
[:repository],
|
39
|
+
[:format],
|
40
|
+
[:standard],
|
41
|
+
[:media_type],
|
42
|
+
[:generation],
|
43
|
+
[:language],
|
44
|
+
[:colors],
|
45
|
+
[:archival_collection],
|
46
|
+
[:archival_series],
|
47
|
+
[:collection_number],
|
48
|
+
[:accession_number],
|
49
|
+
[:usage],
|
50
|
+
[:condition_note],
|
51
|
+
[:cleaning_note]
|
52
|
+
].each do |pointer|
|
53
|
+
test_val = "#{pointer.last.to_s} value"
|
54
|
+
@object_ds.update_values( {pointer=>{"0"=>test_val}} )
|
55
|
+
@object_ds.get_values(pointer).first.should == test_val
|
56
|
+
@object_ds.get_values(pointer).length.should == 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should work for fields that require added xml nodes" do
|
61
|
+
@object_ds.insert_publisher
|
62
|
+
@object_ds.insert_contributor
|
63
|
+
[
|
64
|
+
[:publisher_name],
|
65
|
+
[:publisher_role],
|
66
|
+
[:contributor_name],
|
67
|
+
[:contributor_role]
|
68
|
+
].each do |pointer|
|
69
|
+
test_val = "#{pointer.last.to_s} value"
|
70
|
+
@object_ds.update_indexed_attributes( {pointer=>{"0"=>test_val}} )
|
71
|
+
@object_ds.get_values(pointer).first.should == test_val
|
72
|
+
@object_ds.get_values(pointer).length.should == 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should differentiate between multiple added nodes" do
|
77
|
+
@object_ds.insert_contributor
|
78
|
+
@object_ds.insert_contributor
|
79
|
+
@object_ds.update_indexed_attributes( {[:contributor_name] => { 0 => "first contributor" }} )
|
80
|
+
@object_ds.update_indexed_attributes( {[:contributor_name] => { 1 => "second contributor" }} )
|
81
|
+
@object_ds.update_indexed_attributes( {[:contributor_role] => { 0 => "first contributor role" }} )
|
82
|
+
@object_ds.update_indexed_attributes( {[:contributor_role] => { 1 => "second contributor role" }} )
|
83
|
+
@object_ds.get_values(:contributor).length.should == 2
|
84
|
+
@object_ds.get_values(:contributor_name)[0].should == "first contributor"
|
85
|
+
@object_ds.get_values(:contributor_name)[1].should == "second contributor"
|
86
|
+
@object_ds.get_values(:contributor_role)[0].should == "first contributor role"
|
87
|
+
@object_ds.get_values(:contributor_role)[1].should == "second contributor role"
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#xml_template" do
|
93
|
+
it "should return an empty xml document matching a valid exmplar" do
|
94
|
+
# insert additional nodes
|
95
|
+
@object_ds.insert_publisher("inserted", "inserted")
|
96
|
+
@object_ds.insert_contributor("inserted", "inserted")
|
97
|
+
@object_ds.insert_publisher("inserted")
|
98
|
+
@object_ds.insert_contributor("inserted")
|
99
|
+
@object_ds.insert_contributor
|
100
|
+
|
101
|
+
# update additional nodes that OM will insert automatically
|
102
|
+
@object_ds.update_indexed_attributes({ [:alternative_title] => { 0 => "inserted" }} )
|
103
|
+
@object_ds.update_indexed_attributes({ [:chapter] => { 0 => "inserted" }} )
|
104
|
+
@object_ds.update_indexed_attributes({ [:episode] => { 0 => "inserted" }} )
|
105
|
+
@object_ds.update_indexed_attributes({ [:label] => { 0 => "inserted" }} )
|
106
|
+
@object_ds.update_indexed_attributes({ [:segment] => { 0 => "inserted" }} )
|
107
|
+
@object_ds.update_indexed_attributes({ [:subtitle] => { 0 => "inserted" }} )
|
108
|
+
@object_ds.update_indexed_attributes({ [:track] => { 0 => "inserted" }} )
|
109
|
+
@object_ds.update_indexed_attributes({ [:translation] => { 0 => "inserted" }} )
|
110
|
+
@object_ds.update_indexed_attributes({ [:lc_subject] => { 0 => "inserted" }} )
|
111
|
+
@object_ds.update_indexed_attributes({ [:lc_name] => { 0 => "inserted" }} )
|
112
|
+
@object_ds.update_indexed_attributes({ [:rh_subject] => { 0 => "inserted" }} )
|
113
|
+
@object_ds.update_indexed_attributes({ [:getty_genre] => { 0 => "inserted" }} )
|
114
|
+
@object_ds.update_indexed_attributes({ [:lc_genre] => { 0 => "inserted" }} )
|
115
|
+
@object_ds.update_indexed_attributes({ [:lc_subject_genre] => { 0 => "inserted" }} )
|
116
|
+
@object_ds.update_indexed_attributes({ [:subject] => { 0 => "inserted" }} )
|
117
|
+
@object_ds.update_indexed_attributes({ [:genre] => { 0 => "inserted" }} )
|
118
|
+
@object_ds.update_indexed_attributes({ [:condition_note] => { 0 => "inserted" }} )
|
119
|
+
@object_ds.update_indexed_attributes({ [:cleaning_note] => { 0 => "inserted" }} )
|
120
|
+
|
121
|
+
# Load example deprecated_fixture
|
122
|
+
f = deprecated_fixture "pbcore_document_template.xml"
|
123
|
+
ref_node = Nokogiri::XML(f)
|
124
|
+
f.close
|
125
|
+
|
126
|
+
# Nokogiri-fy our sample document and reorder nodes
|
127
|
+
sample_node = Nokogiri::XML(@object_ds.to_xml)
|
128
|
+
reordered = HydraPbcore::Behaviors.reorder_document(sample_node)
|
129
|
+
|
130
|
+
# Save this for later...
|
131
|
+
out = File.new("tmp/pbcore_document_sample.xml", "w")
|
132
|
+
out.write(reordered.to_s)
|
133
|
+
out.close
|
134
|
+
|
135
|
+
EquivalentXml.equivalent?(ref_node, reordered, opts = { :element_order => false, :normalize_whitespace => true }).should be_true
|
136
|
+
HydraPbcore::Behaviors.validate(reordered).should be_empty
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe ".remove_node" do
|
142
|
+
it "should remove a node a given type and index" do
|
143
|
+
["publisher", "contributor"].each do |type|
|
144
|
+
@object_ds.send("insert_"+type)
|
145
|
+
@object_ds.send("insert_"+type)
|
146
|
+
@object_ds.find_by_terms(type.to_sym).count.should == 2
|
147
|
+
@object_ds.remove_node(type.to_sym, "1")
|
148
|
+
@object_ds.find_by_terms(type.to_sym).count.should == 1
|
149
|
+
@object_ds.remove_node(type.to_sym, "0")
|
150
|
+
@object_ds.find_by_terms(type.to_sym).count.should == 0
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "default fields" do
|
157
|
+
|
158
|
+
it "such as media type should be 'Moving image'" do
|
159
|
+
@object_ds.get_values([:media_type]).first.should == "Moving image"
|
160
|
+
end
|
161
|
+
|
162
|
+
it "such as colors should be 'Color'" do
|
163
|
+
@object_ds.get_values([:colors]).first.should == "Color"
|
164
|
+
end
|
165
|
+
|
166
|
+
it "such as generation should be 'Original'" do
|
167
|
+
@object_ds.get_values([:generation]).first.should == "Original"
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
describe ".to_solr" do
|
173
|
+
|
174
|
+
before(:each) do
|
175
|
+
# insert additional nodes
|
176
|
+
@object_ds.insert_publisher
|
177
|
+
@object_ds.insert_contributor
|
178
|
+
[
|
179
|
+
"main_title",
|
180
|
+
"alternative_title",
|
181
|
+
"chapter",
|
182
|
+
"episode",
|
183
|
+
"label",
|
184
|
+
"segment",
|
185
|
+
"subtitle",
|
186
|
+
"track",
|
187
|
+
"translation",
|
188
|
+
"summary",
|
189
|
+
"parts_list",
|
190
|
+
"lc_subject",
|
191
|
+
"lc_name",
|
192
|
+
"rh_subject",
|
193
|
+
"getty_genre",
|
194
|
+
"lc_genre",
|
195
|
+
"lc_subject_genre",
|
196
|
+
"event_series",
|
197
|
+
"event_place",
|
198
|
+
"event_date",
|
199
|
+
"contributor_name",
|
200
|
+
"contributor_role",
|
201
|
+
"publisher_name",
|
202
|
+
"publisher_role",
|
203
|
+
"note",
|
204
|
+
"creation_date",
|
205
|
+
"barcode",
|
206
|
+
"repository",
|
207
|
+
"format",
|
208
|
+
"standard",
|
209
|
+
"media_type",
|
210
|
+
"generation",
|
211
|
+
"language",
|
212
|
+
"colors",
|
213
|
+
"archival_collection",
|
214
|
+
"archival_series",
|
215
|
+
"collection_number",
|
216
|
+
"accession_number",
|
217
|
+
"usage",
|
218
|
+
"condition_note",
|
219
|
+
"cleaning_note"
|
220
|
+
].each do |field|
|
221
|
+
@object_ds.send("#{field}=".to_sym, field)
|
222
|
+
end
|
223
|
+
# update additional nodes that OM will insert automatically
|
224
|
+
@object_ds.update_indexed_attributes({ [:alternative_title] => { 0 => "inserted" }} )
|
225
|
+
@object_ds.update_indexed_attributes({ [:chapter] => { 0 => "inserted" }} )
|
226
|
+
@object_ds.update_indexed_attributes({ [:episode] => { 0 => "inserted" }} )
|
227
|
+
@object_ds.update_indexed_attributes({ [:label] => { 0 => "inserted" }} )
|
228
|
+
@object_ds.update_indexed_attributes({ [:segment] => { 0 => "inserted" }} )
|
229
|
+
@object_ds.update_indexed_attributes({ [:subtitle] => { 0 => "inserted" }} )
|
230
|
+
@object_ds.update_indexed_attributes({ [:track] => { 0 => "inserted" }} )
|
231
|
+
@object_ds.update_indexed_attributes({ [:translation] => { 0 => "inserted" }} )
|
232
|
+
@object_ds.update_indexed_attributes({ [:lc_subject] => { 0 => "inserted" }} )
|
233
|
+
@object_ds.update_indexed_attributes({ [:lc_name] => { 0 => "inserted" }} )
|
234
|
+
@object_ds.update_indexed_attributes({ [:rh_subject] => { 0 => "inserted" }} )
|
235
|
+
@object_ds.update_indexed_attributes({ [:getty_genre] => { 0 => "inserted" }} )
|
236
|
+
@object_ds.update_indexed_attributes({ [:lc_genre] => { 0 => "inserted" }} )
|
237
|
+
@object_ds.update_indexed_attributes({ [:lc_subject_genre] => { 0 => "inserted" }} )
|
238
|
+
@object_ds.update_indexed_attributes({ [:subject] => { 0 => "inserted" }} )
|
239
|
+
@object_ds.update_indexed_attributes({ [:genre] => { 0 => "inserted" }} )
|
240
|
+
@object_ds.update_indexed_attributes({ [:condition_note] => { 0 => "inserted" }} )
|
241
|
+
@object_ds.update_indexed_attributes({ [:cleaning_note] => { 0 => "inserted" }} )
|
242
|
+
|
243
|
+
# Use ISO 8601 dates
|
244
|
+
@object_ds.event_date = "2012-11-11"
|
245
|
+
@object_ds.creation_date = "2012"
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should match an exmplar" do
|
249
|
+
# Load example deprecated_fixture
|
250
|
+
f = deprecated_fixture "pbcore_solr_document_template.xml"
|
251
|
+
ref_node = Nokogiri::XML(f)
|
252
|
+
f.close
|
253
|
+
|
254
|
+
# Nokogiri-fy our sample document
|
255
|
+
sample_node = Nokogiri::XML(@object_ds.to_solr.to_xml)
|
256
|
+
|
257
|
+
# Save this for later...
|
258
|
+
out = File.new("tmp/pbcore_solr_document_sample.xml", "w")
|
259
|
+
out.write(sample_node.to_s)
|
260
|
+
out.close
|
261
|
+
|
262
|
+
EquivalentXml.equivalent?(ref_node, sample_node, opts = { :element_order => false, :normalize_whitespace => true }).should be_true
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should display dates as they were entered" do
|
266
|
+
@object_ds.to_solr["creation_date_display"].should == ["2012"]
|
267
|
+
@object_ds.to_solr["event_date_display"].should == ["2012-11-11"]
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should have dates converted to ISO 8601" do
|
271
|
+
@object_ds.to_solr["creation_date_dt"].should == ["2012-01-01T00:00:00Z"]
|
272
|
+
@object_ds.to_solr["event_date_dt"].should == ["2012-11-11T00:00:00Z"]
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should not index dates as text" do
|
276
|
+
@object_ds.to_solr["creation_date_t"].should be_nil
|
277
|
+
@object_ds.to_solr["event_date_t"].should be_nil
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
|
282
|
+
end
|