hydra-pbcore 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p125@hydra-pbcore"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.14.3 (version)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hydra-pbcore.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Adam Wead
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # HydraPbcore
2
+
3
+ A Hydra gem that offers PBCore datastream definitions using OM, as well as some other convenience
4
+ methods such as inserting xml templates into existing docments and reording your PBCore xml
5
+ elements so that you can export complete, valid PBCore documents.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'hydra-pbcore'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install hydra-pbcore
20
+
21
+ ## Usage
22
+
23
+ Use this with your hydra head.
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #require File.expand_path('../lib/hydra-pbcore', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Adam Wead"]
6
+ gem.email = ["amsterdamos@gmail.com"]
7
+ gem.description = %q{A Hydra gem that offers PBCore datastream definitions using OM}
8
+ gem.summary = %q{A Hydra gem that offers PBCore datastream definitions using OM}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "hydra-pbcore"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = "0.0.1"
17
+
18
+ # Dependencies
19
+ gem.add_dependency('nokogiri')
20
+ gem.add_dependency('om')
21
+ gem.add_dependency('active-fedora')
22
+ gem.add_dependency('solrizer')
23
+ gem.add_development_dependency('yard')
24
+ gem.add_development_dependency('redcarpet')
25
+ # For Development
26
+ gem.add_development_dependency 'rspec'
27
+ gem.add_development_dependency 'debugger'
28
+ gem.add_development_dependency 'rdoc'
29
+ gem.add_development_dependency 'equivalent-xml'
30
+ end
@@ -0,0 +1,18 @@
1
+ #require "hydra-pbcore/version"
2
+ require "nokogiri"
3
+ require "solrizer"
4
+ require "om"
5
+ require "active-fedora"
6
+
7
+ module HydraPbcore
8
+ VERSION = "0.0.1"
9
+ def self.version
10
+ HydraPbcore::VERSION
11
+ end
12
+ end
13
+
14
+ require "hydra-pbcore/methods"
15
+ require "hydra-pbcore/behaviors"
16
+ require "hydra-pbcore/datastream/document"
17
+ require "hydra-pbcore/datastream/instantiation"
18
+ require "hydra-pbcore/datastream/digital_document"
@@ -0,0 +1,60 @@
1
+ module HydraPbcore
2
+ class Behaviors
3
+
4
+ # This module is a work in progress
5
+
6
+ # Nokogiri's add_namespace doesn't seem to work, so we have to insert it "manually"
7
+ def self.insert_pbcore_namespace(doc)
8
+ index = doc.to_s.index("xmlns:xsi")
9
+ new_s = doc.to_s.insert(index.to_i, 'xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" ')
10
+ new_doc = Nokogiri::XML(new_s)
11
+ return new_doc
12
+ end
13
+
14
+ # Validates a PBCore document against an xsd
15
+ # Returns an array of errors -- an empty array means it's valid
16
+ def self.validate(doc)
17
+ xsd = Nokogiri::XML::Schema(open("http://pbcore.org/xsd/pbcore-2.0.xsd"))
18
+ xsd.validate(doc)
19
+ end
20
+
21
+
22
+ # Reorders the nodes of pbcoreDescriptionDocument to conform with the correct order
23
+ def self.reorder_document(doc)
24
+
25
+ nodes = [
26
+ "pbcoreAssetType",
27
+ "pbcoreAssetDate",
28
+ "pbcoreIdentifier",
29
+ "pbcoreTitle",
30
+ "pbcoreSubject",
31
+ "pbcoreDescription",
32
+ "pbcoreGenre",
33
+ "pbcoreRelation",
34
+ "pbcoreCoverage",
35
+ "pbcoreAudienceLevel",
36
+ "pbcoreAudienceRating",
37
+ "pbcoreCreator",
38
+ "pbcoreContributor",
39
+ "pbcorePublisher",
40
+ "pbcoreRightsSummary",
41
+ "pbcoreInstantiation",
42
+ "pbcoreAnnotation",
43
+ "pbcorePart",
44
+ "pbcoreExtension",
45
+ ]
46
+
47
+ blank = '<?xml version="1.0"?><pbcoreDescriptionDocument xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html"></pbcoreDescriptionDocument>'
48
+ new_doc = Nokogiri::XML(blank)
49
+
50
+ nodes.each do |node|
51
+ doc.search(node).each do |n|
52
+ new_doc.root.add_child(n)
53
+ end
54
+ end
55
+
56
+ return new_doc
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,269 @@
1
+ module HydraPbcore::Datastream
2
+ class DigitalDocument < ActiveFedora::NokogiriDatastream
3
+
4
+ include HydraPbcore::Methods
5
+
6
+ set_terminology do |t|
7
+ t.root(:path=>"pbcoreDescriptionDocument", :xmlns => '', :namespace_prefix=>nil)
8
+
9
+ #
10
+ # pbcoreDescription fields
11
+ #
12
+ t.pbc_id(:path=>"pbcoreIdentifier", :namespace_prefix=>nil, :namespace_prefix=>nil, :attributes=>{ :source=>"Rock and Roll Hall of Fame and Museum", :annotation=>"PID" })
13
+
14
+ t.main_title(:path=>"pbcoreTitle", :namespace_prefix=>nil, :namespace_prefix=>nil, :attributes=>{ :titleType=>"Main" })
15
+ t.alternative_title(:path=>"pbcoreTitle", :namespace_prefix=>nil, :namespace_prefix=>nil, :attributes=>{ :titleType=>"Alternative" })
16
+ t.chapter(:path=>"pbcoreTitle", :namespace_prefix=>nil, :namespace_prefix=>nil, :attributes=>{ :titleType=>"Chapter" })
17
+ t.episode(:path=>"pbcoreTitle", :namespace_prefix=>nil, :attributes=>{ :titleType=>"Episode" })
18
+ t.label(:path=>"pbcoreTitle", :namespace_prefix=>nil, :attributes=>{ :titleType=>"Label" })
19
+ t.segment(:path=>"pbcoreTitle", :namespace_prefix=>nil, :attributes=>{ :titleType=>"Segment" })
20
+ t.subtitle(:path=>"pbcoreTitle", :namespace_prefix=>nil, :attributes=>{ :titleType=>"Subtitle" })
21
+ t.track(:path=>"pbcoreTitle", :namespace_prefix=>nil, :attributes=>{ :titleType=>"Track" })
22
+ t.translation(:path=>"pbcoreTitle", :namespace_prefix=>nil, :attributes=>{ :titleType=>"Translation" })
23
+
24
+ # This is only to display all subjects
25
+ t.subjects(:path=>"pbcoreSubject", :namespace_prefix=>nil)
26
+
27
+ # Individual subject types defined for entry
28
+ t.lc_subject(:path=>"pbcoreSubject", :namespace_prefix=>nil, :attributes=>{ :source=>"Library of Congress Subject Headings", :ref=>"http://id.loc.gov/authorities/subjects.html" })
29
+ t.lc_name(:path=>"pbcoreSubject", :namespace_prefix=>nil, :attributes=>{ :source=>"Library of Congress Name Authority File", :ref=>"http://id.loc.gov/authorities/names" })
30
+ t.rh_subject(:path=>"pbcoreSubject", :namespace_prefix=>nil, :attributes=>{ :source=>"Rock and Roll Hall of Fame and Museum" })
31
+
32
+ t.summary(:path=>"pbcoreDescription", :namespace_prefix=>nil, :attributes=>{ :descriptionType=>"Description",
33
+ :descriptionTypeSource=>"pbcoreDescription/descriptionType",
34
+ :descriptionTypeRef=>"http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#description",
35
+ :annotation=>"Summary"}
36
+ )
37
+
38
+ t.parts_list(:path=>"pbcoreDescription", :namespace_prefix=>nil, :attributes=>{ :descriptionType=>"Table of Contents",
39
+ :descriptionTypeSource=>"pbcoreDescription/descriptionType",
40
+ :descriptionTypeRef=>"http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#table-of-contents",
41
+ :annotation=>"Parts List" }
42
+ )
43
+
44
+ # This is only to display all genres
45
+ t.genres(:path=>"pbcoreGenre", :namespace_prefix=>nil)
46
+
47
+ # Individual genre types defined for entry
48
+ t.getty_genre(:path=>"pbcoreGenre", :namespace_prefix=>nil, :attributes=>{ :source=>"The Getty Research Institute Art and Architecture Thesaurus", :ref=>"http://www.getty.edu/research/tools/vocabularies/aat/index.html" })
49
+ t.lc_genre(:path=>"pbcoreGenre", :namespace_prefix=>nil, :attributes=>{ :source=>"Library of Congress Genre/Form Terms", :ref=>"http://id.loc.gov/authorities/genreForms.html" })
50
+ t.lc_subject_genre(:path=>"pbcoreGenre", :namespace_prefix=>nil, :attributes=>{ :source=>"Library of Congress Subject Headings", :ref=>"http://id.loc.gov/authorities/subjects.html" })
51
+
52
+
53
+ # Pbcore relation fields
54
+ t.pbcoreRelation(:namespace_prefix=>nil) {
55
+ t.series(:path=>"pbcoreRelationIdentifier", :namespace_prefix=>nil, :attributes=>{ :annotation=>"Event Series" })
56
+ t.arch_coll(:path=>"pbcoreRelationIdentifier", :namespace_prefix=>nil, :attributes=>{ :annotation=>"Archival Collection" })
57
+ t.arch_ser(:path=>"pbcoreRelationIdentifier", :namespace_prefix=>nil, :attributes=>{ :annotation=>"Archival Series" })
58
+ t.coll_num(:path=>"pbcoreRelationIdentifier", :namespace_prefix=>nil, :attributes=>{ :annotation=>"Collection Number" })
59
+ t.acc_num(:path=>"pbcoreRelationIdentifier", :namespace_prefix=>nil, :attributes=>{ :annotation=>"Accession Number" })
60
+ }
61
+ t.event_series(:ref=>[:pbcoreRelation, :series])
62
+ t.archival_collection(:ref=>[:pbcoreRelation, :arch_coll])
63
+ t.archival_series(:ref=>[:pbcoreRelation, :arch_ser])
64
+ t.collection_number(:ref=>[:pbcoreRelation, :coll_num])
65
+ t.accession_number(:ref=>[:pbcoreRelation, :acc_num])
66
+
67
+ # Terms for time and place
68
+ t.pbcore_coverage(:path=>"pbcoreCoverage", :namespace_prefix=>nil) {
69
+ t.coverage(:path=>"coverage", :namespace_prefix=>nil)
70
+ }
71
+ t.spatial(:ref => :pbcore_coverage,
72
+ :path=>'pbcoreCoverage[coverageType="Spatial"]',
73
+ :namespace_prefix=>nil
74
+ )
75
+ t.temporal(:ref => :pbcore_coverage,
76
+ :path=>'pbcoreDescriptionDocument/pbcoreCoverage[coverageType="Temporal"]',
77
+ :namespace_prefix=>nil
78
+ )
79
+ t.event_place(:proxy=>[:spatial, :coverage])
80
+ t.event_date(:proxy=>[:temporal, :coverage])
81
+
82
+ # Contributor names and roles
83
+ t.contributor(:path=>"pbcoreContributor", :namespace_prefix=>nil) {
84
+ t.name_(:path=>"contributor", :namespace_prefix=>nil)
85
+ t.role_(:path=>"contributorRole", :namespace_prefix=>nil, :attributes=>{ :source=>"MARC relator terms" })
86
+ }
87
+ t.contributor_name(:proxy=>[:contributor, :name])
88
+ t.contributor_role(:proxy=>[:contributor, :role])
89
+
90
+ # Publisher names and roles
91
+ t.publisher(:path=>"pbcorePublisher", :namespace_prefix=>nil) {
92
+ t.name_(:path=>"publisher", :namespace_prefix=>nil)
93
+ t.role_(:path=>"publisherRole", :namespace_prefix=>nil, :attributes=>{ :source=>"PBCore publisherRole" })
94
+ }
95
+ t.publisher_name(:proxy=>[:publisher, :name])
96
+ t.publisher_role(:proxy=>[:publisher, :role])
97
+
98
+ t.usage(:path=>"pbcoreRightsSummary", :namespace_prefix=>nil)
99
+
100
+ t.note(:path=>"pbcoreAnnotation", :namespace_prefix=>nil, :atttributes=>{ :annotationType=>"Notes" })
101
+
102
+ #
103
+ # pbcorePart fields
104
+ #
105
+ t.pbcorePart(:namespace_prefix=>nil) {
106
+ t.pbcoreTitle(:namespace_prefix=>nil, :attributes=>{ :titleType=>"song", :annotation=>"part title" })
107
+ t.pbcoreIdentifier(:namespace_prefix=>nil, :attributes=>{ :source=>"rock hall", :annotation=>"part number" })
108
+ t.pbcoreDescription(:namespace_prefix=>nil, :attributes=>{ :descriptionType=>"Description",
109
+ :descriptionTypesource=>"pbcoreDescription/descriptionType",
110
+ :ref=>"http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#description" }
111
+ )
112
+ t.pbcoreContributor(:namespace_prefix=>nil) {
113
+ t.contributor(:namespace_prefix=>nil, :attributes=>{ :annotation=>"part contributor" })
114
+ t.contributorRole(:namespace_prefix=>nil, :attributes=>{ :source=>"MARC relator terms" })
115
+ }
116
+ }
117
+ t.part_title(:ref=>[:pbcorePart, :pbcoreTitle])
118
+ t.part_number(:ref=>[:pbcorePart, :pbcoreIdentifier])
119
+ t.part_description(:ref=>[:pbcorePart, :pbcoreDescription])
120
+ t.part_contributor(:ref=>[:pbcorePart, :pbcoreContributor, :contributor])
121
+ t.part_role(:ref=>[:pbcorePart, :pbcoreContributor, :contributorRole])
122
+
123
+ end
124
+
125
+
126
+ def self.xml_template
127
+ builder = Nokogiri::XML::Builder.new do |xml|
128
+
129
+ xml.pbcoreDescriptionDocument("xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
130
+ "xsi:schemaLocation"=>"http://www.pbcore.org/PBCore/PBCoreNamespace.html") {
131
+
132
+ xml.pbcoreIdentifier(:source=>"Rock and Roll Hall of Fame and Museum", :annotation=>"PID")
133
+ xml.pbcoreTitle(:titleType=>"Main")
134
+ xml.pbcoreDescription(:descriptionType=>"Description",
135
+ :descriptionTypeSource=>"pbcoreDescription/descriptionType",
136
+ :descriptionTypeRef=>"http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#description",
137
+ :annotation=>"Summary"
138
+ )
139
+ xml.pbcoreDescription(:descriptionType=>"Table of Contents",
140
+ :descriptionTypeSource=>"pbcoreDescription/descriptionType",
141
+ :descriptionTypeRef=>"http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#table-of-contents",
142
+ :annotation=>"Parts List"
143
+ )
144
+ xml.pbcoreRelation {
145
+ xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
146
+ xml.text "Is Part Of"
147
+ }
148
+ xml.pbcoreRelationIdentifier(:annotation=>"Event Series")
149
+ }
150
+ xml.pbcoreRelation {
151
+ xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
152
+ xml.text "Is Part Of"
153
+ }
154
+ xml.pbcoreRelationIdentifier(:annotation=>"Archival Collection")
155
+ }
156
+ xml.pbcoreRelation {
157
+ xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
158
+ xml.text "Is Part Of"
159
+ }
160
+ xml.pbcoreRelationIdentifier(:annotation=>"Archival Series")
161
+ }
162
+ xml.pbcoreRelation {
163
+ xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
164
+ xml.text "Is Part Of"
165
+ }
166
+ xml.pbcoreRelationIdentifier(:annotation=>"Collection Number")
167
+ }
168
+ xml.pbcoreRelation {
169
+ xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
170
+ xml.text "Is Part Of"
171
+ }
172
+ xml.pbcoreRelationIdentifier(:annotation=>"Accession Number")
173
+ }
174
+ xml.pbcoreCoverage {
175
+ xml.coverage(:annotation=>"Event Place")
176
+ xml.coverageType {
177
+ xml.text "Spatial"
178
+ }
179
+ }
180
+ xml.pbcoreCoverage {
181
+ xml.coverage(:annotation=>"Event Date")
182
+ xml.coverageType {
183
+ xml.text "Temporal"
184
+ }
185
+ }
186
+ xml.pbcoreRightsSummary
187
+ xml.pbcoreAnnotation(:annotationType=>"Notes")
188
+
189
+ }
190
+
191
+ end
192
+ return builder.doc
193
+ end
194
+
195
+
196
+ def to_solr(solr_doc=Solr::Document.new)
197
+ super(solr_doc)
198
+
199
+ solr_doc.merge!(:format => "Video")
200
+ solr_doc.merge!(:title_t => self.find_by_terms(:main_title).text)
201
+
202
+ # Specific fields for Blacklight export
203
+
204
+ # Title fields
205
+ solr_doc.merge!(:title_display => self.find_by_terms(:main_title).text)
206
+ ["alternative_title", "chapter", "episode", "label", "segment", "subtitle", "track", "translation"].each do |addl_title|
207
+ solr_doc.merge!(:title_addl_display => self.find_by_terms(addl_title.to_sym).text)
208
+ end
209
+ solr_doc.merge!(:heading_display => self.find_by_terms(:main_title).text)
210
+
211
+ # Individual fields
212
+ solr_doc.merge!(:summary_display => self.find_by_terms(:summary).text)
213
+ solr_doc.merge!(:pub_date_display => self.find_by_terms(:event_date).text)
214
+ solr_doc.merge!(:publisher_display => gather_terms(self.find_by_terms(:publisher_name)))
215
+ solr_doc.merge!(:contributors_display => format_contributors_display)
216
+ solr_doc.merge!(:subject_display => gather_terms(self.find_by_terms(:subjects)))
217
+ solr_doc.merge!(:genre_display => gather_terms(self.find_by_terms(:genres)))
218
+ solr_doc.merge!(:series_display => gather_terms(self.find_by_terms(:event_series)))
219
+
220
+ solr_doc.merge!(:recinfo_display => gather_terms(self.find_by_terms(:event_place)))
221
+ solr_doc.merge!(:recinfo_display => gather_terms(self.find_by_terms(:event_date)))
222
+ solr_doc.merge!(:contents_display => gather_terms(self.find_by_terms(:parts_list)))
223
+ solr_doc.merge!(:notes_display => gather_terms(self.find_by_terms(:note)))
224
+
225
+
226
+
227
+ # Blacklight facets - these are the same facet fields used in our Blacklight app
228
+ # for consistency and so they'll show up when we export records from Hydra into BL:
229
+ solr_doc.merge!(:material_facet => "Digital")
230
+ solr_doc.merge!(:genre_facet => gather_terms(self.find_by_terms(:genres)))
231
+ solr_doc.merge!(:name_facet => gather_terms(self.find_by_terms(:contributor_name)))
232
+ solr_doc.merge!(:subject_topic_facet => gather_terms(self.find_by_terms(:subjects)))
233
+ solr_doc.merge!(:series_facet => gather_terms(self.find_by_terms(:event_series)))
234
+
235
+ # These fields are not in the parent...
236
+ #solr_doc.merge!(:format_facet => gather_terms(self.find_by_terms(:format)))
237
+ #solr_doc.merge!(:collection_facet => gather_terms(self.find_by_terms(:archival_collection)))
238
+ #solr_doc.merge!(:collection_display => gather_terms(self.find_by_terms(:archival_collection)))
239
+ #solr_doc.merge!(:physical_dtl_display => gather_terms(self.find_by_terms(:format)))
240
+ #solr_doc.merge!(:access_display => gather_terms(self.find_by_terms(:usage)))
241
+
242
+ # TODO: map PBcore's three-letter language codes to full language names
243
+ # Right now, everything's English.
244
+ # language field is not in the parent... yet?
245
+ # if self.find_by_terms(:language).text.match("eng")
246
+ # solr_doc.merge!(:language_facet => "English")
247
+ # solr_doc.merge!(:language_display => "English")
248
+ # else
249
+ # solr_doc.merge!(:language_facet => "Unknown")
250
+ # solr_doc.merge!(:language_display => "Unknown")
251
+ # end
252
+
253
+ # Extract 4-digit year for creation date facet in Hydra and pub_date facet in Blacklight
254
+ # not in parent
255
+ # create = self.find_by_terms(:creation_date).text.strip
256
+ # unless create.nil? or create.empty?
257
+ # solr_doc.merge!(:create_date_facet => DateTime.parse(create).strftime("%Y"))
258
+ # solr_doc.merge!(:pub_date => DateTime.parse(create).strftime("%Y"))
259
+ # end
260
+
261
+ # For full text, we stuff it into the mods_t field which is already configured for Mods doucments
262
+ solr_doc.merge!(:mods_t => self.ng_xml.text)
263
+
264
+ return solr_doc
265
+ end
266
+
267
+
268
+ end
269
+ end