Class: Hydra::Datastream::ModsImage

Inherits:
ActiveFedora::NokogiriDatastream
  • Object
show all
Includes:
CommonModsIndexMethods
Defined in:
app/models/hydra/datastream/mods_image.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CommonModsIndexMethods

#extract_person_full_names, #extract_person_organizations

Class Method Details

.common_relator_termsObject



229
230
231
232
233
234
235
236
237
238
239
240
# File 'app/models/hydra/datastream/mods_image.rb', line 229

def self.common_relator_terms
   {"aut" => "Author",
    "clb" => "Collaborator",
    "com" => "Compiler",
    "ctb" => "Contributor",
    "cre" => "Creator",
    "edt" => "Editor",
    "ill" => "Illustrator",
    "oth" => "Other",
    "trl" => "Translator",
    }
end

.conference_relator_termsObject



257
258
259
260
261
# File 'app/models/hydra/datastream/mods_image.rb', line 257

def self.conference_relator_terms
  {
    "hst" => "Host"
  }
end

.conference_templateObject

Generates a new Conference node



178
179
180
181
182
183
184
185
186
187
188
# File 'app/models/hydra/datastream/mods_image.rb', line 178

def self.conference_template
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.name(:type=>"conference") {
      xml.namePart
      xml.role {
        xml.roleTerm(:authority=>"marcrelator", :type=>"text")
      }                          
    }
  end
  return builder.doc.root
end

.dc_relator_termsObject



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'app/models/hydra/datastream/mods_image.rb', line 270

def self.dc_relator_terms
 {"acp" => "Art copyist",
  "act" => "Actor",
  "adp" => "Adapter",
  "aft" => "Author of afterword, colophon, etc.",
  "anl" => "Analyst",
  "anm" => "Animator",
  "ann" => "Annotator",
  "ant" => "Bibliographic antecedent",
  "app" => "Applicant",
  "aqt" => "Author in quotations or text abstracts",
  "arc" => "Architect",
  "ard" => "Artistic director ",
  "arr" => "Arranger",
  "art" => "Artist",
  "asg" => "Assignee",
  "asn" => "Associated name",
  "att" => "Attributed name",
  "auc" => "Auctioneer",
  "aud" => "Author of dialog",
  "aui" => "Author of introduction",
  "aus" => "Author of screenplay",
  "aut" => "Author",
  "bdd" => "Binding designer",
  "bjd" => "Bookjacket designer",
  "bkd" => "Book designer",
  "bkp" => "Book producer",
  "bnd" => "Binder",
  "bpd" => "Bookplate designer",
  "bsl" => "Bookseller",
  "ccp" => "Conceptor",
  "chr" => "Choreographer",
  "clb" => "Collaborator",
  "cli" => "Client",
  "cll" => "Calligrapher",
  "clt" => "Collotyper",
  "cmm" => "Commentator",
  "cmp" => "Composer",
  "cmt" => "Compositor",
  "cng" => "Cinematographer",
  "cnd" => "Conductor",
  "cns" => "Censor",
  "coe" => "Contestant -appellee",
  "col" => "Collector",
  "com" => "Compiler",
  "cos" => "Contestant",
  "cot" => "Contestant -appellant",
  "cov" => "Cover designer",
  "cpc" => "Copyright claimant",
  "cpe" => "Complainant-appellee",
  "cph" => "Copyright holder",
  "cpl" => "Complainant",
  "cpt" => "Complainant-appellant",
  "cre" => "Creator",
  "crp" => "Correspondent",
  "crr" => "Corrector",
  "csl" => "Consultant",
  "csp" => "Consultant to a project",
  "cst" => "Costume designer",
  "ctb" => "Contributor",
  "cte" => "Contestee-appellee",
  "ctg" => "Cartographer",
  "ctr" => "Contractor",
  "cts" => "Contestee",
  "ctt" => "Contestee-appellant",
  "cur" => "Curator",
  "cwt" => "Commentator for written text",
  "dfd" => "Defendant",
  "dfe" => "Defendant-appellee",
  "dft" => "Defendant-appellant",
  "dgg" => "Degree grantor",
  "dis" => "Dissertant",
  "dln" => "Delineator",
  "dnc" => "Dancer",
  "dnr" => "Donor",
  "dpc" => "Depicted",
  "dpt" => "Depositor",
  "drm" => "Draftsman",
  "drt" => "Director",
  "dsr" => "Designer",
  "dst" => "Distributor",
  "dtc" => "Data contributor ",
  "dte" => "Dedicatee",
  "dtm" => "Data manager ",
  "dto" => "Dedicator",
  "dub" => "Dubious author",
  "edt" => "Editor",
  "egr" => "Engraver",
  "elg" => "Electrician ",
  "elt" => "Electrotyper",
  "eng" => "Engineer",
  "etr" => "Etcher",
  "exp" => "Expert",
  "fac" => "Facsimilist",
  "fld" => "Field director ",
  "flm" => "Film editor",
  "fmo" => "Former owner",
  "fpy" => "First party",
  "fnd" => "Funder",
  "frg" => "Forger",
  "gis" => "Geographic information specialist ",
  "grt" => "Graphic technician",
  "hnr" => "Honoree",
  "hst" => "Host",
  "ill" => "Illustrator",
  "ilu" => "Illuminator",
  "ins" => "Inscriber",
  "inv" => "Inventor",
  "itr" => "Instrumentalist",
  "ive" => "Interviewee",
  "ivr" => "Interviewer",
  "lbr" => "Laboratory ",
  "lbt" => "Librettist",
  "ldr" => "Laboratory director ",
  "led" => "Lead",
  "lee" => "Libelee-appellee",
  "lel" => "Libelee",
  "len" => "Lender",
  "let" => "Libelee-appellant",
  "lgd" => "Lighting designer",
  "lie" => "Libelant-appellee",
  "lil" => "Libelant",
  "lit" => "Libelant-appellant",
  "lsa" => "Landscape architect",
  "lse" => "Licensee",
  "lso" => "Licensor",
  "ltg" => "Lithographer",
  "lyr" => "Lyricist",
  "mcp" => "Music copyist",
  "mfr" => "Manufacturer",
  "mdc" => "Metadata contact",
  "mod" => "Moderator",
  "mon" => "Monitor",
  "mrk" => "Markup editor",
  "msd" => "Musical director",
  "mte" => "Metal-engraver",
  "mus" => "Musician",
  "nrt" => "Narrator",
  "opn" => "Opponent",
  "org" => "Originator",
  "orm" => "Organizer of meeting",
  "oth" => "Other",
  "own" => "Owner",
  "pat" => "Patron",
  "pbd" => "Publishing director",
  "pbl" => "Publisher",
  "pdr" => "Project director",
  "pfr" => "Proofreader",
  "pht" => "Photographer",
  "plt" => "Platemaker",
  "pma" => "Permitting agency",
  "pmn" => "Production manager",
  "pop" => "Printer of plates",
  "ppm" => "Papermaker",
  "ppt" => "Puppeteer",
  "prc" => "Process contact",
  "prd" => "Production personnel",
  "prf" => "Performer",
  "prg" => "Programmer",
  "prm" => "Printmaker",
  "pro" => "Producer",
  "prt" => "Printer",
  "pta" => "Patent applicant",
  "pte" => "Plaintiff -appellee",
  "ptf" => "Plaintiff",
  "pth" => "Patent holder",
  "ptt" => "Plaintiff-appellant",
  "rbr" => "Rubricator",
  "rce" => "Recording engineer",
  "rcp" => "Recipient",
  "red" => "Redactor",
  "ren" => "Renderer",
  "res" => "Researcher",
  "rev" => "Reviewer",
  "rps" => "Repository",
  "rpt" => "Reporter",
  "rpy" => "Responsible party",
  "rse" => "Respondent-appellee",
  "rsg" => "Restager",
  "rsp" => "Respondent",
  "rst" => "Respondent-appellant",
  "rth" => "Research team head",
  "rtm" => "Research team member",
  "sad" => "Scientific advisor",
  "sce" => "Scenarist",
  "scl" => "Sculptor",
  "scr" => "Scribe",
  "sds" => "Sound designer",
  "sec" => "Secretary",
  "sgn" => "Signer",
  "sht" => "Supporting host",
  "sng" => "Singer",
  "spk" => "Speaker",
  "spn" => "Sponsor",
  "spy" => "Second party",
  "srv" => "Surveyor",
  "std" => "Set designer",
  "stl" => "Storyteller",
  "stm" => "Stage manager",
  "stn" => "Standards body",
  "str" => "Stereotyper",
  "tcd" => "Technical director",
  "tch" => "Teacher",
  "ths" => "Thesis advisor",
  "trc" => "Transcriber",
  "trl" => "Translator",
  "tyd" => "Type designer",
  "tyg" => "Typographer",
  "vdg" => "Videographer",
  "voc" => "Vocalist",
  "wam" => "Writer of accompanying material",
  "wdc" => "Woodcutter",
  "wde" => "Wood -engraver",
  "wit" => "Witness"}
end

.full_name_templateObject



156
157
158
159
160
161
# File 'app/models/hydra/datastream/mods_image.rb', line 156

def self.full_name_template
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.full_name(:type => "personal")
  end
  return builder.doc.root
end

.organization_relator_termsObject



263
264
265
266
267
268
# File 'app/models/hydra/datastream/mods_image.rb', line 263

def self.organization_relator_terms
  {
    "fnd" => "Funder",
    "hst" => "Host"
  }
end

.organization_templateObject

Generates a new Organization node Uses mods:name



165
166
167
168
169
170
171
172
173
174
175
# File 'app/models/hydra/datastream/mods_image.rb', line 165

def self.organization_template
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.name(:type=>"corporate") {
      xml.namePart
      xml.role {
        xml.roleTerm(:authority=>"marcrelator", :type=>"text")
      }                          
    }
  end
  return builder.doc.root
end

.person_relator_termsObject



242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'app/models/hydra/datastream/mods_image.rb', line 242

def self.person_relator_terms
  {"aut" => "Author",
   "clb" => "Collaborator",
   "com" => "Compiler",
   "cre" => "Creator",
   "ctb" => "Contributor",
   "edt" => "Editor",
   "ill" => "Illustrator",
   "res" => "Researcher",
   "rth" => "Research team head",
   "rtm" => "Research team member",
   "trl" => "Translator"
   }
end

.person_templateObject

Generates a new Person node



142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'app/models/hydra/datastream/mods_image.rb', line 142

def self.person_template
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.name(:type=>"personal") {
      xml.namePart(:type=>"family")
      xml.namePart(:type=>"given")
      xml.affiliation
      xml.role {
        xml.roleTerm(:type=>"text")
      }
    }
  end
  return builder.doc.root
end

.valid_child_typesObject



486
487
488
# File 'app/models/hydra/datastream/mods_image.rb', line 486

def self.valid_child_types
  ["data", "supporting file", "profile", "lorem ipsum", "dolor"]
end

.xml_templateObject

Generates an empty Mods Image (used when you call ModsImage.new without passing in existing xml)



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'app/models/hydra/datastream/mods_image.rb', line 80

def self.xml_template
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.mods(:version=>"3.3", "xmlns:xlink"=>"http://www.w3.org/1999/xlink",
       "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
       "xmlns"=>"http://www.loc.gov/mods/v3",
       "xsi:schemaLocation"=>"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd") {
         xml.titleInfo(:lang=>"") {
           xml.title
         }
         xml.name(:type=>"personal") {
           xml.namePart(:type=>"given")
           xml.namePart(:type=>"family")
           xml.affiliation
           xml.role {
             xml.roleTerm(:authority=>"marcrelator", :type=>"text")
           }
         }
         xml.typeOfResource
         xml.genre(:authority=>"marcgt")
         xml.language {
           xml.languageTerm(:authority=>"iso639-2b", :type=>"code")
         }
  # mods:physicaldescription/mods:extent - used for storing file size in human-readable form.
  xml.physicalDescription {
     xml.extent
  }
         xml.abstract
         xml.subject {
           xml.topic
         }
         xml.relatedItem(:type=>"host") {
           xml.titleInfo {
             xml.title
           }
           xml.identifier(:type=>"issn")
           xml.originInfo {
             xml.publisher
             xml.dateIssued
           }
           xml.part {
             xml.detail(:type=>"volume") {
               xml.number
             }
             xml.detail(:type=>"number") {
               xml.number
             }
             xml.extent(:unit=>"pages") {
               xml.start
               xml.end
             }
             xml.date
           }
         }
         xml.location {
           xml.url
         }
    }
  end
  return builder.doc
end

Instance Method Details

#insert_contributor(type, opts = {}) ⇒ Object

Inserts a new contributor (mods:name) into the mods document creates contributors of type :person, :organization, or :conference



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'app/models/hydra/datastream/mods_image.rb', line 192

def insert_contributor(type, opts={})
  case type.to_sym 
  when :person
    node = Hydra::Datastream::ModsImage.person_template
    nodeset = self.find_by_terms(:person)
  when :organization
    node = Hydra::Datastream::ModsImage.organization_template
    nodeset = self.find_by_terms(:organization)
  when :conference
    node = Hydra::Datastream::ModsImage.conference_template
    nodeset = self.find_by_terms(:conference)
  else
    ActiveFedora.logger.warn("#{type} is not a valid argument for Hydra::Datastream::ModsImage.insert_contributor")
    node = nil
    index = nil
  end
  
  unless nodeset.nil?
    if nodeset.empty?
      self.ng_xml.root.add_child(node)
      index = 0
    else
      nodeset.after(node)
      index = nodeset.length
    end
    self.dirty = true
  end
  
  return node, index
end

#remove_contributor(contributor_type, index) ⇒ Object

Remove the contributor entry identified by @contributor_type and @index



224
225
226
227
# File 'app/models/hydra/datastream/mods_image.rb', line 224

def remove_contributor(contributor_type, index)
  self.find_by_terms( {contributor_type.to_sym => index.to_i} ).first.remove
  self.dirty = true
end

#to_solr(solr_doc = Hash.new) ⇒ Object



490
491
492
493
494
495
496
# File 'app/models/hydra/datastream/mods_image.rb', line 490

def to_solr(solr_doc=Hash.new)
  super(solr_doc)
  solr_doc.merge!(extract_person_full_names)
  solr_doc.merge!(extract_person_organizations)
  solr_doc.merge!(:object_type_facet => "Image")
  solr_doc
end