hydra-pbcore 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -76,5 +76,26 @@ class DigitalDocument < ActiveFedora::NokogiriDatastream
76
76
  return builder.doc
77
77
  end
78
78
 
79
+ def to_solr(solr_doc = Hash.new)
80
+ super(solr_doc)
81
+ solr_doc.merge!({"format" => "Video"})
82
+
83
+ # TODO: map PBcore's three-letter language codes to full language names
84
+ # Right now, everything's English.
85
+ if self.find_by_terms(:language).text.match("eng")
86
+ solr_doc.merge!(:language_facet => "English")
87
+ else
88
+ solr_doc.merge!(:language_facet => "Unknown")
89
+ end
90
+
91
+ # Extract 4-digit year for creation date facet in Hydra and pub_date facet in Blacklight
92
+ create = self.find_by_terms(:creation_date).text.strip
93
+ unless create.nil? or create.empty?
94
+ solr_doc.merge!(:create_date_facet => get_year(create))
95
+ solr_doc.merge!(:pub_date => get_year(create))
96
+ end
97
+ return solr_doc
98
+ end
99
+
79
100
  end
80
101
  end
@@ -15,7 +15,7 @@ class Document < ActiveFedora::NokogiriDatastream
15
15
  :attributes=>{ :source=>"Rock and Roll Hall of Fame and Museum", :annotation=>"PID" }
16
16
  )
17
17
 
18
- t.main_title(:path=>"pbcoreTitle", :attributes=>{ :titleType=>"Main" }, :index_as => [:searchable, :displayable])
18
+ t.title(:path=>"pbcoreTitle", :attributes=>{ :titleType=>"Main" }, :index_as => [:searchable, :displayable])
19
19
  t.alternative_title(:path=>"pbcoreTitle", :attributes=>{ :titleType=>"Alternative" },
20
20
  :index_as => [:searchable, :displayable]
21
21
  )
@@ -30,7 +30,7 @@ class Document < ActiveFedora::NokogiriDatastream
30
30
  )
31
31
 
32
32
  # This is only to display all subjects
33
- t.subject_topic(:path=>"pbcoreSubject", :index_as => [:searchable, :facetable])
33
+ t.subject(:path=>"pbcoreSubject", :index_as => [:facetable])
34
34
 
35
35
  # Individual subject types defined for entry
36
36
  t.lc_subject(:path=>"pbcoreSubject",
@@ -59,7 +59,7 @@ class Document < ActiveFedora::NokogiriDatastream
59
59
  :index_as => [:searchable, :displayable]
60
60
  )
61
61
 
62
- t.parts_list(:path=>"pbcoreDescription",
62
+ t.contents(:path=>"pbcoreDescription",
63
63
  :attributes=>{
64
64
  :descriptionType=>"Table of Contents",
65
65
  :descriptionTypeSource=>"pbcoreDescription/descriptionType",
@@ -70,7 +70,7 @@ class Document < ActiveFedora::NokogiriDatastream
70
70
  )
71
71
 
72
72
  # This is only to display all genres
73
- t.genres(:path=>"pbcoreGenre", :index_as => [:searchable, :facetable])
73
+ t.genre(:path=>"pbcoreGenre", :index_as => [:facetable])
74
74
 
75
75
  # Individual genre types defined for entry
76
76
  t.getty_genre(:path=>"pbcoreGenre",
@@ -100,7 +100,7 @@ class Document < ActiveFedora::NokogiriDatastream
100
100
  t.pbcoreRelation do
101
101
  t.pbcoreRelationIdentifier(:attributes=>{ :annotation=>"Event Series" })
102
102
  end
103
- t.event_series(:ref=>[:pbcoreRelation, :pbcoreRelationIdentifier], :index_as => [:searchable, :displayable])
103
+ t.series(:ref=>[:pbcoreRelation, :pbcoreRelationIdentifier], :index_as => [:facetable, :displayable])
104
104
 
105
105
  # Terms for time and place
106
106
  t.event_place(:path=>"pbcoreCoverage/coverage",
@@ -114,14 +114,13 @@ class Document < ActiveFedora::NokogiriDatastream
114
114
 
115
115
  # Contributor names and roles
116
116
  t.contributor(:path=>"pbcoreContributor") do
117
- t.name_(:path=>"contributor", :index_as => [:searchable, :facetable])
117
+ t.name_(:path=>"contributor")
118
118
  t.role_(:path=>"contributorRole",
119
- :attributes=>{ :source=>"MARC relator terms" },
120
- :index_as => [:searchable, :displayable]
119
+ :attributes=>{ :source=>"MARC relator terms" }
121
120
  )
122
121
  end
123
- t.contributor_name(:proxy=>[:contributor, :name])
124
- t.contributor_role(:proxy=>[:contributor, :role])
122
+ t.contributor_name(:proxy=>[:contributor, :name], :index_as => [:searchable, :facetable])
123
+ t.contributor_role(:proxy=>[:contributor, :role], :index_as => [:searchable, :displayable])
125
124
 
126
125
  # Publisher names and roles
127
126
  t.publisher(:path=>"pbcorePublisher") do
@@ -131,7 +130,7 @@ class Document < ActiveFedora::NokogiriDatastream
131
130
  t.publisher_name(:proxy=>[:publisher, :name], :index_as => [:searchable, :facetable])
132
131
  t.publisher_role(:proxy=>[:publisher, :role], :index_as => [:searchable, :displayable])
133
132
 
134
- t.note(:path=>"pbcoreAnnotation", :atttributes=>{ :annotationType=>"Notes" }, :index_as => [:searchable])
133
+ t.note(:path=>"pbcoreAnnotation", :atttributes=>{ :annotationType=>"Notes" }, :index_as => [:searchable, :displayable])
135
134
 
136
135
  #
137
136
  # pbcoreInstantiation fields for the physical item
@@ -177,15 +176,15 @@ class Document < ActiveFedora::NokogiriDatastream
177
176
  t.creation_date(:ref=>[:pbcoreInstantiation, :instantiationDate], :index_as => [:not_searchable, :converted_date, :displayable])
178
177
  t.barcode(:ref=>[:pbcoreInstantiation, :instantiationIdentifier], :index_as => [:searchable, :displayable])
179
178
  t.repository(:ref=>[:pbcoreInstantiation, :instantiationLocation], :index_as => [:searchable, :displayable])
180
- t.format(:ref=>[:pbcoreInstantiation, :instantiationPhysical], :index_as => [:searchable, :facetable])
181
- t.standard(:ref=>[:pbcoreInstantiation, :instantiationStandard], :index_as => [:searchable, :facetable])
182
- t.media_type(:ref=>[:pbcoreInstantiation, :instantiationMediaType], :index_as => [:searchable, :facetable])
179
+ t.media_format(:ref=>[:pbcoreInstantiation, :instantiationPhysical], :index_as => [:searchable, :facetable])
180
+ t.standard(:ref=>[:pbcoreInstantiation, :instantiationStandard], :index_as => [:searchable, :displayable])
181
+ t.media_type(:ref=>[:pbcoreInstantiation, :instantiationMediaType], :index_as => [:searchable, :displayable])
183
182
  t.generation(:ref=>[:pbcoreInstantiation, :instantiationGenerations], :index_as => [:searchable, :displayable])
184
183
  t.language(:ref=>[:pbcoreInstantiation, :instantiationLanguage], :index_as => [:searchable, :displayable])
185
184
  t.colors(:ref=>[:pbcoreInstantiation, :instantiationColors], :index_as => [:searchable, :displayable])
186
- t.archival_collection(
185
+ t.collection(
187
186
  :ref=>[:pbcoreInstantiation, :instantiationRelation, :arc_collection],
188
- :index_as => [:searchable, :facetable]
187
+ :index_as => [:facetable]
189
188
  )
190
189
  t.archival_series(
191
190
  :ref=>[:pbcoreInstantiation, :instantiationRelation, :arc_series],
@@ -198,7 +197,7 @@ class Document < ActiveFedora::NokogiriDatastream
198
197
  t.accession_number(:ref=>[:pbcoreInstantiation, :instantiationRelation, :acc_number],
199
198
  :index_as => [:searchable, :displayable]
200
199
  )
201
- t.usage(:ref=>[:pbcoreInstantiation, :instantiationRights, :rightsSummary],
200
+ t.access(:ref=>[:pbcoreInstantiation, :instantiationRights, :rightsSummary],
202
201
  :index_as => [:searchable, :displayable]
203
202
  )
204
203
 
@@ -306,5 +305,27 @@ class Document < ActiveFedora::NokogiriDatastream
306
305
  return builder.doc
307
306
  end
308
307
 
308
+ def to_solr(solr_doc = Hash.new)
309
+ super(solr_doc)
310
+ solr_doc.merge!({"format" => "Video"})
311
+
312
+ # TODO: map PBcore's three-letter language codes to full language names
313
+ # Right now, everything's English.
314
+ if self.find_by_terms(:language).text.match("eng")
315
+ solr_doc.merge!(:language_facet => "English")
316
+ else
317
+ solr_doc.merge!(:language_facet => "Unknown")
318
+ end
319
+
320
+ # Extract 4-digit year for creation date facet in Hydra and pub_date facet in Blacklight
321
+ create = self.find_by_terms(:creation_date).text.strip
322
+ unless create.nil? or create.empty?
323
+ solr_doc.merge!(:create_date_facet => get_year(create))
324
+ solr_doc.merge!(:pub_date => get_year(create))
325
+ end
326
+ return solr_doc
327
+ end
328
+
329
+
309
330
  end
310
331
  end
@@ -189,7 +189,6 @@ class Instantiation < ActiveFedora::NokogiriDatastream
189
189
  # Proxies to the relation fields
190
190
  t.next_(:proxy=>[:pbcoreInstantiation, :next_inst, :instantiationRelationIdentifier])
191
191
  t.previous_(:proxy=>[:pbcoreInstantiation, :previous_inst, :instantiationRelationIdentifier])
192
-
193
192
  end
194
193
 
195
194
  def self.xml_template
@@ -27,4 +27,19 @@ module HydraPbcore::Methods
27
27
  xsd.validate(self.to_pbcore_xml)
28
28
  end
29
29
 
30
+ # Returns the 4-digit year from a string
31
+ def get_year(s)
32
+ begin
33
+ return DateTime.parse(s).year.to_s
34
+ rescue
35
+ if s.match(/^\d\d\d\d$/)
36
+ return s.to_s
37
+ elsif s.match(/^(\d\d\d\d)-\d\d$/)
38
+ return $1.to_s
39
+ else
40
+ return nil
41
+ end
42
+ end
43
+ end
44
+
30
45
  end
@@ -1,3 +1,3 @@
1
1
  module HydraPbcore
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -10,7 +10,7 @@ describe HydraPbcore::Datastream::Deprecated::DigitalDocument do
10
10
  it "should update all of the fields in #xml_template and fields not requiring additional inserted nodes" do
11
11
  [
12
12
  [:pbc_id],
13
- [:main_title],
13
+ [:title],
14
14
  [:alternative_title],
15
15
  [:chapter],
16
16
  [:episode],
@@ -20,25 +20,25 @@ describe HydraPbcore::Datastream::Deprecated::DigitalDocument do
20
20
  [:track],
21
21
  [:translation],
22
22
  [:summary],
23
- [:parts_list],
23
+ [:contents],
24
24
  [:lc_subject],
25
25
  [:lc_name],
26
26
  [:rh_subject],
27
27
  [:getty_genre],
28
28
  [:lc_genre],
29
29
  [:lc_subject_genre],
30
- [:event_series],
30
+ [:series],
31
31
  [:event_place],
32
32
  [:contributor_name],
33
33
  [:contributor_role],
34
34
  [:publisher_name],
35
35
  [:publisher_role],
36
36
  [:note],
37
- [:archival_collection],
37
+ [:collection],
38
38
  [:archival_series],
39
39
  [:collection_number],
40
40
  [:accession_number],
41
- [:usage],
41
+ [:access],
42
42
  ].each do |pointer|
43
43
  test_val = "#{pointer.last.to_s} value"
44
44
  @object_ds.update_values( {pointer=>{"0"=>test_val}} )
@@ -154,7 +154,7 @@ describe HydraPbcore::Datastream::Deprecated::DigitalDocument do
154
154
  @object_ds.insert_contributor
155
155
  [
156
156
  "pbc_id",
157
- "main_title",
157
+ "title",
158
158
  "alternative_title",
159
159
  "chapter",
160
160
  "episode",
@@ -164,25 +164,25 @@ describe HydraPbcore::Datastream::Deprecated::DigitalDocument do
164
164
  "track",
165
165
  "translation",
166
166
  "summary",
167
- "parts_list",
167
+ "contents",
168
168
  "lc_subject",
169
169
  "lc_name",
170
170
  "rh_subject",
171
171
  "getty_genre",
172
172
  "lc_genre",
173
173
  "lc_subject_genre",
174
- "event_series",
174
+ "series",
175
175
  "event_place",
176
176
  "contributor_name",
177
177
  "contributor_role",
178
178
  "publisher_name",
179
179
  "publisher_role",
180
180
  "note",
181
- "archival_collection",
181
+ "collection",
182
182
  "archival_series",
183
183
  "collection_number",
184
184
  "accession_number",
185
- "usage"
185
+ "access"
186
186
  ].each do |field|
187
187
  @object_ds.send("#{field}=".to_sym, field)
188
188
  end
@@ -10,7 +10,7 @@ describe HydraPbcore::Datastream::Deprecated::Document do
10
10
  it "should update all of the fields in #xml_template and fields not requiring additional inserted nodes" do
11
11
  [
12
12
  [:pbc_id],
13
- [:main_title],
13
+ [:title],
14
14
  [:alternative_title],
15
15
  [:chapter],
16
16
  [:episode],
@@ -20,14 +20,14 @@ describe HydraPbcore::Datastream::Deprecated::Document do
20
20
  [:track],
21
21
  [:translation],
22
22
  [:summary],
23
- [:parts_list],
23
+ [:contents],
24
24
  [:lc_subject],
25
25
  [:lc_name],
26
26
  [:rh_subject],
27
27
  [:getty_genre],
28
28
  [:lc_genre],
29
29
  [:lc_subject_genre],
30
- [:event_series],
30
+ [:series],
31
31
  [:event_place],
32
32
  [:contributor_name],
33
33
  [:contributor_role],
@@ -36,17 +36,17 @@ describe HydraPbcore::Datastream::Deprecated::Document do
36
36
  [:note],
37
37
  [:barcode],
38
38
  [:repository],
39
- [:format],
39
+ [:media_format],
40
40
  [:standard],
41
41
  [:media_type],
42
42
  [:generation],
43
43
  [:language],
44
44
  [:colors],
45
- [:archival_collection],
45
+ [:collection],
46
46
  [:archival_series],
47
47
  [:collection_number],
48
48
  [:accession_number],
49
- [:usage],
49
+ [:access],
50
50
  [:condition_note],
51
51
  [:cleaning_note]
52
52
  ].each do |pointer|
@@ -176,7 +176,7 @@ describe HydraPbcore::Datastream::Deprecated::Document do
176
176
  @object_ds.insert_publisher
177
177
  @object_ds.insert_contributor
178
178
  [
179
- "main_title",
179
+ "title",
180
180
  "alternative_title",
181
181
  "chapter",
182
182
  "episode",
@@ -186,14 +186,14 @@ describe HydraPbcore::Datastream::Deprecated::Document do
186
186
  "track",
187
187
  "translation",
188
188
  "summary",
189
- "parts_list",
189
+ "contents",
190
190
  "lc_subject",
191
191
  "lc_name",
192
192
  "rh_subject",
193
193
  "getty_genre",
194
194
  "lc_genre",
195
195
  "lc_subject_genre",
196
- "event_series",
196
+ "series",
197
197
  "event_place",
198
198
  "event_date",
199
199
  "contributor_name",
@@ -204,17 +204,17 @@ describe HydraPbcore::Datastream::Deprecated::Document do
204
204
  "creation_date",
205
205
  "barcode",
206
206
  "repository",
207
- "format",
207
+ "media_format",
208
208
  "standard",
209
209
  "media_type",
210
210
  "generation",
211
211
  "language",
212
212
  "colors",
213
- "archival_collection",
213
+ "collection",
214
214
  "archival_series",
215
215
  "collection_number",
216
216
  "accession_number",
217
- "usage",
217
+ "access",
218
218
  "condition_note",
219
219
  "cleaning_note"
220
220
  ].each do |field|