-
Notifications
You must be signed in to change notification settings - Fork 1
/
da_fetch_mapping.fix
677 lines (614 loc) · 18.2 KB
/
da_fetch_mapping.fix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
# Conversion rules for CBS2DigitalesArchiv
# @author: Felix Hemme, Luisa Kramer
# @version: 2022-09-05 v3.0.2
# Accept variable
add_field('target','{{target}}')
add_field('isil','{{isil}}')
# Add download method and default to selen
add_field('download_method','selen')
if all_match('target','owc-de-206')
# For PPN from owc-de-206
marc_map('001','identifier\.ppn')
elsif all_match('target','k10plus')
# For PPN from K10plus
marc_map('001','identifier\.ppn')
elsif all_match('target','ebooks')
# For PPN from E-Book-Pool
marc_map('001','identifier\.ppn')
prepend('identifier\.ppn','EBP')
elsif all_match('target','nl-monographien')
# For PPN from NL-Mono-Pool
marc_map('001','identifier\.ppn')
prepend('identifier\.ppn','NLM')
elsif all_match('target','nl-zeitschriften')
# For PPN from NL-ZS-Pool
marc_map('001','identifier\.ppn')
prepend('identifier\.ppn','NLZ')
end
# Type "Article" (article from journal)
# 002@ Pos.2 = "s"
do marc_each()
if marc_match('7737|||s','s')
set_field('type','b')
# No 773 $7 for target nl-zeitschriften
# Check on LDR/07 bibliographic level
elsif all_match('target','nl-zeitschriften')
if marc_match('LDR/7','b')
set_field('type','b')
end
end
end
# Type "Book Part" (article from monograph)
# 002@ Pos.2 = "s"
do marc_each()
if marc_match('7737|||m','m')
set_field('type','bp')
# No 773 $7 for target ebooks and nl-monographien
# Check on LDR/07 bibliographic level
elsif all_match('target','ebooks')
if marc_match('LDR/7','a')
set_field('type','bp')
end
elsif all_match('target','nl-monographien')
if marc_match('LDR/7','a')
set_field('type','bp')
end
end
end
# Type "Book"
# 002@ Pos.2 = "a" if 013D $8 not one of
# [Konferenzschrift || Bericht || Forschungsbericht || Hochschulschrift]
do marc_each()
if marc_match('LDR/7','m')
unless marc_any_match('655[,7]a','Konferenzschrift')
marc_map('LDR/7','type')
end
unless marc_any_match('655[,7]a','Bericht')
marc_map('LDR/7','type')
end
unless marc_any_match('655[,7]a','Forschungsbericht')
marc_map('LDR/7','type')
end
unless marc_any_match('655[,7]a','Hochschulschrift')
marc_map('LDR/7','type')
end
end
end
# Type "Periodical Part"
# 002@ Pos.2 = "v"
do marc_each()
if marc_match('LDR/19','c')
marc_map('LDR/19','type')
end
end
# Type "Conference Paper"
do marc_each()
if marc_any_match('655[,7]a','Konferenzschrift')
set_field('type','cp')
end
end
# Type "Proceedings"
do marc_each()
if marc_any_match('655[,7]a','Bericht')
set_field('type','p')
end
end
# Type "Research Report"
do marc_each()
if marc_any_match('655[,7]a','Forschungsbericht')
set_field('type','rr')
end
end
# Type "Thesis"
do marc_each()
if marc_any_match('655[,7]a','Hochschulschrift')
set_field('type','t')
end
end
# Date of publication
marc_map('008/07-10','date\.issued')
# ISSN
# if LDR 07 = m then map from 810/830 $x
# elsif 773 $7 = |||s then map from 773[08]x
# Multiple ISSN are separated from each other with "|"
if marc_any_match('LDR/7','m')
if marc_has('810')
marc_map('810x','relation\.issn', join:'|')
elsif marc_has('830')
marc_map('810x','relation\.issn', join:'|')
end
elsif marc_match('7737|||s','s')
marc_map('773[08]x','relation\.issn', join:'|')
end
# ISBN
# Multiple ISBN are separated from each other with "|"
#do marc each()
if marc_has('020')
marc_map('020a','identifier\.isbn', join:'|')
elsif marc_has('773')
marc_map('773[08]z','identifier\.isbn', join:'|')
end
# DOI, URN, Handle are contained in one combined column
# Multiple DOI, URN, Handle are separated from each other with "|"
# Known issue: Prefixes can't be created (2022-08-03)
do marc_each()
if marc_match('024[7]2','doi')
marc_map('024[7]a','identifier\.pi.$append')
elsif marc_match('024[7]2','hdl')
marc_map('024[7]a','identifier\.pi.$append')
elsif marc_match('024[7]2','urn')
marc_map('024[7]a','identifier\.pi.$append')
end
end
join_field('identifier\.pi','|')
# Citation/source for journal articles
do marc_each()
marc_map('952d','econstor\.citation\.volume')
#marc_map('952j','econstor\.citation\.year')
marc_map('952e','econstor\.citation\.issue')
marc_map('952h','econstor\.citation\.startpage')
replace_all('econstor\.citation\.startpage','(^[\d]{1,})(-)([\d]{1,}$)','$1')
marc_map('952h','econstor\.citation\.endpage')
replace_all('econstor\.citation\.endpage','(^[\d]{1,})(-)([\d]{1,}$)','$3')
marc_map('952i','econstor\.citation\.articlenumber')
end
# Languages
# Multiple languages are separated from each other with "|"
marc_map('041a','language\.iso', join:'|')
# If the number in 084 is a JEL code, it is mapped into column "subject.jel"
# Multiple JEL are separated from each other with "|"
if marc_match('0842','(?i)jelc')
marc_map('084a','subject\.jel', join:'|')
end
# Check on relationship designators for field 100 and 700, distinction between author, editor, other
# 100 $4 = aut -> contributor.author
# 700 $4 = aut -> contributor.author
if marc_match('1004','aut')
marc_map('100a','contributor\.author.$append')
end
do marc_each()
if marc_match('7004','aut')
marc_map('700a','contributor\.author.$append')
end
end
join_field('contributor\.author','|')
# 700 $4 = edt -> contributor.editor
do marc_each()
if marc_match('7004','edt')
marc_map('700a','contributor\.editor.$append')
end
end
join_field('contributor\.editor','|')
# All other relationship designators map to contributor.other
do marc_each()
unless marc_match('7004','(edt|aut)')
marc_map('700a','contributor\.other.$append')
end
unless marc_match('1004','aut')
marc_map('100a','contributor\.other.$append')
end
end
join_field('contributor\.other','|')
# Title
marc_map('245ab','title',join:' : ')
# Number/name of part of a work
marc_map('245np','part',join:' ; ')
# Variant title
marc_map('246[1]a','title\.alternative')
# Place of publication and publisher with delimiter " : "
# If independent publication
marc_map('264ab','publisher', join:' : ')
# If book article (type = book part)
if all_match('type','bp')
marc_map('773[08]d','publisher')
replace_all('publisher',',?\s?[0-9]{4}$','')
end
# Edition
# If independent publication
marc_map('250a','description\.version')
# If book article (type = book part)
if all_match('type','bp')
marc_map('773[08]b','description\.version')
end
# Series name
marc_map('490a','relation\.ispartofseries',join:'. ')
#do marc_each()
# marc_map('490a','relation\.ispartofseries.$append')
#end
join_field('relation\.ispartofseries','|')
# Abstract
do marc_each()
marc_map('520a','description\.abstract')
end
join_field('description\.abstract','|')
#######################################
#773 cases
#######################################
# 773 BOOK cases
# Book name (Book Parts)
do marc_each()
if all_match('type','bp')
marc_map('773t','relation\.ispartofbook',join:'|')
end
end
# Book name (Books)
do marc_each()
if marc_match('7737|||m','m')
marc_map('773t','relation\.ispartofbook',join:'|')
end
end
# Book PPN
if all_match('target','owc-de-206')
if marc_any_match('7737|||m','m')
marc_map('773w',tmp,split:1)
end
end
do list(path:tmp,var:c)
if all_match(c,'^\(DE-627\).*')
replace_all(c,'^\([^\)]+\)(.*)$','$1')
copy_field(c,'relation\.bookppn.$append')
end
end
join_field('relation\.bookppn','|')
remove_field(tmp)
# 773 JOURNAL cases
# Journal name
do marc_each()
if marc_match('7737|||s','s')
marc_map('773t','relation\.ispartofjournal',join:'|')
elsif any_match('type','^c$')
marc_map('245ap','relation\.ispartofjournal',join:'. ')
end
end
# Journal ZDB PPN and ZDB ID
do marc_each()
#if marc_has('773w')
if marc_any_match('7737|||s','s')
marc_map('773w',tmp,split:1)
end
end
do list(path:tmp,var:c)
# ZDB PPN (only for target owc-de-206 and nl-zeitschriften)
if all_match(c,'^\(DE-627\).*')
if all_match('target','owc-de-206')
replace_all(c,'^\([^\)]+\)(.*)$','$1')
copy_field(c,'relation\.journalppn.$append')
elsif all_match('target','nl-zeitschriften')
replace_all(c,'^\([^\)]+\)(.*)$','$1')
prepend('c','NLZ')
copy_field(c,'relation\.journalppn.$append')
end
end
# ZDB ID (for all targets)
if all_match(c,'^\(DE-600\).*')
replace_all(c,'^\([^\)]+\)(.*)$','$1')
copy_field(c,'relation\.journalzdbid.$append')
end
end
join_field('relation\.journalppn','|')
join_field('relation\.journalzdbid','|')
remove_field(tmp)
#######################################
# 8XX cases
#######################################
# 810
do marc_each()
if marc_has('810w')
marc_map('810w',tmp,split:1)
end
end
do list(path:tmp,var:c)
# PPN for series
if all_match(c,'^\(DE-627\).*')
replace_all(c,'^\([^\)]+\)(.*)$','$1')
copy_field(c,'relation\.seriesppn.$append')
end
# ZDB ID for series
if all_match(c,'^\(DE-600\).*')
replace_all(c,'^\([^\)]+\)(.*)$','$1')
copy_field(c,'relation\.serieszdbid.$append')
end
end
join_field('relation\.seriesppn','|')
join_field('relation\.serieszdbid','|')
remove_field(tmp)
# 830
do marc_each()
if marc_has('830w')
marc_map('830w',tmp,split:1)
end
end
do list(path:tmp,var:c)
# PPN for series
if all_match(c,'^\(DE-627\).*')
replace_all(c,'^\([^\)]+\)(.*)$','$1')
copy_field(c,'relation\.seriesppn.$append')
end
# ZDB ID for series
if all_match(c,'^\(DE-600\).*')
replace_all(c,'^\([^\)]+\)(.*)$','$1')
copy_field(c,'relation\.serieszdbid.$append')
end
end
join_field('relation\.seriesppn','|')
join_field('relation\.serieszdbid','|')
remove_field(tmp)
# Map callnumbers to Lax record PPNs
do marc_each()
if marc_any_match('980d','ZSM 1')
set_field('collection_handle','11159/536')
end
end
do marc_each()
if marc_any_match('980d','ZSM 3')
set_field('collection_handle','11159/2270')
end
end
do marc_each()
if marc_any_match('980d','ZSM 4')
set_field('collection_handle','11159/2926')
end
end
do marc_each()
if marc_any_match('980d','ZSM 6')
set_field('collection_handle','11159/4684')
end
end
do marc_each()
if marc_any_match('980d','ZSM 7')
set_field('collection_handle','11159/4739')
end
end
do marc_each()
if marc_any_match('980d','ZSM 8')
set_field('collection_handle','11159/2551')
end
end
do marc_each()
if marc_any_match('980d','ZSM 9')
set_field('collection_handle','11159/3309')
end
end
do marc_each()
if marc_any_match('980d','ZSM 10')
set_field('collection_handle','11159/2308')
end
end
do marc_each()
if marc_any_match('980d','ZSM 11')
set_field('collection_handle','11159/1678')
end
end
do marc_each()
if marc_any_match('980d','ZSM 12')
set_field('collection_handle','11159/1103')
end
end
do marc_each()
if marc_any_match('980d','ZSM 13')
set_field('collection_handle','11159/1663')
end
end
do marc_each()
if marc_any_match('980d','ZSM 14')
set_field('collection_handle','11159/2275')
end
end
do marc_each()
if marc_any_match('980d','ZSM 15')
set_field('collection_handle','11159/1045')
end
end
do marc_each()
if marc_any_match('980d','ZSM 16')
set_field('collection_handle','11159/1047')
end
end
do marc_each()
if marc_any_match('980d','ZSM 17')
set_field('collection_handle','11159/2290')
end
end
do marc_each()
if marc_any_match('980d','ZSM 18')
set_field('collection_handle','11159/141')
end
end
do marc_each()
if marc_any_match('980d','ZSM 19')
set_field('collection_handle','11159/3440')
end
end
do marc_each()
if marc_any_match('980d','ZSM 20')
set_field('collection_handle','11159/2890')
end
end
do marc_each()
if marc_any_match('980d','ZSM 21')
set_field('collection_handle','11159/2918')
end
end
do marc_each()
if marc_any_match('980d','ZSM 22')
set_field('collection_handle','11159/5383')
end
end
do marc_each()
if marc_any_match('980d','ZSM 23')
set_field('collection_handle','11159/12240')
end
end
do marc_each()
if marc_any_match('980d','ZSM 24')
set_field('collection_handle','11159/654471')
end
end
# Everything with 8600 DA:oas
do marc_each()
if marc_any_match('980h','DA:oas')
set_field('collection_handle','11159/18')
end
end
# Everything with 8600 DA:ras
do marc_each()
if marc_any_match('980h','DA:ras')
set_field('collection_handle','11159/17')
end
end
# Everything with 8600 DA:cas
do marc_each()
if marc_any_match('980h','DA:cas')
set_field('collection_handle','11159/9034')
end
end
# License statement from 540 is written into column "rights.license"
do marc_each()
marc_map('540u','rights\.license')
end
# A hardcoded base license statement is written into column "rights"
# 2022-09-09: The field is populated by the ingest script, no
# need to have it written to the CSV file
# set_field('rights','https://zbw.eu/econis-archiv/termsofuse')
# Dependent on ISIL a value is written into
# "collection_handle",
# the ISIL is extracted and written into "identifier.packageid",
# and sometimes a fixed value written into "type"
if all_match('isil','zdb-33')
# If ISIL = zdb-33
marc_map('912ab','identifier\.packageid.$append')
join_field('identifier\.packageid','|')
replace_all('identifier\.packageid','(ZDB-[\d]{1,4}-[A-Za-z]{1,})([\d]{4})','$1 \($2\)')
set_field('collection_handle','11159/6527')
set_field('type','wp')
elsif all_match('isil','zdb-1-eem')
# If ISIL = zdb-1-eem
marc_map('912ab','identifier\.packageid.$append')
join_field('identifier\.packageid','|')
replace_all('identifier\.packageid','(ZDB-[\d]{1,4}-[A-Za-z]{1,})([\d]{4})','$1 \($2\)')
# set_field('identifier\.packageid','')
set_field('collection_handle','11159/8695')
elsif all_match('isil','zdb-30-pdt')
marc_map('912ab','identifier\.packageid.$append')
join_field('identifier\.packageid','|')
replace_all('identifier\.packageid','(ZDB-[\d]{1,4}-[A-Za-z]{1,})([\d]{4})','$1 \($2\)')
# set_field('identifier\.packageid','')
set_field('collection_handle','11159/12451')
set_field('type','t')
elsif all_match('isil','zdb-1-wba')
# If ISIL = zdb-1-wba
marc_map('912ab','identifier\.packageid.$append')
join_field('identifier\.packageid','|')
replace_all('identifier\.packageid','(ZDB-[\d]{1,4}-[A-Za-z]{1,})([\d]{4})','$1 \($2\)')
# set_field('identifier\.packageid','')
set_field('collection_handle','11159/632042')
elsif all_match('isil','zdb-1-bmen')
# If ISIL = zdb-1-bmen
marc_map('912ab','identifier\.packageid.$append')
join_field('identifier\.packageid','|')
replace_all('identifier\.packageid','(ZDB-[\d]{1,4}-[A-Za-z]{1,})([\d]{4})','$1 \($2\)')
# set_field('identifier\.packageid','')
set_field('collection_handle','11159/654928')
elsif any_match('isil','zdb-23-gbe')
# If ISIL = zdb-23-gbe
marc_map('912ab','identifier\.packageid.$append')
join_field('identifier\.packageid','|')
replace_all('identifier\.packageid','(ZDB-\d+-[A-Za-z]+)(\d{4}(?:-\d{4})?)','$1 ($2)')
replace_all('identifier\.packageid', '\((\d{4})\)', '($1)')
# set_field('identifier\.packageid','')
set_field('collection_handle','11159/654929')
elsif all_match('isil','zbw-1-dgw')
# If ISIL = zbw-1-dgw
set_field('identifier\.packageid','ZBW-1-DGW')
set_field('collection_handle','11159/654929')
elsif all_match('isil','zbw-1-dgl')
# If ISIL = zbw-1-dgl
set_field('identifier\.packageid','ZBW-1-DGL')
set_field('collection_handle','11159/654929')
#elsif all_match('isil','???')
# PLACEHOLDER
# If ISIL =
# set_field('identifier\.packageid','')
end
# URL
marc_map('856[4,0]u','url',join: '|')
# Extract DOI from 856, transform and write into "identifier.pi"
do marc_each()
if marc_any_match('856[40]u','doi\.org.*')
# Apply substring of doi only
marc_replace_all('856[40]u','https?:\/\/(www\.)?doi\.org/','')
marc_map('856[40]u','identifier\.pi.$append')
end
end
join_field('identifier\.pi','|')
# Extract SSRN abstract ID from 856 and use it for value in "identifier"
# Extract SSRN abstract ID from 856 and use for value in "filepath"
if all_match('isil','zdb-33')
do marc_each()
if marc_any_match('856[40]m','X:ELVSSRN')
if marc_any_match('856[40]u','ssrn.com/abstract=.*')
marc_replace_all('856[40]u','https?:\/\/(www\.)?ssrn\.com\/abstract=','')
marc_map('856[40]u','identifier')
prepend('identifier','ELVSSRN:')
marc_map('856[40]u','filepath')
prepend('filepath','//zbw/metadaten/Work/SSRN/upload/data/pdfs/')
append('filepath','.pdf')
end
end
end
end
# Extract Edward Elgar ISBN from 020a and use for value in "filepath"
if all_match('isil','zdb-1-eem')
marc_map('020a','filepath')
prepend('filepath','//zbw/metadaten/Work/ZDB-1-EWE_und_ZDB-1-EEM/upload/')
append('filepath','.pdf')
end
# Extract Emerald DOI from 024a and use for value in "filepath"
if all_match('isil','zdb-1-bmen')
do marc_each()
if marc_match('024[7]2','doi')
marc_replace_all('024[7]a','10.1016\/|10.1108\/','')
marc_replace_all('024[7]a', '\(|\)', '_')
marc_replace_all('024[7]a', 'S', 's')
marc_map('024[7]a','filepath')
prepend('filepath','//zbw/metadaten/Work/ZDB-1-EPB_und_ZDB-1-BMEN/upload/')
append('filepath','.pdf')
end
end
end
# Extract De Gruyter (Standardpaket) DOI from 024a and use for value in "filepath"
if all_match('isil','zdb-23-gbe')
do marc_each()
if marc_match('024[7]2','doi')
marc_replace_all('024[7]a', '\/', '_')
marc_map('024[7]a','filepath')
prepend('filepath','//zbw/metadaten/Work/ZBW-1-DGW_und_ZDB-23-GBE/upload/')
append('filepath','.pdf')
end
end
end
# Extract De Gruyter (Individualpaket bis 2023) DOI from 024a and use for value in "filepath"
if all_match('isil','zdb-1-dgw')
do marc_each()
if marc_match('024[7]2','doi')
marc_replace_all('024[7]a', '\/', '_')
marc_map('024[7]a','filepath')
prepend('filepath','//zbw/metadaten/Work/ZBW-1-DGW_und_ZDB-23-GBE/upload/')
append('filepath','.pdf')
end
end
end
# Extract De Gruyter (Individualpaket ab 2024) DOI from 024a and use for value in "filepath"
if all_match('isil','zdb-1-dgl')
do marc_each()
set_field('filepath','identifier\.pi')
prepend('filepath','//zbw/metadaten/Work/ZBW-1-DGW_und_ZDB-23-GBE/upload/')
append('filepath','.pdf')
end
end
# DDC and keywords were to be included in the schema, but subsequently it was decided,
# not to fill the fields. Therefore they are created empty as placeholders.
set_field('subject\.ddc','')
set_field('subject\.keyword','')
remove_field('_id')
remove_field('record')