libis-tools 0.9.25 → 0.9.27

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f083609ed0179998247ee56ec2432182fb1bbd32
4
- data.tar.gz: 8418e85cae3c4dfb7d6dc7f8c178da71bed58d2e
3
+ metadata.gz: cfb982a51111d107e3556e974ae13c6785f57fc3
4
+ data.tar.gz: 9f2704b0359750d4be83c1ee426c5ac5f912ecd7
5
5
  SHA512:
6
- metadata.gz: 84f969688fad37af3321f1b9631af1ad0b4deacac4cce100a9eee783775e55aaeec5c3175bd9b38b007f9f998ffb75039ecec08d4c73739db12b5164cc309cc8
7
- data.tar.gz: 4e0109dca780dce283e969c3b749932fe218a6d790db1108ca1d976768a67206a920278cc01cc1a42bf5858179fa6ead7048b4e3e27bd7b8b490e41ccffe57c2
6
+ metadata.gz: a1ecf9fd301c96620532433966b6f88d24f3b442be563f9006bc5570b714d96b0035a5d7ad84551bf01c80557bcd54396c88116606f07c22907df3562765f3e1
7
+ data.tar.gz: 63af44158eadedc92367164e86a6b0065f80f1c4416c9b18615de6602f60cff7184531d95cc0da3a9d5ed32ddfb217823033ec3484160df1bacddd0661a0cd33
@@ -124,7 +124,9 @@ module Libis
124
124
 
125
125
  def marc2dc_identifier_029(xml)
126
126
  # "Siglum: " [MARC 029 __ $a]
127
- each_field('029__', 'a') { |f| xml['dc'].identifier element(f, prefix: 'Siglum: ') }
127
+ # each_field('029__', 'a') { |f| xml['dc'].identifier element(f, prefix: 'Siglum: ') }
128
+ # ALMA: 029 __ a => 028 00 a
129
+ each_field('02800', 'a') { |f| xml['dc'].identifier element(f, prefix: 'Siglum: ') }
128
130
  end
129
131
 
130
132
  def marc2dc_identifier_700(xml)
@@ -139,7 +141,7 @@ module Libis
139
141
 
140
142
  def marc2dc_identifier_752(xml)
141
143
  # [MARC 752 __ $0]
142
- each_field('752#_', '0') { |f| xml['dc'].identifier f }
144
+ each_field('752__', '0') { |f| xml['dc'].identifier f }
143
145
  end
144
146
 
145
147
  def marc2dc_identifier_020(xml)
@@ -179,8 +181,17 @@ module Libis
179
181
 
180
182
  def marc2dc_identifier_690(xml)
181
183
  # [MARC 690 02 $0]
182
- all_tags('69002', '0a') { |t|
183
- if t._0 =~ /^\(ODIS-(PS|ORG)\)(\d)+$/
184
+ # all_tags('69002', '0a') { |t|
185
+ # if t._0 =~ /^\(ODIS-(PS|ORG)\)(\d)+$/
186
+ # xml['dc'].identifier('xsi:type' => 'dcterms:URI').text odis_link($1, $2, CGI::escape(t._a))
187
+ # else
188
+ # xml['dc'].identifier t._a
189
+ # end
190
+ # }
191
+ # ALMA: 690 02 ax0 => 650 _7 ax6 $2 == 'KADOC'
192
+ all_tags('650_7', '6a') { |t|
193
+ next unless t._2 == 'KADOC'
194
+ if t._6 =~ /^\(ODIS-(PS|ORG)\)(\d)+$/
184
195
  xml['dc'].identifier('xsi:type' => 'dcterms:URI').text odis_link($1, $2, CGI::escape(t._a))
185
196
  else
186
197
  xml['dc'].identifier t._a
@@ -208,15 +219,23 @@ module Libis
208
219
 
209
220
  def marc2dc_title_245_0(xml)
210
221
  # [MARC 245 0# $a] " " [MARC 245 0# $b] " [" [MARC 245 0# $h] "]"
211
- all_tags('2450#', 'a b h') { |t|
212
- xml['dc'].title list_s(t._ab, opt_s(t._h))
222
+ # all_tags('2450#', 'a b h') { |t|
223
+ # xml['dc'].title list_s(t._ab, opt_s(t._h))
224
+ # }
225
+ # ALMA: 245 ## Zh => 245 ## 6 [$h skipped, ': ' before $ skipped]
226
+ all_tags('2450#', 'a b') { |t|
227
+ xml['dc'].title element(t._ab, join: ' : ')
213
228
  }
214
229
  end
215
230
 
216
231
  def marc2dc_title_245_1(xml)
217
232
  # [MARC 245 1# $a] " " [MARC 245 1# $b] " [" [MARC 245 1# $h] "]"
218
- all_tags('2451#', 'a b h') { |t|
219
- xml['dc'].title element(t._ab, opt_s(t._h), join: ' ')
233
+ # all_tags('2451#', 'a b h') { |t|
234
+ # xml['dc'].title element(t._ab, opt_s(t._h), join: ' ')
235
+ # }
236
+ # ALMA: 245 ## Zh => 245 ## 6 [$h skipped, ': ' before $ skipped]
237
+ all_tags('2451#', 'a b') { |t|
238
+ xml['dc'].title element(t._ab, join: ' : ')
220
239
  }
221
240
  end
222
241
 
@@ -237,13 +256,19 @@ module Libis
237
256
 
238
257
  def marc2dc_ispartof_243(xml)
239
258
  # [MARC 243 1# $a]
240
- each_field('2431#', 'a') { |f| xml['dcterms'].isPartOf f }
259
+ # each_field('2431#', 'a') { |f| xml['dcterms'].isPartOf f }
260
+ # ALMA: 243 ## a => 830 ## a
261
+ each_field('8301#', 'a') { |f| xml['dcterms'].isPartOf f }
241
262
  end
242
263
 
243
264
  def marc2dc_ispartof_440(xml)
244
265
  # [MARC 440 _# $a] " : " [MARC 440 _# $b] " , " [MARC 440 _# $v]
245
- all_tags('440_#', 'a b v') { |t|
246
- xml['dcterms'].isPartOf element({parts: t._ab, join: ' : '}, t._v, join: ' , ')
266
+ # all_tags('440_#', 'a b v') { |t|
267
+ # xml['dcterms'].isPartOf element({parts: t._ab, join: ' : '}, t._v, join: ' , ')
268
+ # }
269
+ # ALMA: 440 _# ab => 490 1_ a [$b replaced with ' : ']
270
+ all_tags('4901_', 'a v') { |t|
271
+ xml['dcterms'].isPartOf element(t._a, t._v, join: ' , ')
247
272
  }
248
273
  end
249
274
 
@@ -327,7 +352,11 @@ module Libis
327
352
 
328
353
  def marc2dc_alternative_246_19(xml)
329
354
  # [MARC 246 19 $a] ". " [MARC 246 19 $b]
330
- all_tags('24619', 'a b') { |t|
355
+ # all_tags('24619', 'a b') { |t|
356
+ # xml['dcterms'].alternative element(t._ab, join: '. ')
357
+ # }
358
+ # ALMA: 246 19 => 246 33
359
+ all_tags('24633', 'a b') { |t|
331
360
  xml['dcterms'].alternative element(t._ab, join: '. ')
332
361
  }
333
362
  end
@@ -362,10 +391,18 @@ module Libis
362
391
 
363
392
  def marc2dc_creator_100_1(xml)
364
393
  # [MARC 100 1_ $a] " " [MARC 100 1_ $b] " ("[MARC 100 1_ $c] ") " "("[MARC 100 1_ $d]") ("[MARC 100 1_ $g]"), " [MARC 100 1_ $4]" ("[MARC 100 1_ $e]") (" [MARC 100 1_ $9]")"
365
- all_tags('1001_', 'a b c d g e 9') { |t|
394
+ # all_tags('1001_', 'a b c d g e 9') { |t|
395
+ # next unless check_name(t, :creator)
396
+ # xml['dc'].creator element(list_s(t._ab, opt_r(t._c), opt_r(t._d), opt_r(t._g)),
397
+ # list_s(full_name(t), opt_r(t._e), opt_r(t._9)),
398
+ # join: ', ')
399
+ # }
400
+
401
+ # ALMA: 100 #_ 9 => 100 #_ 3
402
+ all_tags('1001_', 'a b c d g e 3') { |t|
366
403
  next unless check_name(t, :creator)
367
404
  xml['dc'].creator element(list_s(t._ab, opt_r(t._c), opt_r(t._d), opt_r(t._g)),
368
- list_s(full_name(t), opt_r(t._e), opt_r(t._9)),
405
+ list_s(full_name(t), opt_r(t._e), opt_r(t._3)),
369
406
  join: ', ')
370
407
  }
371
408
  end
@@ -489,17 +526,28 @@ module Libis
489
526
 
490
527
  def marc2dc_subject_691(xml)
491
528
  # [MARC 691 E1 $8] " " [ MARC 691 E1 $a]
492
- all_tags('691E1', 'a8') { |t|
529
+ # all_tags('691E1', 'a8') { |t|
530
+ # attributes = {'xsi:type' => 'http://purl.org/dc/terms/UDC'}
531
+ # x = taalcode(t._9)
532
+ # attributes['xml:lang'] = x if x
533
+ # xml['dc'].subject(attributes).text list_s(t._ax)
534
+ # }
535
+ # ALMA: 691 E1 8a => 650 _7 ax $2 == 'UDC' $9 skipped
536
+ all_tags('650_7', 'a x') { |t|
537
+ next unless t._2 == 'UDC'
493
538
  attributes = {'xsi:type' => 'http://purl.org/dc/terms/UDC'}
494
- x = taalcode(t._9)
495
- attributes['xml:lang'] = x if x
496
- xml['dc'].subject(attributes).text list_s(t._ax)
539
+ xml['dc'].subject(attributes).text list_s(t._x) # should be t._ax by spec, but seems idiotic
497
540
  }
498
541
  end
499
542
 
500
543
  def marc2dc_subject_082(xml)
501
544
  # [MARC 082 14 $a] " " [MARC 082 14 $x]
502
- all_tags('08214', 'a x') { |t|
545
+ # all_tags('08214', 'a x') { |t|
546
+ # xml['dc'].subject('xsi:type' => 'http://purl.org/dc/terms/DDC', 'xml:lang' => 'en').text list_s(t._ax)
547
+ # }
548
+ # ALMA: 082 14 ax2 => 650 _7 ax4 $2 = 'DDC abridged'
549
+ all_tags('650_7', 'a x') { |t|
550
+ next unless t._2 == 'DDC abridged'
503
551
  xml['dc'].subject('xsi:type' => 'http://purl.org/dc/terms/DDC', 'xml:lang' => 'en').text list_s(t._ax)
504
552
  }
505
553
  end
@@ -507,7 +555,10 @@ module Libis
507
555
  def marc2dc_subject_690(xml)
508
556
  # [MARC 690 [xx]$a]
509
557
  # Set dedups the fields
510
- Set.new(each_field('690##', 'a')) { |f| xml['dc'].subject f }
558
+ # Set.new(each_field('690##', 'a')) { |f| xml['dc'].subject f }
559
+ # ALMA: 690 ## => 650 _7
560
+ # Set.new(all_fields('650_7', 'a')).each { |f| xml['dc'].subject f }
561
+ # rule disbled gives duplicates and needs to be redefined by KUL cataloguing staff
511
562
  end
512
563
 
513
564
  def marc2dc_temporal(xml)
@@ -526,16 +577,24 @@ module Libis
526
577
 
527
578
  def marc2dc_temporal_362(xml)
528
579
  # [MARC 362 __ $a]
529
- each_field('362__', 'a') { |f| xml['dc'].temporal f }
580
+ # each_field('362__', 'a') { |f| xml['dc'].temporal f }
581
+ # ALMA: 362 __ a => 362 0_ a
582
+ each_field('3620_', 'a') { |f| xml['dc'].temporal f }
530
583
  end
531
584
 
532
585
  def marc2dc_temporal_752(xml)
533
586
  # [MARC 752 9_ $9]
534
- each_field('7529_', '9') { |f| xml['dc'].temporal f }
587
+ # each_field('7529_', '9') { |f| xml['dc'].temporal f }
588
+ # ALMA: 752 9_ 9 => 953 __ a
589
+ each_field('953__', 'a') { |f| xml['dc'].temporal f }
535
590
 
536
591
  # [MARC 752 _9 $a] " (" [MARC 752 _9 $9]")"
537
- all_tags('752_9', 'a 9') { |t|
538
- xml['dc'].temporal list_s(t._a, opt_r(t._9))
592
+ # all_tags('752_9', 'a 9') { |t|
593
+ # xml['dc'].temporal list_s(t._a, opt_r(t._9))
594
+ # }
595
+ # ALMA: 752 _9 a9 => 953 __ bc
596
+ all_tags('953__', 'b c') { |t|
597
+ xml['dc'].temporal list_s(t._b, opt_r(t._c))
539
598
  }
540
599
  end
541
600
 
@@ -544,42 +603,74 @@ module Libis
544
603
 
545
604
  x = element(
546
605
  # [MARC 047 __ $a] " (" [MARC 047 __ $9]")"
547
- all_tags('047__', 'a 9').collect { |t|
548
- list_s(t._a, opt_r(t._9))
606
+ # all_tags('047__', 'a 9').collect { |t|
607
+ # list_s(t._a, opt_r(t._9))
608
+ # },
609
+ # ALMA: 047 __ a9 => 947 __ ab
610
+ all_tags('947__', 'a b').collect { |t|
611
+ list_s(t._a, opt_r(t._b))
549
612
  },
550
613
  # [MARC 598 __ $a]
551
- all_fields('598__', 'a'),
614
+ # all_fields('598__', 'a'),
615
+ # ALMA: 598 __ a => 958 __ a
616
+ all_fields('958__', 'a'),
552
617
  # [MARC 597 __ $a]
553
- all_fields('597__', 'a'),
618
+ # all_fields('597__', 'a'),
619
+ # ALMA: 597 __ a => 957 __ a
620
+ all_fields('957__', 'a'),
554
621
  # [MARC 500 __ $a]
555
622
  all_fields('500__', 'a'),
556
623
  # [MARC 520 2_ $a]
557
624
  all_fields('5202_', 'a'),
558
625
  # "Projectie: " [MARC 093 __ $a]
559
- all_tags('093__', 'a').collect { |t| element(t._a, prefix: 'Projectie: ') },
626
+ # all_tags('093__', 'a').collect { |t| element(t._a, prefix: 'Projectie: ') },
627
+ # ALMA: 093 ## a => 954 __ a
628
+ all_tags('954__', 'a').collect { |t| element(t._a, prefix: 'Projectie: ') },
560
629
  # "Equidistance " [MARC 094 __ $a*]
561
- all_tags('094__', 'a').collect { |t| element(t.a_a, prefix: 'Equidistance ', join: ';') },
630
+ # all_tags('094__', 'a').collect { |t| element(t.a_a, prefix: 'Equidistance ', join: ';') },
631
+ # ALMA: 094 ## a => 954 __ b
632
+ all_tags('954__', 'b').collect { |t| element(t.a_b, prefix: 'Equidistance ', join: ';') },
562
633
  # [MARC 502 __ $a] ([MARC 502 __ $9])
563
- all_tags('502__', 'a 9').collect { |t|
564
- list_s(t._a, opt_r(t._9))
634
+ # all_tags('502__', 'a 9').collect { |t|
635
+ # list_s(t._a, opt_r(t._9))
636
+ # },
637
+ # ALMA: 502 __ 9 => 502 __ g
638
+ all_tags('502__', 'a g').collect { |t|
639
+ list_s(t._a, opt_r(t._g))
565
640
  },
566
641
  # [MARC 529 __ $a] ", " [MARC 529 __ $b] " (" [MARC 529 __ $c] ")"
567
- all_tags('529__', 'a b 9').collect { |t|
642
+ # all_tags('529__', 'a b 9').collect { |t|
643
+ # element(t._ab,
644
+ # join: ', ',
645
+ # postfix: opt_r(t._9))
646
+ # },
647
+ # ALMA: 529 __ ab9 => 957 __ abc
648
+ all_tags('957__', 'a b c').collect { |t|
568
649
  element(t._ab,
569
650
  join: ', ',
570
- postfix: opt_r(t._9))
651
+ postfix: opt_r(t._c))
571
652
  },
572
653
  # [MARC 534 9_ $a]
573
- all_fields('5349_', 'a'),
654
+ # all_fields('5349_', 'a'),
655
+ # ALMA: 534 9_ a => 534 __ t
656
+ all_fields('534__', 't'),
574
657
  # [MARC 534 _9 $a] "(oorspronkelijke uitgever)"
575
- all_fields('534_9', 'a').collect { |f| element(f, postfix: '(oorspronkelijke uitgever)') },
658
+ # all_fields('534_9', 'a').collect { |f| element(f, postfix: '(oorspronkelijke uitgever)') },
659
+ # ALMA: 534 _9 a => 534 __ c
660
+ all_fields('534__', 'c').collect { |f| element(f, postfix: '(oorspronkelijke uitgever)') },
576
661
  # [MARC 545 __ $a]
577
662
  all_fields('545__', 'a'),
578
663
  # [MARC 562 __ $a]
579
- all_fields('562__', 'a'),
664
+ # all_fields('562__', 'a'),
665
+ # ALMA: 562 __ a => 963 __ a
666
+ all_fields('963__', 'a'),
580
667
  # [MARC 563 __ $a] " " [MARC 563 __ $9] " (" [MARC 563 __ $u] ")"
581
- all_tags('563__', 'a 9 u').collect { |t|
582
- list_s(t._a9, opt_r(t._u))
668
+ # all_tags('563__', 'a 9 u').collect { |t|
669
+ # list_s(t._a9, opt_r(t._u))
670
+ # },
671
+ # ALMA: 563 __ a9u => 563 __ a3u
672
+ all_tags('563__', 'a 3 u').collect { |t|
673
+ list_s(t._a3, opt_r(t._u))
583
674
  },
584
675
  # [MARC 586 __ $a]
585
676
  all_fields('586__', 'a'),
@@ -646,18 +737,31 @@ module Libis
646
737
 
647
738
  def marc2dc_tableofcontents_505_0_(xml)
648
739
  # [MARC 505 0_ $a] " "[MARC 505 0_ $t]" / " [MARC 505 0_ $r*] " ("[MARC 505 0_ $9*]")"
649
- all_tags('5050_', 'a t r 9') { |t|
740
+ # all_tags('5050_', 'a t r 9') { |t|
741
+ # xml['dcterms'].tableOfContents list_s(t._at,
742
+ # repeat(t.a_r, prefix: '/ '),
743
+ # opt_r(repeat(t.a_9)))
744
+ # }
745
+ # ALMA: 505 ## 9 => 505 ## g
746
+ all_tags('5050_', 'a t r g') { |t|
650
747
  xml['dcterms'].tableOfContents list_s(t._at,
651
- repeat(t.a_r, prefix: '/ '),
652
- opt_r(repeat(t.a_9)))
748
+ repeat(t.a_r, prefix: '/ '),
749
+ opt_r(repeat(t.a_g)))
653
750
  }
654
751
  end
655
752
 
656
753
  def marc2dc_tableofcontents_505_09(xml)
657
754
  # [MARC 505 09 $a*] "\n" [MARC 505 09 $9*] "\n" [MARC 505 09 $u*]
658
- all_tags('50509', 'a u 9') { |t|
755
+ # all_tags('50509', 'a u 9') { |t|
756
+ # xml['dcterms'].tableOfContents element(repeat(t.a_a),
757
+ # repeat(t.a_9),
758
+ # repeat(t.a_u),
759
+ # join: "\n")
760
+ # }
761
+ # ALMA: 505 ## 9 => 505 ## g
762
+ all_tags('50509', 'a u g') { |t|
659
763
  xml['dcterms'].tableOfContents element(repeat(t.a_a),
660
- repeat(t.a_9),
764
+ repeat(t.a_g),
661
765
  repeat(t.a_u),
662
766
  join: "\n")
663
767
  }
@@ -665,10 +769,16 @@ module Libis
665
769
 
666
770
  def marc2dc_tableofcontents_505_2_(xml)
667
771
  # [MARC 505 2_ $a] " "[MARC 505 2_ $t]" / " [MARC 505 2_ $r*] " ("[MARC 505 2_ $9*]")"
668
- all_tags('5052_', 'a t r 9') { |t|
772
+ # all_tags('5052_', 'a t r 9') { |t|
773
+ # xml['dcterms'].tableOfContents list_s(t._at,
774
+ # repeat(t.a_r, prefix: '/ '),
775
+ # opt_r(repeat(t.a_9)))
776
+ # }
777
+ # ALMA: 505 ## 9 => 505 ## g
778
+ all_tags('5052_', 'a t r g') { |t|
669
779
  xml['dcterms'].tableOfContents list_s(t._at,
670
- repeat(t.a_r, prefix: '/ '),
671
- opt_r(repeat(t.a_9)))
780
+ repeat(t.a_r, prefix: '/ '),
781
+ opt_r(repeat(t.a_g)))
672
782
  }
673
783
  end
674
784
 
@@ -676,8 +786,12 @@ module Libis
676
786
  # DCTERMS:AVAILABLE
677
787
 
678
788
  # [MARC 591 ## $9] ":" [MARC 591 ## $a] " (" [MARC 591 ## $b] ")"
679
- all_tags('591##', 'a b 9') { |t|
680
- xml['dcterms'].available element(t._9a, join: ':', postfix: opt_r(t._b, prefix: ' '))
789
+ # all_tags('591##', 'a b 9') { |t|
790
+ # xml['dcterms'].available element(t._9a, join: ':', postfix: opt_r(t._b, prefix: ' '))
791
+ # }
792
+ # ALMA: 591 __ ab9 => 866 __ axz
793
+ all_tags('866##', 'a x z') { |t|
794
+ xml['dcterms'].available element(t._za, join: ':', postfix: opt_r(t._x, prefix: ' '))
681
795
  }
682
796
  end
683
797
 
@@ -703,11 +817,11 @@ module Libis
703
817
  all_tags('1000_', 'a b c d g 9') { |t|
704
818
  next unless check_name(t, :contributor)
705
819
  xml['dc'].contributor element(list_s(t._ab,
706
- opt_r(t._c),
707
- opt_r(t._d),
708
- opt_r(t._g)),
820
+ opt_r(t._c),
821
+ opt_r(t._d),
822
+ opt_r(t._g)),
709
823
  list_s(full_name(t),
710
- opt_r(t._9)),
824
+ opt_r(t._9)),
711
825
  join: ', ')
712
826
  }
713
827
  end
@@ -717,12 +831,12 @@ module Libis
717
831
  all_tags('1001_', 'a b c d g e 9') { |t|
718
832
  next unless check_name(t, :contributor)
719
833
  xml['dc'].contributor element(list_s(t._ab,
720
- opt_r(t._c),
721
- opt_r(t._d),
722
- opt_r(t._g)),
834
+ opt_r(t._c),
835
+ opt_r(t._d),
836
+ opt_r(t._g)),
723
837
  list_s(full_name(t),
724
- opt_r(t._e),
725
- opt_r(t._9)),
838
+ opt_r(t._e),
839
+ opt_r(t._9)),
726
840
  join: ', ')
727
841
  }
728
842
  end
@@ -734,7 +848,7 @@ module Libis
734
848
  next unless check_name(t, :contributor)
735
849
  xml['dc'].contributor element(t._abcd,
736
850
  list_s(t._g,
737
- opt_r(full_name(t), fix: '( |)')),
851
+ opt_r(full_name(t), fix: '( |)')),
738
852
  t._e,
739
853
  join: ', ')
740
854
  }
@@ -746,7 +860,7 @@ module Libis
746
860
  next unless check_name(t, :contributor)
747
861
  xml['dc'].contributor element(t._a,
748
862
  list_s(t._g,
749
- opt_r(full_name(t))),
863
+ opt_r(full_name(t))),
750
864
  t._e,
751
865
  join: ', ')
752
866
  }
@@ -757,10 +871,10 @@ module Libis
757
871
  all_tags('7102_', 'a g 9 e') { |t|
758
872
  next unless check_name(t, :contributor)
759
873
  xml['dc'].contributor element(list_s(t._a,
760
- opt_r(t._g)),
874
+ opt_r(t._g)),
761
875
  list_s(full_name(t),
762
- opt_r(t._9),
763
- opt_r(t._e)),
876
+ opt_r(t._9),
877
+ opt_r(t._e)),
764
878
  join: ', ')
765
879
  }
766
880
  end
@@ -771,7 +885,7 @@ module Libis
771
885
  next unless check_name(t, :contributor)
772
886
  xml['dc'].contributor element(t._anc,
773
887
  list_s(t._d,
774
- opt_r(t._g)),
888
+ opt_r(t._g)),
775
889
  join: ', ')
776
890
  }
777
891
  end
@@ -806,18 +920,29 @@ module Libis
806
920
 
807
921
  def marc2dc_publisher_260___(xml)
808
922
  # [MARC 260 __ $e] " " [MARC 260 __ $f] " " [MARC 260 __ $c] " " [MARC 260 __ $9] " uitgave: " [MARC 260 __ $g]
809
- all_tags('260__', 'e f c 9 g') { |t|
810
- xml['dc'].publisher list_s(t._c9,
811
- element(t._g, prefix: 'uitgave: '))
923
+ # all_tags('260__', 'e f c 9 g') { |t|
924
+ # xml['dc'].publisher list_s(t._efc9,
925
+ # element(t._g, prefix: 'uitgave: '))
926
+ # }
927
+ # ALMA: 260 _# 9 => 260 __ 3
928
+ all_tags('260__', 'e f c 3 g') { |t|
929
+ xml['dc'].publisher list_s(t._efc3,
930
+ element(t._g, prefix: 'uitgave: '))
812
931
  }
813
932
  end
814
933
 
815
934
  def marc2dc_publisher_260__9(xml)
816
935
  # [MARC 260 _9 $c] " " [MARC 260 _9 $9*] " (druk: ) " [MARC 260 _9 $g]
817
- all_tags('260_9', 'c 9 g') { |t|
936
+ # all_tags('260_9', 'c 9 g') { |t|
937
+ # xml['dc'].publisher list_s(t._c,
938
+ # repeat(t.a_9),
939
+ # element(t._g, prefix: 'druk: '))
940
+ # }
941
+ # ALMA: 260 _# 9 => 260 __ 3
942
+ all_tags('260_9', 'c 3 g') { |t|
818
943
  xml['dc'].publisher list_s(t._c,
819
- repeat(t.a_9),
820
- element(t._g, prefix: 'uitgave: '))
944
+ repeat(t.a_3),
945
+ element(t._g, prefix: 'druk: '))
821
946
  }
822
947
  end
823
948
 
@@ -827,7 +952,7 @@ module Libis
827
952
  next unless name_type(t) == :publisher
828
953
  xml['dc'].publisher element(t._abcd,
829
954
  list_s(t._g,
830
- opt_r(full_name(t), fix: '( |)')),
955
+ opt_r(full_name(t), fix: '( |)')),
831
956
  t._e,
832
957
  join: ', ',
833
958
  postfix: '(uitgever)')
@@ -838,7 +963,7 @@ module Libis
838
963
  # [MARC 710 29 $a] " (" [MARC 710 29 $c] "), " [MARC 710 29 $9] "," [710 29 $g] "(drukker)"
839
964
  all_tags('71029', 'a c g 9 4') { |t|
840
965
  xml['dc'].publisher element(list_s(t._a,
841
- opt_r(t._c)),
966
+ opt_r(t._c)),
842
967
  t._9g,
843
968
  join: ', ',
844
969
  postfix: '(drukker)')
@@ -901,17 +1026,22 @@ module Libis
901
1026
 
902
1027
  def marc2dc_type_655_x9_a(xml)
903
1028
  # [MARC 655 #9 $a]
904
- each_field('655#9', 'a') { |f| xml['dc'].type f }
1029
+ # each_field('655#9', 'a') { |f| xml['dc'].type f }
1030
+ # ALMA: 655 _9 a => 955 __ a
1031
+ each_field('955__', 'a') { |f| xml['dc'].type f }
905
1032
  end
906
1033
 
907
1034
  def marc2dc_type_655_9x_a(xml)
908
1035
  # [MARC 655 9# $a]
909
- each_field('6559#', 'a') { |f| xml['dc'].type f }
1036
+ # each_field('6559#', 'a') { |f| xml['dc'].type f }
1037
+ # ALMA: 655 9_ a => 955 __ b
1038
+ # Zie marc2dc_type_655_9__a
910
1039
  end
911
1040
 
912
1041
  def marc2dc_type_655__4_z(xml)
913
1042
  # [MARC 655 _4 $z]
914
- each_field('655_4', 'z') { |f| xml['dc'].type f }
1043
+ # each_field('655_4', 'z') { |f| xml['dc'].type f }
1044
+ # ALMA: 655 _4 axyz => 653 _6 a [$xyz skipped]
915
1045
  end
916
1046
 
917
1047
  def marc2dc_type_fmt(xml)
@@ -921,75 +1051,94 @@ module Libis
921
1051
 
922
1052
  def marc2dc_type_655_94_z(xml)
923
1053
  # [MARC 655 94 $z]
924
- each_field('65594', 'z') { |f| xml['dc'].type f }
1054
+ # each_field('65594', 'z') { |f| xml['dc'].type f }
1055
+ # ALMA: 655 94 axyz => 653 _6 a [$xyz skipped]
925
1056
  end
926
1057
 
927
1058
  def marc2dc_type_655_9__a(xml)
928
1059
  # [MARC 655 9_ $a]
929
- each_field('6559_', 'a') { |f| xml['dc'].type f }
1060
+ # each_field('6559_', 'a') { |f| xml['dc'].type f }
1061
+ # ALMA: 655 9_ a => 955 __ b
1062
+ each_field('955__', 'b') { |f| xml['dc'].type f }
930
1063
  end
931
1064
 
932
1065
  def marc2dc_type_088_9__a(xml)
933
1066
  # [MARC 088 9_ $a]
934
- each_field('0889_', 'a') { |f| xml['dc'].type f } if each_field('088__', 'axy').empty?
1067
+ # each_field('0889_', 'a') { |f| xml['dc'].type f } if each_field('088__', 'axy').empty?
1068
+ # ALMA: 088 9_ a9 => 340 __ d3
1069
+ # ALMA: 088 __ axyz9 => 340 __ a3 [$xyz skipped]
1070
+ each_field('340__', 'd') { |f| xml['dc'].type f } if each_field('340__', 'a').empty?
935
1071
  end
936
1072
 
937
1073
  def marc2dc_type_088____z(xml)
938
1074
  # [MARC 088 __ $z]
939
- each_field('088__', 'z') { |f| xml['dc'].type f }
1075
+ # each_field('088__', 'z') { |f| xml['dc'].type f }
1076
+ # ALMA: 088 __ axyz9 => 340 __ a3 [$xyz skipped]
940
1077
  end
941
1078
 
942
1079
  def marc2dc_type_088____a(xml)
943
1080
  # [MARC 088 __ $a]
944
- each_field('088__', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
1081
+ # each_field('088__', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
1082
+ # ALMA: 088 __ axyz9 => 340 __ a3 [$xyz skipped]
1083
+ each_field('340__', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
945
1084
  end
946
1085
 
947
1086
  def marc2dc_type_655__4_a(xml)
948
1087
  # [MARC 655 _4 $a]
949
- each_field('655_4', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
1088
+ # each_field('655_4', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
1089
+ # ALMA: 655 _4 axyz => 653 _6 a [$xyz skipped]
1090
+ each_field('653_6', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
950
1091
  end
951
1092
 
952
1093
  def marc2dc_type_655_94_a(xml)
953
1094
  # [MARC 655 94 $a]
954
- each_field('65594', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
1095
+ # each_field('65594', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
1096
+ # ALMA: 655 94 axyz => 635 _6 a [$xyz skipped]
1097
+ # Case covered by marc2dc_type_655__4_a
955
1098
  end
956
1099
 
957
1100
  def marc2dc_type_088____x(xml)
958
1101
  # [MARC 088 __ $x]
959
- each_field('088__', 'x') { |f| xml['dc'].type('xml:lang' => 'nl').text f }
1102
+ # each_field('088__', 'x') { |f| xml['dc'].type('xml:lang' => 'nl').text f }
1103
+ # ALMA: 088 __ axyz9 => 340 __ a3 [$xyz skipped]
960
1104
  end
961
1105
 
962
1106
  def marc2dc_type_655__4_x(xml)
963
1107
  # [MARC 655 _4 $x]
964
- each_field('655_4', 'x') { |f| xml['dc'].type('xml:lang' => 'nl').text f }
1108
+ # each_field('655_4', 'x') { |f| xml['dc'].type('xml:lang' => 'nl').text f }
1109
+ # ALMA: 655 _4 axyz => 653 _6 a [$xyz skipped]
965
1110
  end
966
1111
 
967
1112
  def marc2dc_type_655_94_x(xml)
968
1113
  # [MARC 655 94 $x]
969
- each_field('65594', 'x') { |f| xml['dc'].type('xml:lang' => 'nl').text f }
1114
+ # each_field('65594', 'x') { |f| xml['dc'].type('xml:lang' => 'nl').text f }
1115
+ # ALMA: 655 94 axyz => 653 _6 a [$xyz skipped]
970
1116
  end
971
1117
 
972
1118
  def marc2dc_type_088____y(xml)
973
1119
  # [MARC 088 __ $y]
974
- each_field('088__', 'y') { |f| xml['dc'].type('xml:lang' => 'fr').text f }
1120
+ # each_field('088__', 'y') { |f| xml['dc'].type('xml:lang' => 'fr').text f }
1121
+ # ALMA: 088 __ axyz9 => 340 __ a3 [$xyz skipped]
975
1122
  end
976
1123
 
977
1124
  def marc2dc_type_655__4_y(xml)
978
1125
  # [MARC 655 _4 $y]
979
- each_field('655_4', 'y') { |f| xml['dc'].type('xml:lang' => 'fr').text f }
1126
+ # each_field('655_4', 'y') { |f| xml['dc'].type('xml:lang' => 'fr').text f }
1127
+ # ALMA: 655 _4 axyz => 653 _6 a [$xyz skipped]
980
1128
  end
981
1129
 
982
1130
  def marc2dc_type_655_94_y(xml)
983
1131
  # [MARC 655 94 $y]
984
- each_field('65594', 'y') { |f| xml['dc'].type('xml:lang' => 'fr').text f }
1132
+ # each_field('65594', 'y') { |f| xml['dc'].type('xml:lang' => 'fr').text f }
1133
+ # ALMA: 655 94 axyz => 653 _6 a [$xyz skipped]
985
1134
  end
986
1135
 
987
1136
  def marc2dc_type_655__2(xml)
988
1137
  # [MARC 655 #2 $a] " " [MARC 655 #2 $x*] " " [MARC 655 #2 $9]
989
1138
  all_tags('655#2', 'a x 9') { |t|
990
1139
  xml['dc'].type({'xsi:type' => 'http://purl.org/dc/terms/MESH'}).text list_s(t._a,
991
- repeat(t.a_x),
992
- t._9)
1140
+ repeat(t.a_x),
1141
+ t._9)
993
1142
  }
994
1143
  end
995
1144
 
@@ -1006,9 +1155,14 @@ module Libis
1006
1155
 
1007
1156
  def marc2dc_spatial_752(xml)
1008
1157
  # [MARC 752 __ $a] " " [MARC 752 __ $c] " " [MARC 752 __ $d] " (" [MARC 752 __ $9] ")"
1009
- all_tags('752__', 'a c d 9') { |t|
1158
+ # all_tags('752__', 'a c d 9') { |t|
1159
+ # xml['dcterms'].spatial list_s(t._acd,
1160
+ # opt_r(t._9))
1161
+ # }
1162
+ # ALMA: 752 __ acd9 => 952 acde
1163
+ all_tags('952__', 'a c d e') { |t|
1010
1164
  xml['dcterms'].spatial list_s(t._acd,
1011
- opt_r(t._9))
1165
+ opt_r(t._e))
1012
1166
  }
1013
1167
  end
1014
1168
 
@@ -1040,8 +1194,8 @@ module Libis
1040
1194
  # [MARC 651 #0 $a] " " [MARC 651 #0 $x*] " " [MARC 651 #0 $y] " " [MARC 651 #0 $z]
1041
1195
  all_tags('651#0', 'a x y z') { |t|
1042
1196
  xml['dcterms'].spatial({'xsi:type' => 'http://purl.org/dc/terms/LCSH'}).text list_s(t._a,
1043
- repeat(t.a_x),
1044
- t._yz)
1197
+ repeat(t.a_x),
1198
+ t._yz)
1045
1199
  }
1046
1200
  end
1047
1201
 
@@ -1049,7 +1203,7 @@ module Libis
1049
1203
  # [MARC 651 #2 $a] " " [MARC 651 #2 $x*]
1050
1204
  all_tags('651#2', 'a x') { |t|
1051
1205
  xml['dcterms'].spatial({'xsi:type' => 'http://purl.org/dc/terms/LCSH'}).text list_s(t._a,
1052
- repeat(t.a_x))
1206
+ repeat(t.a_x))
1053
1207
  }
1054
1208
  end
1055
1209
 
@@ -1064,22 +1218,39 @@ module Libis
1064
1218
 
1065
1219
  def marc2dc_extent_300__(xml)
1066
1220
  # [MARC 300 __ $a*] " " [MARC 300 __ $b] " " [MARC 300__ $c*] " " [MARC 300 __ $e] " (" [MARC 300 __ $9] ")"
1067
- all_tags('300__', 'a b c e 9') { |t|
1221
+ # all_tags('300__', 'a b c e 9') { |t|
1222
+ # xml['dcterms'].extent list_s(repeat(t.a_a),
1223
+ # t._b,
1224
+ # repeat(t.a_c),
1225
+ # t._e,
1226
+ # opt_r(t._9))
1227
+ # }
1228
+ # ALMA: 300 __ 9 => 300 __ g
1229
+ all_tags('300__', 'a b c e g') { |t|
1068
1230
  xml['dcterms'].extent list_s(repeat(t.a_a),
1069
- t._b,
1070
- repeat(t.a_c),
1071
- t._e,
1072
- opt_r(t._9))
1231
+ t._b,
1232
+ repeat(t.a_c),
1233
+ t._e,
1234
+ opt_r(t._g))
1073
1235
  }
1074
1236
  end
1075
1237
 
1076
1238
  def marc2dc_extent_300_9(xml)
1077
1239
  # [MARC 300 9_ $a] " " [MARC 300 9_ $b] " " [MARC 300 9_ $c*] " " [MARC 300 9_ $e] " (" [MARC 300 9_ $9]")"
1078
- all_tags('3009_', 'a b c e 9') { |t|
1079
- xml['dcterms'].extent list_s(t._ab,
1080
- repeat(t.a_c),
1081
- t._e,
1082
- opt_r(t._9))
1240
+ # all_tags('3009_', 'a b c e 9') { |t|
1241
+ # xml['dcterms'].extent list_s(t._ab,
1242
+ # repeat(t.a_c),
1243
+ # t._e,
1244
+ # opt_r(t._9))
1245
+ # }
1246
+ # ALMA: 300 9_ ac => 300 9_ ac
1247
+ # ALMA: 300 9_ b9 => 340 __ oc
1248
+ # This change is not compatible with DC converter (only 1 tag per DC element). 2 DC elements generated instead.
1249
+ all_tags('3009_', 'a c') { |t|
1250
+ xml['dcterms'].extent list_s(t._a, repeat(t.a_c))
1251
+ }
1252
+ all_tags('340__', 'o c') { |t|
1253
+ xml['dcterms'].extent list_s(t._o, opt_r(t._c))
1083
1254
  }
1084
1255
  end
1085
1256
 
@@ -1090,12 +1261,16 @@ module Libis
1090
1261
 
1091
1262
  def marc2dc_extent_309(xml)
1092
1263
  # [MARC 309 __ $a]
1093
- each_field('309__', 'a') { |f| xml['dcterms'].extent f }
1264
+ # each_field('309__', 'a') { |f| xml['dcterms'].extent f }
1265
+ # ALMA: 309 __ a => 306 __ a
1266
+ # covered by marc2dc_extent_306
1094
1267
  end
1095
1268
 
1096
1269
  def marc2dc_extent_339(xml)
1097
1270
  # [MARC 339 __ $a*]
1098
- all_tags('339__', 'a') { |t| xml['dcterms'].extent repeat(t.a_a) }
1271
+ # all_tags('339__', 'a') { |t| xml['dcterms'].extent repeat(t.a_a) }
1272
+ # ALMA: 339 __ a => 340 __ d
1273
+ all_tags('340__', 'd') { |t| xml['dcterms'].extent repeat(t.a_d) }
1099
1274
  end
1100
1275
 
1101
1276
  def marc2dc_accrualperiodicity(xml)
@@ -1104,7 +1279,7 @@ module Libis
1104
1279
  # [MARC 310 __ $a] " (" [MARC 310 __ $b] ")"
1105
1280
  all_tags('310__', 'a b') { |t|
1106
1281
  xml['dcterms'].accrualPeriodicity list_s(t._a,
1107
- opt_r(t._b))
1282
+ opt_r(t._b))
1108
1283
  }
1109
1284
  end
1110
1285
 
@@ -1126,22 +1301,31 @@ module Libis
1126
1301
 
1127
1302
  def marc2dc_medium_319__(xml)
1128
1303
  # [MARC 319 __ $a]
1129
- each_field('319__', 'a') { |f| xml['dcterms'].medium f }
1304
+ # each_field('319__', 'a') { |f| xml['dcterms'].medium f }
1305
+ # ALMA: 319 __ a => 340 __ e
1306
+ each_field('340__', 'e') { |f| xml['dcterms'].medium f }
1130
1307
  end
1131
1308
 
1132
1309
  def marc2dc_medium_319_9(xml)
1133
1310
  # [MARC 319 9_ $a] " (" [MARC 319 9_ $9] ")"
1134
- all_tags('3199_', 'a 9') { |t|
1135
- xml['dcterms'].medium list_s(t._a,
1136
- opt_r(t._9))
1137
- }
1311
+ # all_tags('3199_', 'a 9') { |t|
1312
+ # xml['dcterms'].medium list_s(t._a,
1313
+ # opt_r(t._9))
1314
+ # }
1315
+ # ALMA: 319 9_ a => 340 __ e
1316
+ # covered by marc2dc_medium_319__
1138
1317
  end
1139
1318
 
1140
1319
  def marc2dc_medium_399(xml)
1141
1320
  # [MARC 399 __ $a] " " [MARC 399 __ $b] " (" [MARC 399 __ $9] ")"
1142
- all_tags('399__', 'a b 9') { |t|
1321
+ # all_tags('399__', 'a b 9') { |t|
1322
+ # xml['dcterms'].medium list_s(t._ab,
1323
+ # opt_r(t._9))
1324
+ # }
1325
+ # ALMA: 399 __ ab9 => 950 __ abc
1326
+ all_tags('950__', 'a b c') { |t|
1143
1327
  xml['dcterms'].medium list_s(t._ab,
1144
- opt_r(t._9))
1328
+ opt_r(t._c))
1145
1329
  }
1146
1330
  end
1147
1331
 
@@ -1156,8 +1340,12 @@ module Libis
1156
1340
  # DCTERMS:REPLACES
1157
1341
 
1158
1342
  # [MARC 247 1# $a] " : " [MARC 247 1# $b] " (" [MARC 247 1# $9] ")"
1159
- all_tags('2471#', 'a b 9') { |t|
1160
- xml['dcterms'].replaces list_s(element(t._a, t._b, join: ' : '), opt_r(t._9))
1343
+ # all_tags('2471#', 'a b 9') { |t|
1344
+ # xml['dcterms'].replaces list_s(element(t._a, t._b, join: ' : '), opt_r(t._9))
1345
+ # }
1346
+ # ALMA: 247 10 9Z => 247 10 g6
1347
+ all_tags('2471#', 'a b g') { |t|
1348
+ xml['dcterms'].replaces list_s(element(t._a, t._b, join: ' : '), opt_r(t._g))
1161
1349
  }
1162
1350
  end
1163
1351
 
@@ -1165,7 +1353,9 @@ module Libis
1165
1353
  # DCTERMS:HASVERSION
1166
1354
 
1167
1355
  # [MARC 534 __ $a]
1168
- each_field('534__', 'a') { |f| xml['dcterms'].hasVersion f }
1356
+ # each_field('534__', 'a') { |f| xml['dcterms'].hasVersion f }
1357
+ # ALMA: 534 __ a => 534 __ b
1358
+ each_field('534__', 'b') { |f| xml['dcterms'].hasVersion f }
1169
1359
  end
1170
1360
 
1171
1361
  def marc2dc_source(xml)
@@ -1176,8 +1366,12 @@ module Libis
1176
1366
 
1177
1367
  def marc2dc_source_852___(xml)
1178
1368
  # [MARC 852 __ $b] " " [MARC 852 __ $c] " " [MARC 852 __ $k] " " [MARC 852 __ $h] " " [MARC 852 __ $9] " " [MARC 852 __ $l] " " [MARC 852 __ $m]
1179
- all_tags('852__', 'b c k h 9 l m') { |t|
1180
- xml['dc'].source list_s(t._bckh9lm)
1369
+ # all_tags('852__', 'b c k h 9 l m') { |t|
1370
+ # xml['dc'].source list_s(t._bckh9lm)
1371
+ # }
1372
+ # ALMA: 852 __ 9 => 852 __ i
1373
+ all_tags('852__', 'b c k h i l m') { |t|
1374
+ xml['dc'].source list_s(t._bckhilm)
1181
1375
  }
1182
1376
  end
1183
1377
 
@@ -1272,8 +1466,12 @@ module Libis
1272
1466
 
1273
1467
  def marc2dc_language_014_9__9(xml)
1274
1468
  # [MARC 041 9_ $9*]
1275
- all_tags('0419_', '9') { |t|
1276
- xml['dc'].language repeat(t.a_9.collect { |y| taalcode(y) })
1469
+ # all_tags('0419_', '9') { |t|
1470
+ # xml['dc'].language repeat(t.a_9.collect { |y| taalcode(y) })
1471
+ # }
1472
+ # ALMA: 041 9# 9 => 041 __ k
1473
+ all_tags('041__', 'k') { |t|
1474
+ xml['dc'].language repeat(t.a_k.collect { |y| taalcode(y) })
1277
1475
  }
1278
1476
  end
1279
1477
 
@@ -1299,8 +1497,12 @@ module Libis
1299
1497
 
1300
1498
  def marc2dc_language_041__9_9(xml)
1301
1499
  # "Ondertitels: " [MARC 041 _9 $9*]
1302
- all_tags('041_9', '9') { |t|
1303
- xml['dc'].language element(t.a_9.collect { |y| taalcode(y) }, prefix: 'Ondertitels:')
1500
+ # all_tags('041_9', '9') { |t|
1501
+ # xml['dc'].language element(t.a_9.collect { |y| taalcode(y) }, prefix: 'Ondertitels:')
1502
+ # }
1503
+ # ALMA: 041 #9 9 => 041 __ j
1504
+ all_tags('041__', 'j') { |t|
1505
+ xml['dc'].language element(t.a_j.collect { |y| taalcode(y) }, prefix: 'Ondertitels:')
1304
1506
  }
1305
1507
  end
1306
1508
 
@@ -1325,11 +1527,13 @@ module Libis
1325
1527
  # [MARC 546 __ $a]
1326
1528
  each_field('546__', 'a') { |f| xml['dc'].language f }
1327
1529
 
1328
- # []MARC 546 9_ $a]
1329
- each_field('5469_', 'a') { |f| xml['dc'].language f }
1530
+ # [MARC 546 9_ $a]
1531
+ # ALMA: 546 9_ a => 546 __ a
1532
+ # each_field('5469_', 'a') { |f| xml['dc'].language f }
1330
1533
 
1331
1534
  # [MARC 546 _9 $a]
1332
- each_field('546_9', 'a') { |f| xml['dc'].language f }
1535
+ # ALMA: 546 _9 a => 546 __ a
1536
+ # each_field('546_9', 'a') { |f| xml['dc'].language f }
1333
1537
  end
1334
1538
 
1335
1539
  def marc2dc_rightsholder(xml)
@@ -1351,9 +1555,9 @@ module Libis
1351
1555
  all_tags('7102_', '4') { |t|
1352
1556
  next unless check_name(t, :rightsholder)
1353
1557
  xml['dcterms'].rightsholder element(list_s(t._a,
1354
- opt_r(t._g)),
1558
+ opt_r(t._g)),
1355
1559
  list_s(opt_r(t._9),
1356
- opt_r(t._e)),
1560
+ opt_r(t._e)),
1357
1561
  join: ', ')
1358
1562
  }
1359
1563
  end
@@ -1428,7 +1632,7 @@ module Libis
1428
1632
  end
1429
1633
 
1430
1634
  def lookup(table, key, constraints = {})
1431
- table.select { |value| constraints.map { |k,v| value[k] == v }.all? }.map { |v| v[key] }
1635
+ table.select { |value| constraints.map { |k, v| value[k] == v }.all? }.map { |v| v[key] }
1432
1636
  end
1433
1637
 
1434
1638
  #noinspection RubyStringKeysInHashInspection
@@ -1439,7 +1643,7 @@ module Libis
1439
1643
  arc: ['architect', :contributor],
1440
1644
  arr: ['arranger', :contributor],
1441
1645
  art: ['artist', :creator],
1442
- aui: ['author of introduction', :contributor ],
1646
+ aui: ['author of introduction', :contributor],
1443
1647
  aut: ['author', :creator],
1444
1648
  bbl: ['bibliography', :contributor],
1445
1649
  bdd: ['binder', :contributor],
@@ -14,27 +14,30 @@ module Libis
14
14
 
15
15
  # This class supports creating METS files in a friendlier way than by creating an XML file.
16
16
  #
17
- # There are sub-classes that represent {Representation}s, {File}s, {Div}isions and {Map}s.
17
+ # There are sub-classes that represent {::Libis::Tools::MetsFile::Representation}s,
18
+ # {::Libis::Tools::MetsFile::File}s, {::Libis::Tools::MetsFile::Div}isions and {::Libis::Tools::MetsFile::Map}s.
18
19
  # These are simple container classes that take care of assigning proper ids and accept most known attributes.
19
20
  # Each of the container classes have a corresponding method on the METS class that takes a Hash with attributes
20
21
  # and returns the created object.
21
22
  #
22
- # {Div} and {File} instances can be added to a {Div} instance and a Div can be associated with a {Representation},
23
- # thus creating a structmap.
23
+ # {::Libis::Tools::MetsFile::Div} and {::Libis::Tools::MetsFile::File} instances can be added to a
24
+ # {::Libis::Tools::MetsFile::Div} instance and a Div can be associated with a
25
+ # {::Libis::Tools::MetsFile::Representation}, thus creating a structmap.
24
26
  #
25
27
  # The {#amd_info=} method on the {MetsFile} class sets the main amd parameters and
26
28
  #
27
29
  # With the help of the {DnxSection} class and it's derived classes, the container classes can generate the amd
28
30
  # sections for the METS file.
29
31
  class MetsFile
32
+ include ::Libis::Tools::ThreadSafe
30
33
 
31
- # Keeps track of {Representation}s created
34
+ # Keeps track of {::Libis::Tools::MetsFile::Representation}s created
32
35
  attr_reader :representations
33
- # Keeps track of {File}s created
36
+ # Keeps track of {::Libis::Tools::MetsFile::File}s created
34
37
  attr_reader :files
35
- # Keeps track of {Div}s created
38
+ # Keeps track of {::Libis::Tools::MetsFile::Div}s created
36
39
  attr_reader :divs
37
- # Keeps track of {Map}s created
40
+ # Keeps track of {::Libis::Tools::MetsFile::Map}s created
38
41
  attr_reader :maps
39
42
 
40
43
  # noinspection RubyConstantNamingConvention
@@ -55,11 +58,13 @@ module Libis
55
58
  @maps = {}
56
59
  @dnx = {}
57
60
  @dc_record = nil
61
+ @id_map = {}
58
62
  end
59
63
 
60
64
  # Reads an existing METS XML file and parses into a large Hash structure for inspection.
65
+ #
61
66
  # It will not immediately allow you to create a {MetsFile} instance from it, but with some inspection and
62
- # knowledge of METS file structure it should be possible to recreate a similar file using the class.
67
+ # knowledge of METS file structure it should be possible to recreate a similar file using the result.
63
68
  #
64
69
  # The returned Hash has the following structure:
65
70
  #
@@ -233,11 +238,23 @@ module Libis
233
238
  end
234
239
  end
235
240
 
236
- # Create a new representation. See {Representation} for supported Hash keys.
241
+ def get_id(klass)
242
+ self.mutex.synchronize do
243
+ if @id_map[klass]
244
+ @id_map[klass] += 1
245
+ else
246
+ @id_map[klass] = 1
247
+ end
248
+ return @id_map[klass]
249
+ end
250
+ end
251
+
252
+ # Create a new representation. See {::Libis::Tools::MetsFile::Representation} for supported Hash keys.
237
253
  # @param [Hash] hash
238
254
  # @return [Libis::Tools::MetsFile::Representation]
239
255
  def representation(hash = {})
240
- rep = Representation.new
256
+ rep = ::Libis::Tools::MetsFile::Representation.new
257
+ rep.set_id = get_id(::Libis::Tools::MetsFile::Representation)
241
258
  rep.set_from_hash hash
242
259
  @representations[rep.id] = rep
243
260
  end
@@ -247,6 +264,7 @@ module Libis
247
264
  # @return [Libis::Tools::MetsFile::Div]
248
265
  def div(hash = {})
249
266
  div = Libis::Tools::MetsFile::Div.new
267
+ div.set_id = get_id(::Libis::Tools::MetsFile::Div)
250
268
  div.set_from_hash hash
251
269
  @divs[div.id] = div
252
270
  end
@@ -256,6 +274,7 @@ module Libis
256
274
  # @return [Libis::Tools::MetsFile::File]
257
275
  def file(hash = {})
258
276
  file = Libis::Tools::MetsFile::File.new
277
+ file.set_id = get_id(::Libis::Tools::MetsFile::File)
259
278
  file.set_from_hash hash
260
279
  @files[file.id] = file
261
280
  end
@@ -263,11 +282,14 @@ module Libis
263
282
  # Create a new structmap.
264
283
  # @param [Libis::Tools::MetsFile::Representation] rep
265
284
  # @param [Libis::Tools::MetsFile::Div] div
285
+ # @param [Boolean] logical if true, create a logical structmap; if false (default): a physical structmap.
266
286
  # @return [Libis::Tools::MetsFile::Map]
267
- def map(rep, div)
287
+ def map(rep, div, logical = false)
268
288
  map = Libis::Tools::MetsFile::Map.new
289
+ map.set_id = get_id(::Libis::Tools::MetsFile::Map)
269
290
  map.representation = rep
270
291
  map.div = div
292
+ map.is_logical = logical
271
293
  @maps[map.id] = map
272
294
  end
273
295
 
@@ -379,7 +401,7 @@ module Libis
379
401
  @maps.values.each do |map|
380
402
  xml[:mets].structMap(
381
403
  ID: "#{map.representation.xml_id}-1",
382
- TYPE: 'PHYSICAL',
404
+ TYPE: (map.is_logical ? 'LOGICAL' : 'PHYSICAL'),
383
405
  ) {
384
406
  xml[:mets].div(LABEL: map.representation.label) {
385
407
  add_struct_map(xml, map.div) if map.div
@@ -4,29 +4,22 @@ module Libis
4
4
  class MetsFile
5
5
 
6
6
  # Generic module that provides code shortcuts for the {Representation}, {Div} and {File} classes.
7
- module IdContainer
8
- def self.included(klass)
9
- klass.include ::Libis::Tools::ThreadSafe
10
- end
7
+ module MetsObject
11
8
 
12
9
  # Take a hash and set class instance attributes.
13
- #
14
- #
15
10
  # @param [Hash] hash Hash with <attribute_name>, <attribute_value> pairs.
16
11
  def set_from_hash(hash)
17
12
  hash.each { |key, value| send "#{key}=", value if respond_to?(key) }
18
13
  end
19
14
 
20
- # Assigns a unique id to a class instance.
21
- #
22
- # A class variable is used to keep track of the id sequence and is incremented as needed. Thread-safe operation.
23
- def id
24
- return @id if @id
25
- self.mutex.synchronize do
26
- @id = self.class.instance_variable_get('@id') || 1
27
- self.class.instance_variable_set('@id', @id + 1)
28
- @id
29
- end
15
+ # Default initializer
16
+ def initialize
17
+ @id = 0
18
+ end
19
+
20
+ # Sets the unique id for the instance
21
+ def set_id(id)
22
+ @id = id
30
23
  end
31
24
 
32
25
  # Convert structure to String. Can be used for debugging to show what is stored.
@@ -34,9 +27,9 @@ module Libis
34
27
  "#{self.class}:\n" +
35
28
  self.instance_variables.map do |var|
36
29
  v = self.instance_variable_get(var)
37
- v = "#{v.class}-#{v.id}" if v.is_a? IdContainer
30
+ v = "#{v.class}-#{v.id}" if v.is_a? MetsObject
38
31
  v = v.map do |x|
39
- x.is_a?(IdContainer) ? "#{x.class}-#{x.id}" : x.to_s
32
+ x.is_a?(MetsObject) ? "#{x.class}-#{x.id}" : x.to_s
40
33
  end.join(',') if v.is_a? Array
41
34
  " - #{var.to_s.gsub(/^@/, '')}: #{v}"
42
35
  end.join("\n")
@@ -46,7 +39,7 @@ module Libis
46
39
 
47
40
  # Container class for creating a representation in the METS.
48
41
  class Representation
49
- include IdContainer
42
+ include MetsObject
50
43
 
51
44
  # The currently allowed attributes on this class. The attributes will typically be used in {DnxSection}s.
52
45
  attr_accessor :label, :preservation_type, :usage_type, :representation_code, :entity_type, :access_right_id,
@@ -59,7 +52,7 @@ module Libis
59
52
 
60
53
  # The id that will be used in the XML file to reference this representation.
61
54
  def xml_id
62
- "rep#{id}"
55
+ "rep#{@id}"
63
56
  end
64
57
 
65
58
  # This method creates the appropriate {DnxSection}s based on what attributes are filled in.
@@ -228,7 +221,7 @@ module Libis
228
221
 
229
222
  # Container class for creating a file in the METS.
230
223
  class File
231
- include IdContainer
224
+ include MetsObject
232
225
 
233
226
  # The currently allowed attributes on this class. The attributes will typically be used in {DnxSection}s.
234
227
  attr_accessor :label, :note, :location, :target_location, :mimetype, :puid, :size, :entity_type,
@@ -241,12 +234,12 @@ module Libis
241
234
 
242
235
  # The id that will be used in the XML file to reference this file.
243
236
  def xml_id
244
- "fid#{id}"
237
+ "fid#{@id}"
245
238
  end
246
239
 
247
240
  # The id that will be used for the group in the XML file.
248
241
  def make_group_id
249
- "grp#{group_id rescue id}"
242
+ "grp#{group_id rescue @id}"
250
243
  end
251
244
 
252
245
  # The file's name as it was originally.
@@ -471,13 +464,13 @@ module Libis
471
464
 
472
465
  # Container class for creating a division in the METS.
473
466
  class Div
474
- include IdContainer
467
+ include MetsObject
475
468
 
476
469
  attr_accessor :label
477
470
 
478
471
  # The id that will be used in the XML file to reference this division.
479
472
  def xml_id
480
- "div-#{id}"
473
+ "div-#{@id}"
481
474
  end
482
475
 
483
476
  # All items stored in the current division
@@ -517,16 +510,18 @@ module Libis
517
510
 
518
511
  # Container class for creating a structmap in the METS.
519
512
  class Map
520
- include IdContainer
513
+ include MetsObject
521
514
 
522
515
  # The representation this structmap is for
523
516
  attr_accessor :representation
524
517
  # The top division in the structmap
525
518
  attr_accessor :div
519
+ # Is the structmap Logical (true) or Physical(false)?
520
+ attr_accessor :is_logical
526
521
 
527
522
  # The id that will be used in the XML file to reference this structmap.
528
523
  def xml_id
529
- "smap-#{id}"
524
+ "smap-#{@id}"
530
525
  end
531
526
 
532
527
  end
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Tools
3
- VERSION = '0.9.25'
3
+ VERSION = '0.9.27'
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@
3
3
  xmlns="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
4
  <leader>01068nam 2200241u 4500</leader>
5
5
  <controlfield tag="005">20150701153710.0</controlfield>
6
- <controlfield tag="008">000608m17221724xx |||| | 000|0 lat c</controlfield>
6
+ <controlfield tag="008">000608m17221724xx |||| | 000|0 lat c</controlfield>
7
7
  <controlfield tag="001">9921543960101471</controlfield>
8
8
  <datafield tag="035" ind1=" " ind2=" ">
9
9
  <subfield code="a">(BeLVLBS)002154396LBS01-Aleph</subfield>
@@ -19,7 +19,7 @@ describe 'Marc21Record' do
19
19
  expect(record.marc_dump).to eq <<-STR.align_left
20
20
  LDR:'01068nam 2200241u 4500'
21
21
  005:'20150701153710.0'
22
- 008:'000608m17221724xx |||| | 000|0 lat c'
22
+ 008:'000608m17221724xx |||| | 000|0 lat c'
23
23
  001:'9921543960101471'
24
24
  035: : :
25
25
  \ta:["(BeLVLBS)002154396LBS01-Aleph"]
@@ -99,10 +99,13 @@ describe 'Marc21Record' do
99
99
  <dc:identifier>8389207</dc:identifier>
100
100
  <dc:title>Anecdota Graeca, sacra et profana /</dc:title>
101
101
  <dc:creator>Wolf, Johann Christoph, 1683-1739, (author)</dc:creator>
102
+ <dc:subject xsi:type="http://purl.org/dc/terms/UDC" class="text">Griekse patrologie</dc:subject>
103
+ <dc:temporal>1701-1750</dc:temporal>
102
104
  <dc:description>Ded. Petrus Theodorus Seelmann; Erdmannus Neumeister; Thomas Claussen; Joannes Grammius\n \nElk deel heeft eigen titelp. in roodzwartdruk, met drukkersmerk</dc:description>
103
105
  <dc:date>1722 - 1724</dc:date>
106
+ <dc:type xml:lang="en" class="text">Books before 1840</dc:type>
104
107
  <dcterms:extent>8o: 4 v.; [22], 298, [8]; [16], 354, [1]; [16], 299, [7]; [16], 271, [5] p.</dcterms:extent>
105
- <dc:language/>
108
+ <dc:language>la</dc:language>
106
109
  </dc:record>
107
110
  STR
108
111
  expect(record.to_dc.root).to be_equivalent_to(xml_doc.root).respecting_element_order
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.25
4
+ version: 0.9.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-11 00:00:00.000000000 Z
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler