hydra-mods 0.0.1

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.
@@ -0,0 +1,24 @@
1
+ # An EXAMPLE Basic Model for Assets that conform to Hydra commonMetadata cModel and have basic MODS metadata (currently "Article" is the MODS exemplar)
2
+ class ModsAsset < ActiveFedora::Base
3
+
4
+ # declares a rightsMetadata datastream with type Hydra::Datastream::RightsMetadata
5
+ # basically, it is another expression of
6
+ # has_metadata :name => "rightsMetadata", :type => Hydra::Datastream::RightsMetadata
7
+ include Hydra::ModelMixins::CommonMetadata
8
+
9
+ ## Convenience methods for manipulating the rights metadata datastream
10
+ include Hydra::ModelMixins::RightsMetadata
11
+
12
+ # declares a descMetadata datastream with type Hydra::Datastream::ModsArticle
13
+ # basically, it is another expression of
14
+ # has_metadata :name => "descMetadata", :type => Hydra::Datastream::ModsArticle
15
+ include Hydra::ModelMixins::ModsObject
16
+
17
+ # adds helpful methods for basic hydra objects
18
+ include Hydra::ModelMethods
19
+
20
+ # adds file_objects methods
21
+ include ActiveFedora::FileManagement
22
+
23
+
24
+ end
@@ -0,0 +1,20 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ # require "hydra-head/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'hydra-mods'
6
+ s.version = '0.0.1'
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield, Justin Coyne & many more. See https://github.com/projecthydra/hydra-head/contributors"]
9
+ s.email = ["hydra-tech@googlegroups.com"]
10
+ s.homepage = 'http://projecthydra.org'
11
+ s.summary = "Hydra MODS components split out from hydra-head"
12
+ s.description = "Hydra MODS components split out from hydra-head"
13
+
14
+ s.add_dependency "hydra-head"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.test_files = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib", "app/models"]
20
+ end
data/lib/hydra-mods.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'hydra/mods'
2
+
3
+ module HydraMods
4
+ require 'rails'
5
+
6
+ class Engine < Rails::Engine
7
+
8
+ end
9
+ end
@@ -0,0 +1,46 @@
1
+ # Provides some helper methods for indexing compound or non-standard facets
2
+ #
3
+ # == Methods
4
+ #
5
+ # extract_person_full_names
6
+ # This method returns a Hash of person_full_name_facet values which combine Lastname, Firstname
7
+ # extract_person_organizations
8
+ # This method returns a Hash of person_full_name_facet values which extract the persons affiliation and puts it in an mods_organization_facet
9
+ # will be removed in release 5.x
10
+ module Hydra::CommonModsIndexMethods
11
+
12
+ def self.included(base)
13
+ ActiveSupport::Deprecation.warn("Hydra::CommonModsIndexMethods has been deprecated. Use Hydra::Datastream::CommonModsIndexMethods instead")
14
+ end
15
+
16
+ # Extracts the first and last names of persons and creates Solr::Field objects with for person_full_name_facet
17
+ #
18
+ # == Returns:
19
+ # An array of Solr::Field objects
20
+ #
21
+ def extract_person_full_names
22
+ names = {}
23
+ self.find_by_terms(:person).each do |person|
24
+ name_parts = person.children.inject({}) do |hash,child|
25
+ hash[child.get_attribute(:type)] = child.text if ["family","given"].include? child.get_attribute(:type)
26
+ hash
27
+ end
28
+ ::Solrizer::Extractor.insert_solr_field_value(names, "person_full_name_facet", [name_parts["family"], name_parts["given"]].join(", ") ) if name_parts.keys.sort == ["family","given"]
29
+ names
30
+ end
31
+ return names
32
+ end
33
+
34
+ # Extracts the affiliations of persons and creates Solr::Field objects for them
35
+ #
36
+ # == Returns:
37
+ # An array of Solr::Field objects
38
+ #
39
+ def extract_person_organizations
40
+ orgs = {}
41
+ self.find_by_terms(:person,:affiliation).each do |org|
42
+ ::Solrizer::Extractor.insert_solr_field_value(orgs, "mods_organization_facet", org.text)
43
+ end
44
+ return orgs
45
+ end
46
+ end
@@ -0,0 +1,19 @@
1
+ # Include this into models to specify that the descMetadata datastream contains basic MODS metadata
2
+ #
3
+ # Explicitly declares:
4
+ # descMetadata datastream using Hydra::Datastream::ModsArticle Terminology
5
+ #
6
+ # will move to lib/hydra/model/mods_object_behavior in release 5.x
7
+ module Hydra::ModelMixins
8
+ module ModsObject
9
+
10
+ def self.included(klazz)
11
+ # Uses the Hydra MODS Basic profile for tracking descriptive metadata
12
+ klazz.has_metadata :name => "descMetadata", :type => Hydra::Datastream::ModsArticle
13
+
14
+ # Ensure that objects assert the modsObject cModel
15
+ # klazz.relationships << :has_model => "info:fedora/hydra-cModel:modsObject"
16
+ end
17
+
18
+ end
19
+ end
data/lib/hydra/mods.rb ADDED
@@ -0,0 +1,14 @@
1
+ module Hydra
2
+
3
+ # DEPRECATED STUFF
4
+ #module ModelMixins
5
+ # autoload :CommonModsIndexMethods, 'hydra/model_mixins/mods_object'
6
+ #end
7
+ require 'hydra/model_mixins/mods_object'
8
+ require 'uva/mods_index_methods'
9
+
10
+ autoload :ModsArticle, 'hydra/mods_article'
11
+ autoload :ModsDataset, 'hydra/mods_article'
12
+ autoload :ModsGenericContent, 'hydra/mods_article'
13
+ autoload :ModsImage, 'hydra/mods_article'
14
+ end
@@ -0,0 +1,535 @@
1
+ # @deprecated -- this will be removed in 5.x release
2
+ module Hydra
3
+
4
+ class ModsArticle < ActiveFedora::NokogiriDatastream
5
+ include Hydra::Datastream::CommonModsIndexMethods
6
+
7
+ def initialize(digital_object, dsid, options={})
8
+ ActiveSupport::Deprecation.warn("Hydra::ModsArticle has been deprecated. Use Hydra::Datastream::ModsArticle instead")
9
+ super
10
+
11
+ end
12
+
13
+ set_terminology do |t|
14
+ t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
15
+
16
+
17
+ t.title_info(:path=>"titleInfo") {
18
+ t.main_title(:index_as=>[:facetable],:path=>"title", :label=>"title")
19
+ t.language(:index_as=>[:facetable],:path=>{:attribute=>"lang"})
20
+ }
21
+ t.language{
22
+ t.lang_code(:index_as=>[:facetable], :path=>"languageTerm", :attributes=>{:type=>"code"})
23
+ }
24
+ t.abstract
25
+ t.subject {
26
+ t.topic(:index_as=>[:facetable])
27
+ }
28
+ t.topic_tag(:proxy=>[:subject, :topic])
29
+ # t.topic_tag(:index_as=>[:facetable],:path=>"subject", :default_content_path=>"topic")
30
+ # This is a mods:name. The underscore is purely to avoid namespace conflicts.
31
+ t.name_ {
32
+ # this is a namepart
33
+ t.namePart(:type=>:string, :label=>"generic name")
34
+ # affiliations are great
35
+ t.affiliation
36
+ t.institution(:path=>"affiliation", :index_as=>[:facetable], :label=>"organization")
37
+ t.displayForm
38
+ t.role(:ref=>[:role])
39
+ t.description(:index_as=>[:facetable])
40
+ t.date(:path=>"namePart", :attributes=>{:type=>"date"})
41
+ t.last_name(:path=>"namePart", :attributes=>{:type=>"family"})
42
+ t.first_name(:path=>"namePart", :attributes=>{:type=>"given"}, :label=>"first name")
43
+ t.terms_of_address(:path=>"namePart", :attributes=>{:type=>"termsOfAddress"})
44
+ t.computing_id
45
+ }
46
+ # lookup :person, :first_name
47
+ t.person(:ref=>:name, :attributes=>{:type=>"personal"}, :index_as=>[:facetable])
48
+ t.department(:proxy=>[:person,:description],:index_as=>[:facetable])
49
+ t.organization(:ref=>:name, :attributes=>{:type=>"corporate"}, :index_as=>[:facetable])
50
+ t.conference(:ref=>:name, :attributes=>{:type=>"conference"}, :index_as=>[:facetable])
51
+ t.role {
52
+ t.text(:path=>"roleTerm",:attributes=>{:type=>"text"})
53
+ t.code(:path=>"roleTerm",:attributes=>{:type=>"code"})
54
+ }
55
+ t.journal(:path=>'relatedItem', :attributes=>{:type=>"host"}) {
56
+ t.title_info(:index_as=>[:facetable],:ref=>[:title_info])
57
+ t.origin_info(:path=>"originInfo") {
58
+ t.publisher
59
+ t.date_issued(:path=>"dateIssued")
60
+ t.issuance(:index_as=>[:facetable])
61
+ }
62
+ t.issn(:path=>"identifier", :attributes=>{:type=>"issn"})
63
+ t.issue(:path=>"part") {
64
+ t.volume(:path=>"detail", :attributes=>{:type=>"volume"}, :default_content_path=>"number")
65
+ t.level(:path=>"detail", :attributes=>{:type=>"number"}, :default_content_path=>"number")
66
+ t.extent
67
+ t.pages(:path=>"extent", :attributes=>{:unit=>"pages"}) {
68
+ t.start
69
+ t.end
70
+ }
71
+ t.start_page(:proxy=>[:pages, :start])
72
+ t.end_page(:proxy=>[:pages, :end])
73
+ t.publication_date(:path=>"date")
74
+ }
75
+ }
76
+ t.note
77
+ t.location(:path=>"location") {
78
+ t.url(:path=>"url")
79
+ }
80
+ t.publication_url(:proxy=>[:location,:url])
81
+ t.peer_reviewed(:proxy=>[:journal,:origin_info,:issuance], :index_as=>[:facetable])
82
+ t.title(:proxy=>[:mods,:title_info, :main_title])
83
+ end
84
+
85
+ # Generates an empty Mods Article (used when you call ModsArticle.new without passing in existing xml)
86
+ def self.xml_template
87
+ builder = Nokogiri::XML::Builder.new do |xml|
88
+ xml.mods(:version=>"3.3", "xmlns:xlink"=>"http://www.w3.org/1999/xlink",
89
+ "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
90
+ "xmlns"=>"http://www.loc.gov/mods/v3",
91
+ "xsi:schemaLocation"=>"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd") {
92
+ xml.titleInfo(:lang=>"") {
93
+ xml.title
94
+ }
95
+ xml.name(:type=>"personal") {
96
+ xml.namePart(:type=>"given")
97
+ xml.namePart(:type=>"family")
98
+ xml.affiliation
99
+ xml.computing_id
100
+ xml.description
101
+ xml.role {
102
+ xml.roleTerm("Author", :authority=>"marcrelator", :type=>"text")
103
+ }
104
+ }
105
+ xml.typeOfResource
106
+ xml.genre(:authority=>"marcgt")
107
+ xml.language {
108
+ xml.languageTerm(:authority=>"iso639-2b", :type=>"code")
109
+ }
110
+ xml.abstract
111
+ xml.subject {
112
+ xml.topic
113
+ }
114
+ xml.relatedItem(:type=>"host") {
115
+ xml.titleInfo {
116
+ xml.title
117
+ }
118
+ xml.identifier(:type=>"issn")
119
+ xml.originInfo {
120
+ xml.publisher
121
+ xml.dateIssued
122
+ xml.issuance
123
+ }
124
+ xml.part {
125
+ xml.detail(:type=>"volume") {
126
+ xml.number
127
+ }
128
+ xml.detail(:type=>"number") {
129
+ xml.number
130
+ }
131
+ xml.extent(:unit=>"pages") {
132
+ xml.start
133
+ xml.end
134
+ }
135
+ xml.date
136
+ }
137
+ }
138
+ xml.location {
139
+ xml.url
140
+ }
141
+ }
142
+ end
143
+ return builder.doc
144
+ end
145
+
146
+ # Generates a new Person node
147
+ def self.person_template
148
+ builder = Nokogiri::XML::Builder.new do |xml|
149
+ xml.name(:type=>"personal") {
150
+ xml.namePart(:type=>"family")
151
+ xml.namePart(:type=>"given")
152
+ xml.affiliation
153
+ xml.computing_id
154
+ xml.description
155
+ xml.role {
156
+ xml.roleTerm("Author", :type=>"text")
157
+ }
158
+ }
159
+ end
160
+ return builder.doc.root
161
+ end
162
+
163
+ def self.full_name_template
164
+ builder = Nokogiri::XML::Builder.new do |xml|
165
+ xml.full_name(:type => "personal")
166
+ end
167
+ return builder.doc.root
168
+ end
169
+
170
+ # Generates a new Organization node
171
+ # Uses mods:name[@type="corporate"]
172
+ def self.organization_template
173
+ builder = Nokogiri::XML::Builder.new do |xml|
174
+ xml.name(:type=>"corporate") {
175
+ xml.namePart
176
+ xml.role {
177
+ xml.roleTerm(:authority=>"marcrelator", :type=>"text")
178
+ }
179
+ }
180
+ end
181
+ return builder.doc.root
182
+ end
183
+
184
+ # Generates a new Conference node
185
+ def self.conference_template
186
+ builder = Nokogiri::XML::Builder.new do |xml|
187
+ xml.name(:type=>"conference") {
188
+ xml.namePart
189
+ xml.role {
190
+ xml.roleTerm(:authority=>"marcrelator", :type=>"text")
191
+ }
192
+ }
193
+ end
194
+ return builder.doc.root
195
+ end
196
+
197
+ # Inserts a new contributor (mods:name) into the mods document
198
+ # creates contributors of type :person, :organization, or :conference
199
+ def insert_contributor(type, opts={})
200
+ case type.to_sym
201
+ when :person
202
+ node = Hydra::ModsArticle.person_template
203
+ nodeset = self.find_by_terms(:person)
204
+ when :organization
205
+ node = Hydra::ModsArticle.organization_template
206
+ nodeset = self.find_by_terms(:organization)
207
+ when :conference
208
+ node = Hydra::ModsArticle.conference_template
209
+ nodeset = self.find_by_terms(:conference)
210
+ else
211
+ ActiveFedora.logger.warn("#{type} is not a valid argument for Hydra::ModsArticle.insert_contributor")
212
+ node = nil
213
+ index = nil
214
+ end
215
+
216
+ unless nodeset.nil?
217
+ if nodeset.empty?
218
+ self.ng_xml.root.add_child(node)
219
+ index = 0
220
+ else
221
+ nodeset.after(node)
222
+ index = nodeset.length
223
+ end
224
+ self.dirty = true
225
+ end
226
+
227
+ return node, index
228
+ end
229
+
230
+ # Remove the contributor entry identified by @contributor_type and @index
231
+ def remove_contributor(contributor_type, index)
232
+ contributor = self.find_by_terms( {contributor_type.to_sym => index.to_i} ).first
233
+ unless contributor.nil?
234
+ contributor.remove
235
+ self.dirty = true
236
+ end
237
+ end
238
+
239
+ def self.common_relator_terms
240
+ {"aut" => "Author",
241
+ "clb" => "Collaborator",
242
+ "com" => "Compiler",
243
+ "ctb" => "Contributor",
244
+ "cre" => "Creator",
245
+ "edt" => "Editor",
246
+ "ill" => "Illustrator",
247
+ "oth" => "Other",
248
+ "trl" => "Translator",
249
+ }
250
+ end
251
+
252
+ def self.person_relator_terms
253
+ {"aut" => "Author",
254
+ "clb" => "Collaborator",
255
+ "com" => "Compiler",
256
+ "cre" => "Creator",
257
+ "ctb" => "Contributor",
258
+ "edt" => "Editor",
259
+ "ill" => "Illustrator",
260
+ "res" => "Researcher",
261
+ "rth" => "Research team head",
262
+ "rtm" => "Research team member",
263
+ "trl" => "Translator"
264
+ }
265
+ end
266
+
267
+ def self.conference_relator_terms
268
+ {
269
+ "hst" => "Host"
270
+ }
271
+ end
272
+
273
+ def self.organization_relator_terms
274
+ {
275
+ "fnd" => "Funder",
276
+ "hst" => "Host"
277
+ }
278
+ end
279
+
280
+ def self.dc_relator_terms
281
+ {"acp" => "Art copyist",
282
+ "act" => "Actor",
283
+ "adp" => "Adapter",
284
+ "aft" => "Author of afterword, colophon, etc.",
285
+ "anl" => "Analyst",
286
+ "anm" => "Animator",
287
+ "ann" => "Annotator",
288
+ "ant" => "Bibliographic antecedent",
289
+ "app" => "Applicant",
290
+ "aqt" => "Author in quotations or text abstracts",
291
+ "arc" => "Architect",
292
+ "ard" => "Artistic director ",
293
+ "arr" => "Arranger",
294
+ "art" => "Artist",
295
+ "asg" => "Assignee",
296
+ "asn" => "Associated name",
297
+ "att" => "Attributed name",
298
+ "auc" => "Auctioneer",
299
+ "aud" => "Author of dialog",
300
+ "aui" => "Author of introduction",
301
+ "aus" => "Author of screenplay",
302
+ "aut" => "Author",
303
+ "bdd" => "Binding designer",
304
+ "bjd" => "Bookjacket designer",
305
+ "bkd" => "Book designer",
306
+ "bkp" => "Book producer",
307
+ "bnd" => "Binder",
308
+ "bpd" => "Bookplate designer",
309
+ "bsl" => "Bookseller",
310
+ "ccp" => "Conceptor",
311
+ "chr" => "Choreographer",
312
+ "clb" => "Collaborator",
313
+ "cli" => "Client",
314
+ "cll" => "Calligrapher",
315
+ "clt" => "Collotyper",
316
+ "cmm" => "Commentator",
317
+ "cmp" => "Composer",
318
+ "cmt" => "Compositor",
319
+ "cng" => "Cinematographer",
320
+ "cnd" => "Conductor",
321
+ "cns" => "Censor",
322
+ "coe" => "Contestant -appellee",
323
+ "col" => "Collector",
324
+ "com" => "Compiler",
325
+ "cos" => "Contestant",
326
+ "cot" => "Contestant -appellant",
327
+ "cov" => "Cover designer",
328
+ "cpc" => "Copyright claimant",
329
+ "cpe" => "Complainant-appellee",
330
+ "cph" => "Copyright holder",
331
+ "cpl" => "Complainant",
332
+ "cpt" => "Complainant-appellant",
333
+ "cre" => "Creator",
334
+ "crp" => "Correspondent",
335
+ "crr" => "Corrector",
336
+ "csl" => "Consultant",
337
+ "csp" => "Consultant to a project",
338
+ "cst" => "Costume designer",
339
+ "ctb" => "Contributor",
340
+ "cte" => "Contestee-appellee",
341
+ "ctg" => "Cartographer",
342
+ "ctr" => "Contractor",
343
+ "cts" => "Contestee",
344
+ "ctt" => "Contestee-appellant",
345
+ "cur" => "Curator",
346
+ "cwt" => "Commentator for written text",
347
+ "dfd" => "Defendant",
348
+ "dfe" => "Defendant-appellee",
349
+ "dft" => "Defendant-appellant",
350
+ "dgg" => "Degree grantor",
351
+ "dis" => "Dissertant",
352
+ "dln" => "Delineator",
353
+ "dnc" => "Dancer",
354
+ "dnr" => "Donor",
355
+ "dpc" => "Depicted",
356
+ "dpt" => "Depositor",
357
+ "drm" => "Draftsman",
358
+ "drt" => "Director",
359
+ "dsr" => "Designer",
360
+ "dst" => "Distributor",
361
+ "dtc" => "Data contributor ",
362
+ "dte" => "Dedicatee",
363
+ "dtm" => "Data manager ",
364
+ "dto" => "Dedicator",
365
+ "dub" => "Dubious author",
366
+ "edt" => "Editor",
367
+ "egr" => "Engraver",
368
+ "elg" => "Electrician ",
369
+ "elt" => "Electrotyper",
370
+ "eng" => "Engineer",
371
+ "etr" => "Etcher",
372
+ "exp" => "Expert",
373
+ "fac" => "Facsimilist",
374
+ "fld" => "Field director ",
375
+ "flm" => "Film editor",
376
+ "fmo" => "Former owner",
377
+ "fpy" => "First party",
378
+ "fnd" => "Funder",
379
+ "frg" => "Forger",
380
+ "gis" => "Geographic information specialist ",
381
+ "grt" => "Graphic technician",
382
+ "hnr" => "Honoree",
383
+ "hst" => "Host",
384
+ "ill" => "Illustrator",
385
+ "ilu" => "Illuminator",
386
+ "ins" => "Inscriber",
387
+ "inv" => "Inventor",
388
+ "itr" => "Instrumentalist",
389
+ "ive" => "Interviewee",
390
+ "ivr" => "Interviewer",
391
+ "lbr" => "Laboratory ",
392
+ "lbt" => "Librettist",
393
+ "ldr" => "Laboratory director ",
394
+ "led" => "Lead",
395
+ "lee" => "Libelee-appellee",
396
+ "lel" => "Libelee",
397
+ "len" => "Lender",
398
+ "let" => "Libelee-appellant",
399
+ "lgd" => "Lighting designer",
400
+ "lie" => "Libelant-appellee",
401
+ "lil" => "Libelant",
402
+ "lit" => "Libelant-appellant",
403
+ "lsa" => "Landscape architect",
404
+ "lse" => "Licensee",
405
+ "lso" => "Licensor",
406
+ "ltg" => "Lithographer",
407
+ "lyr" => "Lyricist",
408
+ "mcp" => "Music copyist",
409
+ "mfr" => "Manufacturer",
410
+ "mdc" => "Metadata contact",
411
+ "mod" => "Moderator",
412
+ "mon" => "Monitor",
413
+ "mrk" => "Markup editor",
414
+ "msd" => "Musical director",
415
+ "mte" => "Metal-engraver",
416
+ "mus" => "Musician",
417
+ "nrt" => "Narrator",
418
+ "opn" => "Opponent",
419
+ "org" => "Originator",
420
+ "orm" => "Organizer of meeting",
421
+ "oth" => "Other",
422
+ "own" => "Owner",
423
+ "pat" => "Patron",
424
+ "pbd" => "Publishing director",
425
+ "pbl" => "Publisher",
426
+ "pdr" => "Project director",
427
+ "pfr" => "Proofreader",
428
+ "pht" => "Photographer",
429
+ "plt" => "Platemaker",
430
+ "pma" => "Permitting agency",
431
+ "pmn" => "Production manager",
432
+ "pop" => "Printer of plates",
433
+ "ppm" => "Papermaker",
434
+ "ppt" => "Puppeteer",
435
+ "prc" => "Process contact",
436
+ "prd" => "Production personnel",
437
+ "prf" => "Performer",
438
+ "prg" => "Programmer",
439
+ "prm" => "Printmaker",
440
+ "pro" => "Producer",
441
+ "prt" => "Printer",
442
+ "pta" => "Patent applicant",
443
+ "pte" => "Plaintiff -appellee",
444
+ "ptf" => "Plaintiff",
445
+ "pth" => "Patent holder",
446
+ "ptt" => "Plaintiff-appellant",
447
+ "rbr" => "Rubricator",
448
+ "rce" => "Recording engineer",
449
+ "rcp" => "Recipient",
450
+ "red" => "Redactor",
451
+ "ren" => "Renderer",
452
+ "res" => "Researcher",
453
+ "rev" => "Reviewer",
454
+ "rps" => "Repository",
455
+ "rpt" => "Reporter",
456
+ "rpy" => "Responsible party",
457
+ "rse" => "Respondent-appellee",
458
+ "rsg" => "Restager",
459
+ "rsp" => "Respondent",
460
+ "rst" => "Respondent-appellant",
461
+ "rth" => "Research team head",
462
+ "rtm" => "Research team member",
463
+ "sad" => "Scientific advisor",
464
+ "sce" => "Scenarist",
465
+ "scl" => "Sculptor",
466
+ "scr" => "Scribe",
467
+ "sds" => "Sound designer",
468
+ "sec" => "Secretary",
469
+ "sgn" => "Signer",
470
+ "sht" => "Supporting host",
471
+ "sng" => "Singer",
472
+ "spk" => "Speaker",
473
+ "spn" => "Sponsor",
474
+ "spy" => "Second party",
475
+ "srv" => "Surveyor",
476
+ "std" => "Set designer",
477
+ "stl" => "Storyteller",
478
+ "stm" => "Stage manager",
479
+ "stn" => "Standards body",
480
+ "str" => "Stereotyper",
481
+ "tcd" => "Technical director",
482
+ "tch" => "Teacher",
483
+ "ths" => "Thesis advisor",
484
+ "trc" => "Transcriber",
485
+ "trl" => "Translator",
486
+ "tyd" => "Type designer",
487
+ "tyg" => "Typographer",
488
+ "vdg" => "Videographer",
489
+ "voc" => "Vocalist",
490
+ "wam" => "Writer of accompanying material",
491
+ "wdc" => "Woodcutter",
492
+ "wde" => "Wood -engraver",
493
+ "wit" => "Witness"}
494
+ end
495
+
496
+ def self.valid_child_types
497
+ ["data", "supporting file", "profile", "lorem ipsum", "dolor"]
498
+ end
499
+
500
+ def to_solr(solr_doc=Hash.new)
501
+ super(solr_doc)
502
+
503
+ extract_person_full_names.each_pair {|n,v| ::Solrizer::Extractor.insert_solr_field_value(solr_doc, n, v) }
504
+ extract_person_organizations.each_pair {|n,v| ::Solrizer::Extractor.insert_solr_field_value(solr_doc, n, v) }
505
+ extract_person_full_names_and_computing_ids.each_pair {|n,v| ::Solrizer::Extractor.insert_solr_field_value(solr_doc, n, v) }
506
+
507
+ ::Solrizer::Extractor.insert_solr_field_value(solr_doc, "object_type_facet", "Article")
508
+ ::Solrizer::Extractor.insert_solr_field_value(solr_doc, "mods_journal_title_info_facet", "Unknown") if solr_doc["mods_journal_title_info_facet"].nil? || solr_doc["mods_journal_title_info_facet"].blank?
509
+
510
+ solr_doc
511
+ end
512
+
513
+ # extracts the last_name##full_name##computing_id to be used by home view
514
+ def extract_person_full_names_and_computing_ids
515
+ names = {}
516
+ self.find_by_terms(:person).each do |person|
517
+ name_parts = person.children.inject({}) do |hash,child|
518
+ hash[child.get_attribute(:type)] = child.text if ["family","given"].include? child.get_attribute(:type)
519
+ hash["computing_id"] = child.text if child.name == 'computing_id'
520
+ hash
521
+ end
522
+ if name_parts.length == 3 and person.search(:roleTerm).children.text.include?("Author")
523
+ if name_parts["family"].blank? && name_parts["given"].blank? && name_parts["computing_id"].blank?
524
+ value = "Unknown Author"
525
+ else
526
+ value = "#{name_parts["family"]}, #{name_parts["given"]} (#{name_parts["computing_id"]})"
527
+ end
528
+ ::Solrizer::Extractor.insert_solr_field_value(names, "person_full_name_cid_facet", value) if name_parts.length == 3
529
+ end
530
+ end
531
+ names
532
+ end
533
+
534
+ end
535
+ end