-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdatahub-oai-to-iiif-blacklight-solr-nl.fix
1119 lines (869 loc) · 37 KB
/
datahub-oai-to-iiif-blacklight-solr-nl.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
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Catmandu Fix script
#
# Convert data from the VKC Datahub to the VKC Arthub.
#
# This Fix script will take LIDO XML records as an input and transform
# them into JSON objects that can be uploaded into an Apache Solr store.
#
# The Solr schema has been optimised for Project Blacklight (http://projectblacklight.org).
# The JSON objects should conform to the schema.
#
# See: https://github.com/VlaamseKunstcollectie/Arthub-Frontend/tree/master/jetty/solr
#
# Usage:
#
# $ catmandu convert OAI --url "http://endpoint/oai/" --metadataPrefix oai_lido
# --handler lido to JSON --pretty 1 --fix datahub-oai-to-blacklight-solr.fix > out.json
#
# In order to import data into the Solr core, create a pipeline and use the Datahub::Factory:
#
# see:
#
# arthub.ini:
#
# [Indexer]
# plugin = Solr
#
# [plugin_indexer_Solr]
# file_name = '/tmp/bulk.json'
# request_handler = 'http://datahub.box:8983/solr/blacklight-core/update/json'
#
# Usage:
#
# $ catmandu convert OAI --url http://datahub.box/oai --handler lido
# to JSON --fix datahub-oai-to-blacklight-solr.fix > /tmp/bulk.json
# $ dhconveyor index -p ../pipelines/arthub.ini -v
### Mapping between LIDO elements and Solr fields
# Mapping
# --------------------------------------------------------------------------
# LIDO Solr
# id
# lido:lidoRecID
# type: purl data_pid
# lido:objectPublishedID work_pid
# lido:objectWorkType
# lido:term
# pref: preferred artwork_subtype_display
# pref: alternate artwork_subtype
# lido:classification
# type: object-category
# lido:term
# pref: preferred artwork_type_display
# pref: alternate artwork_type
# lido:titleSet
# pref: preferred title_display
# lido:workID
# type: object-number object_number
# lido:objectDescriptionSet description
# lido:objectMeasurementsSet
# lido:measurementsSet
# lido:extentMeasurements
# geheel dimensions
#
# creator
# lido:eventType
# lido:term
# production
# lido:eventActor
# lido:nameActorSet
# pref: preferred creator_display
# pref: alternate creator_index
# lido:roleActor creator_role
# lido:attributionQualifierActor
# lido:eventDate
# lido:displayDate production_date
# lido:periodName
# lido:term
# lang: nl period
# lido:termMaterialsTech
# type: material
# lido:term
# pref: preferred material_display
# pref: alternate material
# lido:objectRelationWrap
# lido:subject
# type: content-motif-general
# lido:subjectConcept
# lido:term
# pref: preferred artwork_category_display
# pref: alternate artwork_category
# lido:recordWrap
# lido:recordSource
# lido:legalBodyName repository
# lido:resourceWrap
# lido:resourceSet
# lido:resourceID representation_pid
# lido:resourceRepresentation
# lido:resourceSet
# lido:resourceID manifest_url
# lido:resourceType
# lido:term
# IIIF Manifest
# lido:resourceSet
# lido:resourceID thumbnail_url
# lido:resourceType
# lido:term
# thumbnail
#
# publish_image
## DescriptiveMetadata
# Copy field to filter on language
do list(path:_metadata.descriptiveMetadata, var:dm)
if all_match('dm.lang', 'nl')
copy_field('dm', 'filteredDescriptiveMetadata')
end
end
## AdministrativeMetadata
# Copy field to filter on language
do list(path:_metadata.administrativeMetadata, var:am)
if all_match('am.lang', 'nl')
copy_field('am', 'filteredAdministrativeMetadata')
end
end
## Title
# Get preferred nl title from LIDO if exists
do list(path:filteredDescriptiveMetadata.objectIdentificationWrap.titleWrap.titleSet.0.appellationValue, var:el)
if all_match('el.pref', 'preferred')
if all_match('el.lang', 'nl')
if all_match('el._', '.*\S.*')
copy_field('el._', "title_display")
end
end
end
end
# If no preferred nl title exists, try to get any title from LIDO
unless all_match(title_display, '.*\S.*')
do list(path:filteredDescriptiveMetadata.objectIdentificationWrap.titleWrap.titleSet.0.appellationValue, var:el)
if all_match('el.pref', 'preferred')
if all_match('el._', '.*\S.*')
copy_field('el._', "title_display")
end
end
end
end
# If no preferred title exists, try to get any title from LIDO
unless all_match(title_display, '.*\S.*')
do list(path:filteredDescriptiveMetadata.objectIdentificationWrap.titleWrap.titleSet.0.appellationValue, var:el)
if all_match('el._', '.*\S.*')
copy_field('el._', "title_display")
end
end
end
# If no title exists, use n/a (not available)
unless all_match('title_display', '.*\S.*')
add_field('title_display', 'n/a')
end
## Creator
set_array(creator)
set_array(creator_dod)
set_array(creator_role)
set_array(creator_display)
set_array(creator_index)
# Use the event 'production'
unless is_array('filteredDescriptiveMetadata.eventWrap.eventSet')
move_field('filteredDescriptiveMetadata.eventWrap.eventSet', tmp)
set_array('filteredDescriptiveMetadata.eventWrap.eventSet')
move_field(tmp,'filteredDescriptiveMetadata.eventWrap.eventSet.$append')
end
do list(path:'filteredDescriptiveMetadata.eventWrap.eventSet', var:e)
do list(path:e.event.eventType.term, var:p)
if all_match(p._, 'production')
# Get the name of the creator from LIDO
do list(path:e.event.eventActor, var:c)
set_array(tmp_creator_display)
set_array(tmp_creator_index)
# Use the name as established by the museum for the detail page (preferred name)
# Use the alternate name in the search results if exists, else use the preferred name
# If no creator name exists, use n/a (not available)
do list(path:c.actorInRole.actor.nameActorSet.0.appellationValue, var:d)
if all_match('d.pref', 'preferred')
if all_match(d._, '.*\S.*')
copy_field(d._, tmp_creator_display.$append)
copy_field(d._, tmp_creator_index.$append)
else
add_field(creator_display_na, 'n/a')
copy_field(creator_display_na, tmp_creator_display.$append)
copy_field(creator_display_na, tmp_creator_index.$append)
remove_field(creator_display_na)
end
end
end
do list(path:c.actorInRole.actor.nameActorSet.0.appellationValue, var:d)
if all_match('d.pref', 'alternate')
if all_match(d._, '.*\S.*')
copy_field(d._, tmp_creator_index.$last)
end
end
end
# Add VIAF alternate names from CREATORS_UTF8.csv
# The original LIDO data doesn't contain those. It only contains the
# data sanctioned by the institutions, not the actual VIAF data itself.
copy_field(tmp_creator_display.$last, tmp_creator_concord)
downcase(tmp_creator_concord)
lookup_in_store(tmp_creator_concord, DBI, data_source: "dbi:SQLite:/tmp/import.CREATORS_UTF8.sqlite")
# We store the VIAF alternate names in creator search field.
# This allows users to search on name variants of the creator.
# If no VIAF alternate names are found, use n/a (not available)
if all_match(tmp_creator_concord.viaf_alternate, '.*\S.*')
copy_field(tmp_creator_concord.viaf_alternate, creator.$append)
else
add_field(tmp_creator, 'n/a')
copy_field(tmp_creator, creator.$append)
remove_field(tmp_creator)
end
remove_field(tmp_creator_concord)
# Add LIDO date of death of the creator
# If no date of death exists, use n/a (not available)
# We use the date of death later on to establish copyright.
# Thererfor we don't need the date of birth of the creator.
if all_match(c.actorInRole.actor.vitalDatesActor.latestDate._, '.*\S.*')
copy_field(c.actorInRole.actor.vitalDatesActor.latestDate._, creator_dod.$append)
else
add_field(tmp_creator_dod, 'n/a')
copy_field(tmp_creator_dod, creator_dod.$append)
remove_field(tmp_creator_dod)
end
# LIDO qualifier (copy after, attributed to ...)
if all_match('c.actorInRole.attributionQualifierActor.$last._', '.*\S.*')
if all_match('c.actorInRole.attributionQualifierActor.$last._', '.*\S.*')
# add the attribution to the creator_display and creator_index
copy_field(c.actorInRole.attributionQualifierActor.$last._, tmp_creator_display.$prepend)
copy_field(c.actorInRole.attributionQualifierActor.$last._, tmp_creator_index.$prepend)
# We use the date of death later on to establish copyright.
#
# In case the work is tentatively "attributed to" an artist, we don't take
# the date of death into account.
#
# Why? Because we can't reliable establish that the work was truly created
# by the attributed artist. i.e. The qualifier "copy after" implies
# that this work was created by someone else. "copy after Anthony van Dyck"
# might have us erroneously infer that the work was created by Anthony van Dyck
# while it may have actually been created in the 20th century.
#
# Instead we'll check the production date for these works.
set_field(check_production_date, 'true')
end
end
# Creator role (Publisher, Painter,...)
# If no creator role exists, use n/a (not available)
if all_match('c.actorInRole.roleActor.$last.term.$last._', '.*\S.*')
copy_field(c.actorInRole.roleActor.$last.term.$last._, creator_role.$append)
else
add_field(tmp_creator_role, 'n/a')
copy_field(tmp_creator_role, creator_role.$append)
remove_field(tmp_creator_role)
end
# Flatten creator_display & creator_index
join_field(tmp_creator_display, " ")
move_field(tmp_creator_display, creator_display.$append)
join_field(tmp_creator_index, " ")
move_field(tmp_creator_index, creator_index.$append)
end
end
end
end
# If the fields for creator are empty, use n/a (not available)
unless all_match(creator.$first, '.*\S.*')
set_field(creator.$first, 'n/a')
end
unless all_match(creator_dod.$first, '.*\S.*')
set_field(creator_dod.$first, 'n/a')
end
unless all_match(creator_role.$first, '.*\S.*')
set_field(creator_role.$first, 'n/a')
end
unless all_match(creator_display.$first, '.*\S.*')
set_field(creator_display.$first, 'n/a')
end
unless all_match(creator_index.$first, '.*\S.*')
set_field(creator_index.$first, 'n/a')
end
## Production date
set_array(production_date)
# Use the event 'production'
do list(path:'filteredDescriptiveMetadata.eventWrap.eventSet', var:e)
do list(path:e.event.eventType.term, var:p)
if all_match(p._, 'production')
# Get production date from LIDO
# If no production date exists, use n/a (not available)
do list(path:e.event.eventDate.displayDate, var:dat)
if all_match(dat._, '.*\S.*')
copy_field(dat._, production_date.$append)
else
add_field(tmp_production_date, 'n/a')
copy_field(tmp_production_date, production_date.$append)
remove_field(tmp_production_date)
end
end
end
end
end
# If the field for production date is empty, use n/a (not available)
unless all_match(production_date.$first, '.*\S.*')
set_field(production_date.$first, 'n/a')
end
## Publish image
# This algorithm establishes wether or not a digital representation
# may be published based on copyright rules.
#
# General rule: date of death artist < current date - 70 years
#
# We check if the LIDO date of death of the longest living contributor to the
# work is more than 70 years ago.
#
# In case the work is tentatively "attributed to" an artist, we check the
# production date, that is, the most recent asserted date instead.
#
# When asserting copyright via the production date of the work, we use
# this rule: production date < current date - 150 years.
#
# Assuming a max life expectancy of 90 years, we rule out all works
# created in the past 150 years (70 after presumable death + 80 years).
# This would rule out the edge case of a creator who died in his 90's, exactly
# 70 years ago and made his first known works in his teenage years.
#
# The algorithm is a two step process:
#
# 1. Clean up the date formatting of fields we're going to check against.
# They all need to be of the ISO format YYYY. This requires some regex fu.
# 2. Check against the dates according to the algorithm.
#
# This field is what ultimately determines whether an image can be published
# or not. The default assumption is 'false'. We need to prove that we are
# allowed to publish the digital image.
add_field(publish_image, "false")
# This is a 'sentinel' variable. As soon as the copyright has been
# determined (true), we bail out of the algorithm.
add_field(determined, "false")
# Step 1: Clean out the date formatting
set_field(production_date_copyright)
set_array(pretty_dod)
copy_field(filteredDescriptiveMetadata.eventWrap.eventSet.0.event.eventDate, dates)
if all_match(check_production_date, 'true')
if all_match(dates.date.latestDate._, '.*\S.*')
if any_match(dates.date.latestDate._, '(\d\d\d\d)-(\d\d)-(\d\d)')
parse_text(dates.date.latestDate._, '(\d\d\d\d)-(\d\d)-(\d\d)')
if is_number(dates.date.latestDate._.$first)
copy_field(dates.date.latestDate._.$first, production_date_copyright)
end
else
if any_match(dates.date.latestDate._, '(\d\d\d\d)-(\d\d)')
parse_text(dates.date.latestDate._, '(\d\d\d\d)-(\d\d)')
if is_number(dates.date.latestDate._.$first)
copy_field(dates.date.latestDate._.$first, production_date_copyright)
end
else
if any_match(dates.date.latestDate._, '(\d\d\d\d)')
if is_number(dates.date.latestDate._)
copy_field(dates.date.latestDate._, production_date_copyright)
end
else
set_field(determined, "true")
end
end
end
end
else
do list(path: 'creator_dod', var: 'dod')
copy_field(dod, tmp_dod)
if any_match(tmp_dod, '(\d\d\d\d)-(\d\d)-(\d\d)')
parse_text(tmp_dod, '(\d\d\d\d)-(\d\d)-(\d\d)')
if is_number(tmp_dod.$first)
copy_field(tmp_dod.$first, pretty_dod.$append)
end
else
if any_match(tmp_dod, '(\d\d\d\d)-(\d\d)')
parse_text(tmp_dod, '(\d\d\d\d)-(\d\d)')
if is_number(tmp_dod.$first)
copy_field(tmp_dod.$first, pretty_dod.$append)
end
else
if any_match(tmp_dod, '(\d\d\d\d)')
if is_number(tmp_dod)
copy_field(tmp_dod, pretty_dod.$append)
end
else
set_field(determined, "true")
end
end
end
remove_field(tmp_dod)
end
end
# Step 2: Actual determination of the copyright
if all_match(check_production_date, 'true')
if all_equal(determined, "false")
if all_match(production_date_copyright, ".*\S.*")
if less_than(production_date_copyright, 1870)
set_field(publish_image, "true")
end
set_field(determined, "true")
end
end
remove_field(check_production_date)
else
if all_equal(determined, "false")
sort_field(pretty_dod, numeric: 1)
if all_match(pretty_dod.$last, ".*\S.*")
if less_than(pretty_dod.$last, 1948)
set_field(publish_image, "true")
end
set_field(determined, "true")
end
end
end
# Done. Remove fields. We don't need them anymore.
remove_field(creator_dod)
remove_field(pretty_dod)
remove_field(production_date_copyright)
remove_field(dates)
remove_field(determined)
## Period
set_array(period)
# Use the event 'production'
do list(path:'filteredDescriptiveMetadata.eventWrap.eventSet', var: e)
do list(path:e.event.eventType.term, var:p)
if all_match(p._, 'production')
# Get period from LIDO
# If no period exists, use n/a (not available)
do list(path:e.event.periodName, var:per)
# Use NL field
if all_match('per.term.*.lang', 'nl')
if all_match('per.term.*._', '.*\S.*')
copy_field('per.term.*._', period.$append)
else
add_field(tmp_period, 'n/a')
copy_field(tmp_period, period.$append)
remove_field(tmp_period)
end
end
end
end
end
end
# If the field for period is empty, use n/a (not available)
unless all_match(period.$first, '.*\S.*')
set_field(period.$first, 'n/a')
end
sort_field(period)
## Repository
# Get repository from LIDO if exists (repository = data provider / source of record)
# If no repository exists, use n/a (not available)
if all_match('filteredAdministrativeMetadata.recordWrap.recordSource.0.legalBodyName.0.appellationValue.0._', '.*\S.*')
copy_field('filteredAdministrativeMetadata.recordWrap.recordSource.0.legalBodyName.0.appellationValue.0._', 'repository')
else
add_field('repository', 'n/a')
end
## Material
set_array(material_display)
set_array(material)
# Use the event 'production'
do list(path:'filteredDescriptiveMetadata.eventWrap.eventSet', var:e)
do list(path:e.event.eventType.term, var:p)
if all_match(p._, 'production')
# Get materials from LIDO
do list(path:e.event.eventMaterialsTech, var:mat)
# Use the preferred term for the detail page
# Use the alternate term in the search results / facet if exists, else use the preferred term
# If no material exists, use n/a (not available)
if all_match(mat.materialsTech.termMaterialsTech.0.type, 'material')
do list(path: 'mat.materialsTech.termMaterialsTech.0.term', var:prefMaterial)
if all_match('prefMaterial.pref', 'preferred')
if all_match(prefMaterial._, '.*\S.*')
copy_field(prefMaterial._, material_display.$append)
copy_field(prefMaterial._, material.$append)
else
add_field(tmp_material, 'n/a')
copy_field(tmp_material, material_display.$append)
copy_field(tmp_material, material.$append)
remove_field(tmp_material)
end
end
end
do list(path: 'mat.materialsTech.termMaterialsTech.0.term', var:prefMaterial)
if all_match('prefMaterial.pref', 'alternate')
if all_match(prefMaterial._, '.*\S.*')
copy_field(prefMaterial._, material.$last)
end
end
end
end
end
end
end
end
# If the fields for material are empty, use n/a (not available)
unless all_match(material_display.$first, '.*\S.*')
set_field(material_display.$first, 'n/a')
end
unless all_match(material.$first, '.*\S.*')
set_field(material.$first, 'n/a')
end
## Dimensions
set_array(dimensions)
# Use extent 'geheel' (used in AdLib) or 'Dagmaat' (used in TMS)
do list(path:filteredDescriptiveMetadata.objectIdentificationWrap.objectMeasurementsWrap.objectMeasurementsSet, var:el2)
if all_match(el2.objectMeasurements.extentMeasurements.0._, 'geheel')
# Get measurements from LIDO
# If no measurement exist, use n/a (not available)
do list(path:el2.objectMeasurements.measurementsSet, var:el)
if all_match('el.measurementType.0._', 'hoogte')
if all_match(el.measurementValue._, '.*\S.*')
copy_field(el.measurementValue._, dimensionsh.$append)
else
add_field(tmp_dimensionsh, 'n/a')
copy_field(tmp_dimensionsh, dimensionsh.$append)
remove_field(tmp_dimensionsh)
end
if all_match(el.measurementUnit.0._, '.*\S.*')
copy_field(el.measurementUnit.0._, dimensionsh.$append)
else
add_field(tmp_dimensionsh, 'n/a')
copy_field(tmp_dimensionsh, dimensionsh.$append)
remove_field(tmp_dimensionsh)
end
join_field(dimensionsh, ' ')
if all_match(dimensionsh, 'n/a n/a')
remove_field(dimensionsh)
else
prepend(dimensionsh, 'h ')
move_field(dimensionsh, dimensions.$append)
end
end
if all_match('el.measurementType.0._', 'breedte')
if all_match(el.measurementValue._, '.*\S.*')
copy_field(el.measurementValue._, dimensionsw.$append)
else
add_field(tmp_dimensionsw, 'n/a')
copy_field(tmp_dimensionsw, dimensionsw.$append)
remove_field(tmp_dimensionsw)
end
if all_match(el.measurementUnit.0._, '.*\S.*')
copy_field(el.measurementUnit.0._, dimensionsw.$append)
else
add_field(tmp_dimensionsw, 'n/a')
copy_field(tmp_dimensionsw, dimensionsw.$append)
remove_field(tmp_dimensionsw)
end
join_field(dimensionsw, ' ')
if all_match(dimensionsw, 'n/a n/a')
remove_field(dimensionsw)
else
prepend(dimensionsw, 'b ')
move_field(dimensionsw, dimensions.$append)
end
end
if all_match('el.measurementType.0._', 'diepte')
if all_match(el.measurementValue._, '.*\S.*')
copy_field(el.measurementValue._, dimensionsd.$append)
else
add_field(tmp_dimensionsd, 'n/a')
copy_field(tmp_dimensionsd, dimensionsd.$append)
remove_field(tmp_dimensionsd)
end
if all_match(el.measurementUnit.0._, '.*\S.*')
copy_field(el.measurementUnit.0._, dimensionsd.$append)
else
add_field(tmp_dimensionsd, 'n/a')
copy_field(tmp_dimensionsd, dimensionsd.$append)
remove_field(tmp_dimensionsd)
end
join_field(dimensionsd, ' ')
if all_match(dimensionsd, 'n/a n/a')
remove_field(dimensionsd)
else
prepend(dimensionsd, 'd ')
move_field(dimensionsd, dimensions.$append)
end
end
if all_match('el.measurementType.0._', 'diameter')
if all_match(el.measurementValue._, '.*\S.*')
copy_field(el.measurementValue._, dimensionsr.$append)
else
add_field(tmp_dimensionsr, 'n/a')
copy_field(tmp_dimensionsr, dimensionsr.$append)
remove_field(tmp_dimensionsr)
end
if all_match(el.measurementUnit.0._, '.*\S.*')
copy_field(el.measurementUnit.0._, dimensionsr.$append)
else
add_field(tmp_dimensionsr, 'n/a')
copy_field(tmp_dimensionsr, dimensionsr.$append)
remove_field(tmp_dimensionsr)
end
join_field(dimensionsr, ' ')
if all_match(dimensionsr, 'n/a n/a')
remove_field(dimensionsr)
else
append(dimensionsr, ' (diameter)')
move_field(dimensionsr, dimensions.$append)
end
end
end
else
if all_match(el2.objectMeasurements.extentMeasurements.0._, 'Dagmaat')
if all_match(el2.displayObjectMeasurements.0._, '.*\S.*')
if all_match(dimensions.$first, '.*\S.*')
unless in(el2.displayObjectMeasurements.0._, dimensions.$last)
copy_field(el2.displayObjectMeasurements.0._, dimensions.$append)
end
else
copy_field(el2.displayObjectMeasurements.0._, dimensions.$append)
end
end
end
end
end
# If the field for dimensions is empty, use n/a (not available)
unless all_match(dimensions.$first, '.*\S.*')
set_field(dimensions.$first, 'n/a')
end
## Category
set_array(artwork_category_display)
set_array(artwork_category)
# Use type 'content-motif-general'
do list(path: 'filteredDescriptiveMetadata.objectRelationWrap.subjectWrap.subjectSet', var:c)
if all_match(c.subject.type, 'content-motif-general')
# Get content motif general from LIDO
# Use the preferred term for the detail page
# Use the alternate term in the search results / facet if exists, else use the preferred term
# If no content motif general exists, use n/a (not available)
do list(path: 'c.subject.subjectConcept', var:subjectconcept)
do list(path: 'subjectconcept.term', var:subject)
if all_match('subject.pref', 'preferred')
if all_match(subject._, '.*\S.*')
copy_field(subject._, artwork_category_display.$append)
copy_field(subject._, artwork_category.$append)
else
add_field(tmp_artwork_category_display, 'n/a')
copy_field(tmp_artwork_category_display, artwork_category_display.$append)
copy_field(tmp_artwork_category_display, artwork_category.$append)
remove_field(tmp_artwork_category_display)
end
end
end
do list(path: 'subjectconcept.term', var:subject)
if all_match('subject.pref', 'alternate')
if all_match(subject._, '.*\S.*')
copy_field(subject._, artwork_category.$last)
end
end
end
end
end
end
# If the fields for artwork category are empty, use n/a (not available)
unless all_match(artwork_category_display.$first, '.*\S.*')
set_field(artwork_category_display.$first, 'n/a')
end
unless all_match(artwork_category.$first, '.*\S.*')
set_field(artwork_category.$first, 'n/a')
end
## Artwork_type
set_array(artwork_type_display)
set_array(artwork_type)
# Use type 'object-category'
do list(path: 'filteredDescriptiveMetadata.objectClassificationWrap.classificationWrap.classification', var:c)
if all_match(c.type, 'object-category')
# Get artwork type from LIDO
# Use the preferred term for the detail page
# Use the alternate term in the search results / facet if exists, else use the preferred term
# If no artwork type exists, use n/a (not available)
do list(path: 'c.term', var:classification)
if all_match('classification.pref', 'preferred')
if all_match(classification._, '.*\S.*')
copy_field(classification._, artwork_type_display.$append)
copy_field(classification._, artwork_type.$append)
else
add_field(tmp_artwork_type_display, 'n/a')
copy_field(tmp_artwork_type_display, artwork_type_display.$append)
copy_field(tmp_artwork_type_display, artwork_type.$append)
remove_field(tmp_artwork_type_display)
end
end
end
do list(path: 'c.term', var:classification)
if all_match('classification.pref', 'alternate')
if all_match(classification._, '.*\S.*')
copy_field(classification._, artwork_type.$last)
end
end
end
end
end
# If the fields for artwork type are empty, use n/a (not available)
unless all_match(artwork_type_display.$first, '.*\S.*')
set_field(artwork_type_display.$first, 'n/a')
end
unless all_match(artwork_type.$first, '.*\S.*')
set_field(artwork_type.$first, 'n/a')
end
## Artwork_subtype
set_array(artwork_subtype_display)
set_array(artwork_subtype)
# Get artwork subtype from LIDO
# Use the preferred term for the detail page
# Use the alternate term in the search results / facet if exists, else use the preferred term
# If no artwork subtype exists, use n/a (not available)
do list(path: 'filteredDescriptiveMetadata.objectClassificationWrap.objectWorkTypeWrap.objectWorkType', var:t)
do list(path: 't.term', var:type)
if all_match('type.pref', 'preferred')
if all_match(type._, '.*\S.*')
copy_field(type._, artwork_subtype_display.$append)
copy_field(type._, artwork_subtype.$append)
else
add_field(tmp_artwork_subtype_display, 'n/a')
copy_field(tmp_artwork_subtype_display, artwork_subtype_display.$append)
copy_field(tmp_artwork_subtype_display, artwork_subtype.$append)
remove_field(tmp_artwork_subtype_display)
end
end
end
do list(path: 't.term', var:type)
if all_match('type.pref', 'alternate')
if all_match(type._, '.*\S.*')
copy_field(type._, artwork_subtype.$last)
end
end
end
end
# If the fields for artwork subtype are empty, use n/a (not available)
unless all_match(artwork_subtype_display.$first, '.*\S.*')
set_field(artwork_subtype_display.$first, 'n/a')
end
unless all_match(artwork_subtype.$first, '.*\S.*')
set_field(artwork_subtype.$first, 'n/a')
end
## Object_number
if all_match('filteredDescriptiveMetadata.objectIdentificationWrap.repositoryWrap.repositorySet.0.workID.0.type', 'object-number')
if all_match('filteredDescriptiveMetadata.objectIdentificationWrap.repositoryWrap.repositorySet.0.workID.0._', '.*\S.*')
copy_field('filteredDescriptiveMetadata.objectIdentificationWrap.repositoryWrap.repositorySet.0.workID.0._', 'object_number')
else
add_field('object_number', 'n/a')
end
end
unless exists(object_number)
add_field(object_number, 'n/a')
end
## Description
if all_match('filteredDescriptiveMetadata.objectIdentificationWrap.objectDescriptionWrap.objectDescriptionSet.0.descriptiveNoteValue.0._', '.*\S.*')
if all_match('filteredDescriptiveMetadata.objectIdentificationWrap.objectDescriptionWrap.objectDescriptionSet.0.descriptiveNoteValue.0._', '.*\S.*')
copy_field('filteredDescriptiveMetadata.objectIdentificationWrap.objectDescriptionWrap.objectDescriptionSet.0.descriptiveNoteValue.0._', 'description')
else
add_field('description', 'n/a')
end
end
unless exists(description)
add_field(description, 'n/a')
end
## Work_pid
if all_match('_metadata.objectPublishedID.0._', '.*\S.*')
copy_field('_metadata.objectPublishedID.0._', 'work_pid')
else
add_field('work_pid', 'n/a')
end
unless exists(work_pid)
add_field(work_pid, 'n/a')
end
## Data_pid
do list(path: '_metadata.lidoRecID', var:lidoRecID)
if all_match('lidoRecID.type', 'purl')
if all_match(lidoRecID._, '.*\S.*')
copy_field(lidoRecID._, data_pid)
else
add_field(data_pid, 'n/a')
end
end
# The field 'raw' is used in process.pl to map the entire LIDO XML to a Solr field called 'xml' and is removed there at the end
# See: https://github.com/VlaamseKunstcollectie/Datahub-Fixes/blob/master/scripts/process.pl
if all_match('lidoRecID.type', 'urn')
copy_field(lidoRecID._, raw)
end