hydra-pbcore 2.4.0 → 3.0.0.rc1

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.
Files changed (50) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -1
  3. data/Gemfile.lock +135 -0
  4. data/README.md +32 -25
  5. data/Rakefile +1 -1
  6. data/hydra-pbcore.gemspec +3 -1
  7. data/lib/hydra-pbcore.rb +19 -2
  8. data/lib/hydra_pbcore/datastream.rb +0 -1
  9. data/lib/hydra_pbcore/datastream/document.rb +6 -11
  10. data/lib/hydra_pbcore/datastream/instantiation.rb +5 -10
  11. data/lib/hydra_pbcore/methods.rb +0 -6
  12. data/lib/hydra_pbcore/templates.rb +6 -6
  13. data/lib/hydra_pbcore/version.rb +1 -1
  14. data/spec/config_spec.rb +88 -0
  15. data/spec/document_spec.rb +37 -17
  16. data/spec/fixtures/digital_instantiation_solr.xml +1009 -1009
  17. data/spec/fixtures/document_solr.xml +441 -430
  18. data/spec/fixtures/physical_instantiation_solr.xml +291 -282
  19. data/spec/instantiation_spec.rb +38 -6
  20. data/spec/spec_helper.rb +1 -0
  21. metadata +42 -87
  22. data/lib/hydra_pbcore/conversions.rb +0 -107
  23. data/lib/hydra_pbcore/datastream/deprecated.rb +0 -6
  24. data/lib/hydra_pbcore/datastream/deprecated/digital_document.rb +0 -105
  25. data/lib/hydra_pbcore/datastream/deprecated/document.rb +0 -332
  26. data/lib/hydra_pbcore/datastream/deprecated/instantiation.rb +0 -263
  27. data/lib/hydra_pbcore/mapper.rb +0 -50
  28. data/spec/deprecated/digital_document_spec.rb +0 -242
  29. data/spec/deprecated/document_spec.rb +0 -282
  30. data/spec/deprecated/instantiation_spec.rb +0 -214
  31. data/spec/fixtures/converted_digital_document_rrhof_1904.xml +0 -61
  32. data/spec/fixtures/converted_digital_document_rrhof_2405.xml +0 -54
  33. data/spec/fixtures/converted_document_rrhof_2439.xml +0 -19
  34. data/spec/fixtures/converted_document_rrhof_524.xml +0 -45
  35. data/spec/fixtures/converted_instantiation_rrhof_1184.xml +0 -39
  36. data/spec/fixtures/converted_rrhof_524.xml +0 -45
  37. data/spec/fixtures/converted_rrhof_524_instantiation.xml +0 -18
  38. data/spec/fixtures/deprecated/pbcore_digital_document_template.xml +0 -67
  39. data/spec/fixtures/deprecated/pbcore_document_template.xml +0 -90
  40. data/spec/fixtures/deprecated/pbcore_instantiation_template.xml +0 -62
  41. data/spec/fixtures/deprecated/pbcore_solr_digital_document_template.xml +0 -500
  42. data/spec/fixtures/deprecated/pbcore_solr_document_template.xml +0 -592
  43. data/spec/fixtures/deprecated/pbcore_solr_instantiation_template.xml +0 -784
  44. data/spec/fixtures/integration/digital_document_rrhof_1904.xml +0 -67
  45. data/spec/fixtures/integration/digital_document_rrhof_2405.xml +0 -66
  46. data/spec/fixtures/integration/document_rrhof_2439.xml +0 -54
  47. data/spec/fixtures/integration/document_rrhof_524.xml +0 -80
  48. data/spec/fixtures/integration/instantiation_rrhof_1184.xml +0 -44
  49. data/spec/integration/conversions_spec.rb +0 -76
  50. data/spec/mapper_spec.rb +0 -18
@@ -1,50 +0,0 @@
1
- class HydraPbcore::Mapper < Solrizer::FieldMapper
2
-
3
- id_field 'id'
4
- index_as :searchable do |t|
5
- t.default :suffix => '_t'
6
- t.date :suffix => '_dt' # single-valued solr date fields
7
- t.dates :suffix => '_dts' # multi-valued solr date fields
8
- t.string :suffix => '_t'
9
- t.text :suffix => '_t'
10
- t.symbol :suffix => '_s'
11
- t.integer :suffix => '_i'
12
- t.long :suffix => '_l'
13
- t.boolean :suffix => '_b'
14
- t.float :suffix => '_f'
15
- t.double :suffix => '_d'
16
- end
17
- index_as :displayable, :suffix => '_display'
18
- index_as :facetable, :suffix => '_facet'
19
- index_as :sortable, :suffix => '_sort'
20
- index_as :unstemmed_searchable, :suffix => '_unstem_search'
21
- index_as :converted_date do |t|
22
- t.default :suffix => '_dt' do |value|
23
- pbcore_date(value)
24
- end
25
- end
26
- index_as :converted_multi_date do |t|
27
- t.default :suffix => '_dts' do |value|
28
- pbcore_date(value)
29
- end
30
- end
31
-
32
- # We assume that all dates are in ISO 8601 format, but sometimes users may only
33
- # specify a year or a year and month. This method adds a -01-01 or -01 respectively
34
- # defaulting to Jan. 1st for dates that are only a year, and the first day of the
35
- # month for dates that are only a year and a month.
36
- # NOTE: This only applies to the date as it is stored in solr. The original value
37
- # as entered by the user is still maintained in the xml.
38
- def self.pbcore_date(date, value = String.new)
39
- return date if date.empty?
40
- if date.match(/^[0-9]{4,4}$/)
41
- value = date + "-01-01"
42
- elsif date.match(/^[0-9]{4,4}-[0-9]{2,2}$/)
43
- value = date + "-01"
44
- else
45
- value = date
46
- end
47
- return DateTime.parse(value).to_time.utc.iso8601
48
- end
49
-
50
- end
@@ -1,242 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe HydraPbcore::Datastream::Deprecated::DigitalDocument do
4
-
5
- before(:each) do
6
- @object_ds = HydraPbcore::Datastream::Deprecated::DigitalDocument.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
- [:title],
14
- [:alternative_title],
15
- [:chapter],
16
- [:episode],
17
- [:label],
18
- [:segment],
19
- [:subtitle],
20
- [:track],
21
- [:translation],
22
- [:summary],
23
- [:contents],
24
- [:lc_subject],
25
- [:lc_name],
26
- [:rh_subject],
27
- [:getty_genre],
28
- [:lc_genre],
29
- [:lc_subject_genre],
30
- [:series],
31
- [:event_place],
32
- [:contributor_name],
33
- [:contributor_role],
34
- [:publisher_name],
35
- [:publisher_role],
36
- [:note],
37
- [:collection],
38
- [:archival_series],
39
- [:collection_number],
40
- [:accession_number],
41
- [:access],
42
- ].each do |pointer|
43
- test_val = "#{pointer.last.to_s} value"
44
- @object_ds.update_values( {pointer=>{"0"=>test_val}} )
45
- @object_ds.get_values(pointer).first.should == test_val
46
- @object_ds.get_values(pointer).length.should == 1
47
- end
48
- end
49
-
50
- it "should work for fields that require added xml nodes" do
51
- @object_ds.insert_publisher
52
- @object_ds.insert_contributor
53
- [
54
- [:publisher_name],
55
- [:publisher_role],
56
- [:contributor_name],
57
- [:contributor_role]
58
- ].each do |pointer|
59
- test_val = "#{pointer.last.to_s} value"
60
- @object_ds.update_indexed_attributes( {pointer=>{"0"=>test_val}} )
61
- @object_ds.get_values(pointer).first.should == test_val
62
- @object_ds.get_values(pointer).length.should == 1
63
- end
64
- end
65
-
66
- it "should differentiate between multiple added nodes" do
67
- @object_ds.insert_contributor
68
- @object_ds.insert_contributor
69
- @object_ds.update_indexed_attributes( {[:contributor_name] => { 0 => "first contributor" }} )
70
- @object_ds.update_indexed_attributes( {[:contributor_name] => { 1 => "second contributor" }} )
71
- @object_ds.update_indexed_attributes( {[:contributor_role] => { 0 => "first contributor role" }} )
72
- @object_ds.update_indexed_attributes( {[:contributor_role] => { 1 => "second contributor role" }} )
73
- @object_ds.get_values(:contributor).length.should == 2
74
- @object_ds.get_values(:contributor_name)[0].should == "first contributor"
75
- @object_ds.get_values(:contributor_name)[1].should == "second contributor"
76
- @object_ds.get_values(:contributor_role)[0].should == "first contributor role"
77
- @object_ds.get_values(:contributor_role)[1].should == "second contributor role"
78
- end
79
-
80
- end
81
-
82
- describe "#xml_template" do
83
- it "should return an empty xml document matching a valid exmplar" do
84
- # insert additional nodes
85
- @object_ds.insert_publisher
86
- @object_ds.insert_contributor
87
- @object_ds.insert_publisher
88
- @object_ds.insert_contributor
89
-
90
- # update additional nodes that OM will insert automatically
91
- @object_ds.update_indexed_attributes({ [:alternative_title] => { 0 => "inserted" }} )
92
- @object_ds.update_indexed_attributes({ [:chapter] => { 0 => "inserted" }} )
93
- @object_ds.update_indexed_attributes({ [:episode] => { 0 => "inserted" }} )
94
- @object_ds.update_indexed_attributes({ [:label] => { 0 => "inserted" }} )
95
- @object_ds.update_indexed_attributes({ [:segment] => { 0 => "inserted" }} )
96
- @object_ds.update_indexed_attributes({ [:subtitle] => { 0 => "inserted" }} )
97
- @object_ds.update_indexed_attributes({ [:track] => { 0 => "inserted" }} )
98
- @object_ds.update_indexed_attributes({ [:translation] => { 0 => "inserted" }} )
99
- @object_ds.update_indexed_attributes({ [:lc_subject] => { 0 => "inserted" }} )
100
- @object_ds.update_indexed_attributes({ [:lc_name] => { 0 => "inserted" }} )
101
- @object_ds.update_indexed_attributes({ [:rh_subject] => { 0 => "inserted" }} )
102
- @object_ds.update_indexed_attributes({ [:getty_genre] => { 0 => "inserted" }} )
103
- @object_ds.update_indexed_attributes({ [:lc_genre] => { 0 => "inserted" }} )
104
- @object_ds.update_indexed_attributes({ [:lc_subject_genre] => { 0 => "inserted" }} )
105
- @object_ds.update_indexed_attributes({ [:subject] => { 0 => "inserted" }} )
106
- @object_ds.update_indexed_attributes({ [:genre] => { 0 => "inserted" }} )
107
-
108
- # Load example deprecated_fixture
109
- f = deprecated_fixture "pbcore_digital_document_template.xml"
110
- ref_node = Nokogiri::XML(f)
111
- f.close
112
-
113
- # Nokogiri-fy our sample document and reorder nodes
114
- sample_node = Nokogiri::XML(@object_ds.to_xml)
115
- reordered = HydraPbcore::Behaviors.reorder_document(sample_node)
116
-
117
- # Save this for later...
118
- out = File.new("tmp/pbcore_digital_document_sample.xml", "w")
119
- out.write(reordered.to_s)
120
- out.close
121
-
122
- EquivalentXml.equivalent?(ref_node, reordered, opts = { :element_order => false, :normalize_whitespace => true }).should be_true
123
- HydraPbcore::Behaviors.validate(reordered).should be_empty
124
-
125
- end
126
- end
127
-
128
- describe ".insert_node" do
129
- it "should raise an exception for non-exisitent templates" do
130
- lambda { @object_ds.insert_node("blarg") }.should raise_error
131
- end
132
- end
133
-
134
- describe ".remove_node" do
135
- it "should remove a node a given type and index" do
136
- ["publisher", "contributor"].each do |type|
137
- @object_ds.send("insert_"+type)
138
- @object_ds.send("insert_"+type)
139
- @object_ds.find_by_terms(type.to_sym).count.should == 2
140
- @object_ds.remove_node(type.to_sym, "1")
141
- @object_ds.find_by_terms(type.to_sym).count.should == 1
142
- @object_ds.remove_node(type.to_sym, "0")
143
- @object_ds.find_by_terms(type.to_sym).count.should == 0
144
- end
145
- end
146
-
147
- end
148
-
149
- describe ".to_solr" do
150
-
151
- before(:each) do
152
- # insert additional nodes
153
- @object_ds.insert_publisher
154
- @object_ds.insert_contributor
155
- [
156
- "pbc_id",
157
- "title",
158
- "alternative_title",
159
- "chapter",
160
- "episode",
161
- "label",
162
- "segment",
163
- "subtitle",
164
- "track",
165
- "translation",
166
- "summary",
167
- "contents",
168
- "lc_subject",
169
- "lc_name",
170
- "rh_subject",
171
- "getty_genre",
172
- "lc_genre",
173
- "lc_subject_genre",
174
- "series",
175
- "event_place",
176
- "contributor_name",
177
- "contributor_role",
178
- "publisher_name",
179
- "publisher_role",
180
- "note",
181
- "collection",
182
- "archival_series",
183
- "collection_number",
184
- "accession_number",
185
- "access"
186
- ].each do |field|
187
- @object_ds.send("#{field}=".to_sym, field)
188
- end
189
- # update additional nodes that OM will insert automatically
190
- @object_ds.update_indexed_attributes({ [:alternative_title] => { 0 => "inserted" }} )
191
- @object_ds.update_indexed_attributes({ [:chapter] => { 0 => "inserted" }} )
192
- @object_ds.update_indexed_attributes({ [:episode] => { 0 => "inserted" }} )
193
- @object_ds.update_indexed_attributes({ [:label] => { 0 => "inserted" }} )
194
- @object_ds.update_indexed_attributes({ [:segment] => { 0 => "inserted" }} )
195
- @object_ds.update_indexed_attributes({ [:subtitle] => { 0 => "inserted" }} )
196
- @object_ds.update_indexed_attributes({ [:track] => { 0 => "inserted" }} )
197
- @object_ds.update_indexed_attributes({ [:translation] => { 0 => "inserted" }} )
198
- @object_ds.update_indexed_attributes({ [:lc_subject] => { 0 => "inserted" }} )
199
- @object_ds.update_indexed_attributes({ [:lc_name] => { 0 => "inserted" }} )
200
- @object_ds.update_indexed_attributes({ [:rh_subject] => { 0 => "inserted" }} )
201
- @object_ds.update_indexed_attributes({ [:getty_genre] => { 0 => "inserted" }} )
202
- @object_ds.update_indexed_attributes({ [:lc_genre] => { 0 => "inserted" }} )
203
- @object_ds.update_indexed_attributes({ [:lc_subject_genre] => { 0 => "inserted" }} )
204
- @object_ds.update_indexed_attributes({ [:subject] => { 0 => "inserted" }} )
205
- @object_ds.update_indexed_attributes({ [:genre] => { 0 => "inserted" }} )
206
-
207
- # Use ISO 8601 dates
208
- @object_ds.event_date = "2012-11-11"
209
- end
210
-
211
- it "should match an exmplar" do
212
- # Load example deprecated_fixture
213
- f = deprecated_fixture "pbcore_solr_digital_document_template.xml"
214
- ref_node = Nokogiri::XML(f)
215
- f.close
216
-
217
- # Nokogiri-fy our sample document
218
- sample_node = Nokogiri::XML(@object_ds.to_solr.to_xml)
219
-
220
- # Save this for later...
221
- out = File.new("tmp/pbcore_solr_digital_document_sample.xml", "w")
222
- out.write(sample_node.to_s)
223
- out.close
224
-
225
- EquivalentXml.equivalent?(ref_node, sample_node, opts = { :element_order => false, :normalize_whitespace => true }).should be_true
226
- end
227
-
228
- it "should display dates as they were entered" do
229
- @object_ds.to_solr["event_date_display"].should == ["2012-11-11"]
230
- end
231
-
232
- it "should have dates converted to ISO 8601" do
233
- @object_ds.to_solr["event_date_dt"].should == ["2012-11-11T00:00:00Z"]
234
- end
235
-
236
- it "should not index dates as text" do
237
- @object_ds.to_solr["event_date_t"].should be_nil
238
- end
239
-
240
- end
241
-
242
- end
@@ -1,282 +0,0 @@
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
- [:title],
14
- [:alternative_title],
15
- [:chapter],
16
- [:episode],
17
- [:label],
18
- [:segment],
19
- [:subtitle],
20
- [:track],
21
- [:translation],
22
- [:summary],
23
- [:contents],
24
- [:lc_subject],
25
- [:lc_name],
26
- [:rh_subject],
27
- [:getty_genre],
28
- [:lc_genre],
29
- [:lc_subject_genre],
30
- [:series],
31
- [:event_place],
32
- [:contributor_name],
33
- [:contributor_role],
34
- [:publisher_name],
35
- [:publisher_role],
36
- [:note],
37
- [:barcode],
38
- [:repository],
39
- [:media_format],
40
- [:standard],
41
- [:media_type],
42
- [:generation],
43
- [:language],
44
- [:colors],
45
- [:collection],
46
- [:archival_series],
47
- [:collection_number],
48
- [:accession_number],
49
- [:access],
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
- "title",
180
- "alternative_title",
181
- "chapter",
182
- "episode",
183
- "label",
184
- "segment",
185
- "subtitle",
186
- "track",
187
- "translation",
188
- "summary",
189
- "contents",
190
- "lc_subject",
191
- "lc_name",
192
- "rh_subject",
193
- "getty_genre",
194
- "lc_genre",
195
- "lc_subject_genre",
196
- "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
- "media_format",
208
- "standard",
209
- "media_type",
210
- "generation",
211
- "language",
212
- "colors",
213
- "collection",
214
- "archival_series",
215
- "collection_number",
216
- "accession_number",
217
- "access",
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