cocina-models 0.128.0 → 0.130.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,600 @@
1
+ # Form source codes from LC source lists
2
+ # Sources:
3
+ # - https://www.loc.gov/standards/sourcelist/genre-form.html
4
+ # - https://www.loc.gov/standards/sourcelist/subject.html
5
+ - aass
6
+ - aat
7
+ - aatnor
8
+ - abne
9
+ - aedoml
10
+ - afo
11
+ - afset
12
+ - agrifors
13
+ - agrovoc
14
+ - agrovocf
15
+ - agrovocs
16
+ - ahecc
17
+ - aiatsisl
18
+ - aiatsisp
19
+ - aiatsiss
20
+ - aktp
21
+ - albt
22
+ - alett
23
+ - allars
24
+ - amg
25
+ - anzsic
26
+ - anzsoc
27
+ - anzsrc
28
+ - apaist
29
+ - armarc
30
+ - ascdc
31
+ - asced
32
+ - ascl
33
+ - asft
34
+ - ashlnl
35
+ - asrcrfcd
36
+ - asrcseo
37
+ - asrctoa
38
+ - asth
39
+ - ated
40
+ - atg
41
+ - atla
42
+ - aucsh
43
+ - ausext
44
+ - bare
45
+ - barn
46
+ - barngf
47
+ - bdrc
48
+ - bella
49
+ - bellobv
50
+ - bet
51
+ - bgtchm
52
+ - bhammf
53
+ - bhashe
54
+ - bhb
55
+ - bib1814
56
+ - bibalex
57
+ - bibbi
58
+ - biccbmc
59
+ - bicssc
60
+ - bidex
61
+ - bisacmt
62
+ - bisacrt
63
+ - bisacsh
64
+ - bjornson
65
+ - blcpss
66
+ - blmlsh
67
+ - blnpn
68
+ - bokbas
69
+ - bt
70
+ - btr
71
+ - buscem
72
+ - buscxf
73
+ - cabt
74
+ - cash
75
+ - cbk
76
+ - cbktrf
77
+ - cccv
78
+ - cck
79
+ - cckthema
80
+ - ccsa
81
+ - cct
82
+ - ccte
83
+ - cctf
84
+ - cdcng
85
+ - ceeus
86
+ - cgndb
87
+ - cgpa
88
+ - chirosh
89
+ - cht
90
+ - ciesiniv
91
+ - cilla
92
+ - cjh
93
+ - coarrt
94
+ - collett
95
+ - conorsi
96
+ - conorsr
97
+ - csahssa
98
+ - csalsct
99
+ - csapa
100
+ - csh
101
+ - csht
102
+ - cstud
103
+ - cyac
104
+ - czenas
105
+ - czmesh
106
+ - dbcsh
107
+ - dbn
108
+ - dcs
109
+ - dct
110
+ - ddcri
111
+ - ddcrit
112
+ - ddcut
113
+ - dhb-jdg
114
+ - dicgenam
115
+ - dicgenes
116
+ - dicgentop
117
+ - dissao
118
+ - dit
119
+ - dltlt
120
+ - dltt
121
+ - doll
122
+ - drama
123
+ - dtict
124
+ - dugfr
125
+ - ebfem
126
+ - eclas
127
+ - eet
128
+ - eflch
129
+ - eks
130
+ - elsst
131
+ - embehu
132
+ - embiaecid
133
+ - embne
134
+ - embucm
135
+ - embus
136
+ - embuz
137
+ - emnmus
138
+ - ept
139
+ - erfemn
140
+ - ericd
141
+ - esar
142
+ - est
143
+ - estc
144
+ - etiras
145
+ - etuesh
146
+ - etuturkob
147
+ - eum
148
+ - eurovoc
149
+ - eurovocen
150
+ - eurovoces
151
+ - eurovocfr
152
+ - eurovocsl
153
+ - fast
154
+ - fbg
155
+ - fcb
156
+ - fes
157
+ - fgtpcm
158
+ - finmesh
159
+ - fire
160
+ - flgeo
161
+ - fmesh
162
+ - fnhl
163
+ - francis
164
+ - frst
165
+ - fssh
166
+ - ftamc
167
+ - galestne
168
+ - gatbeg
169
+ - gbd
170
+ - gccst
171
+ - gcipmedia
172
+ - gcipplatform
173
+ - gem
174
+ - gemet
175
+ - gemppg
176
+ - geni
177
+ - geonames
178
+ - geonet
179
+ - georeft
180
+ - gmd
181
+ - gmgpc
182
+ - gnd
183
+ - gnd-carrier
184
+ - gnd-content
185
+ - gnd-music
186
+ - gnis
187
+ - gpn
188
+ - gsafd
189
+ - gsso
190
+ - gst
191
+ - gtlm
192
+ - gtmm
193
+ - gtt
194
+ - gttg
195
+ - habibe
196
+ - habich
197
+ - habifr
198
+ - habiit
199
+ - hamsun
200
+ - hapi
201
+ - helecon
202
+ - henn
203
+ - hkcan
204
+ - hlasstg
205
+ - hoidokki
206
+ - homoit
207
+ - hrvmesh
208
+ - hrvmr
209
+ - huc
210
+ - humord
211
+ - ibsen
212
+ - ica
213
+ - iconauth
214
+ - icpsr
215
+ - idas
216
+ - idref
217
+ - idsbb
218
+ - idszbz
219
+ - idszbzes
220
+ - idszbzna
221
+ - idszbzzg
222
+ - idszbzzh
223
+ - idszbzzk
224
+ - iescs
225
+ - iest
226
+ - ilot
227
+ - ilpt
228
+ - inist
229
+ - inspect
230
+ - ipat
231
+ - ipsp
232
+ - iptcnc
233
+ - isbdcontent
234
+ - isbdmedia
235
+ - isis
236
+ - itglit
237
+ - itis
238
+ - itrt
239
+ - jhpb
240
+ - jhpk
241
+ - jlabsh
242
+ - juho
243
+ - jupo
244
+ - jurivoc
245
+ - kaa
246
+ - kaba
247
+ - kao
248
+ - kassu
249
+ - kauno
250
+ - kaunokki
251
+ - kdm
252
+ - khib
253
+ - kito
254
+ - kitu
255
+ - kkts
256
+ - koko
257
+ - kssbar
258
+ - kta
259
+ - kto
260
+ - ktpt
261
+ - ktta
262
+ - kubikat
263
+ - kula
264
+ - kulo
265
+ - kupu
266
+ - labloc
267
+ - lacnaf
268
+ - lapponica
269
+ - larpcal
270
+ - lcac
271
+ - lcdgt
272
+ - lcgft
273
+ - lcmpt
274
+ - lcsh
275
+ - lcshac
276
+ - lcstt
277
+ - lctgm
278
+ - leaubsh
279
+ - lemac
280
+ - lemb
281
+ - liito
282
+ - liv
283
+ - lnmmbr
284
+ - lobt
285
+ - local
286
+ - lst
287
+ - ltcsh
288
+ - lua
289
+ - maaq
290
+ - maknaz
291
+ - maotao
292
+ - mar
293
+ - marccarrier
294
+ - marccategory
295
+ - marcform
296
+ - marcgt
297
+ - marcsmd
298
+ - masa
299
+ - mech
300
+ - mero
301
+ - mesh
302
+ - meshscr
303
+ - migfg
304
+ - mim
305
+ - minecost
306
+ - mipfesd
307
+ - mmm
308
+ - mpirdes
309
+ - msc
310
+ - msh
311
+ - msupplcont
312
+ - mtirdes
313
+ - mts
314
+ - musa
315
+ - muso
316
+ - musvok-sf
317
+ - muzeukc
318
+ - muzeukn
319
+ - muzeukv
320
+ - muzvukci
321
+ - naf
322
+ - nal
323
+ - nalnaf
324
+ - nasat
325
+ - nbdbgf
326
+ - nbdbt
327
+ - nbiemnfag
328
+ - ncjt
329
+ - ncrbs
330
+ - ncrcarrier
331
+ - ncrcontent
332
+ - ncrcpc
333
+ - ncrfs
334
+ - ncrft
335
+ - ncrmat
336
+ - ncrmedia
337
+ - ncrpm
338
+ - ncrpo
339
+ - ncrrm
340
+ - ncrtr
341
+ - ncrvf
342
+ - ndlgft
343
+ - ndlsh
344
+ - neo
345
+ - netc
346
+ - ngl
347
+ - nicem
348
+ - nimacsc
349
+ - nimafc
350
+ - niodt
351
+ - nlgaf
352
+ - nlggf
353
+ - nlgkk
354
+ - nlgsh
355
+ - nli
356
+ - nlksh
357
+ - nlmnaf
358
+ - nmaict
359
+ - nmc
360
+ - no-ubo-mr
361
+ - nom
362
+ - noraf
363
+ - noram
364
+ - norbok
365
+ - normesh
366
+ - norvok
367
+ - noubojur
368
+ - noubomn
369
+ - nsbncf
370
+ - nskps
371
+ - nskzs
372
+ - nta
373
+ - ntc
374
+ - ntcpsc
375
+ - ntcsd
376
+ - ntids
377
+ - ntissc
378
+ - ntsf
379
+ - nzcoh
380
+ - nzggn
381
+ - nznb
382
+ - oabt
383
+ - odlt
384
+ - ogst
385
+ - olacvggt
386
+ - opat
387
+ - opms
388
+ - ordnok
389
+ - orgnr
390
+ - pana
391
+ - pascal
392
+ - peakbag
393
+ - pepp
394
+ - peri
395
+ - periodo
396
+ - pha
397
+ - pkk
398
+ - pldi
399
+ - pleiades
400
+ - pmbok
401
+ - pmcsg
402
+ - pmont
403
+ - pmt
404
+ - poha
405
+ - poliscit
406
+ - popinte
407
+ - pplt
408
+ - ppluk
409
+ - precis
410
+ - prnpdi
411
+ - proqsc
412
+ - proysen
413
+ - prvt
414
+ - psh
415
+ - psychit
416
+ - puho
417
+ - qlit
418
+ - qlsp
419
+ - qnaf
420
+ - qnlsh
421
+ - qrma
422
+ - qrmak
423
+ - qtglit
424
+ - quiding
425
+ - radfg
426
+ - ram
427
+ - rasuqam
428
+ - rbbin
429
+ - rbgenr
430
+ - rbmscv
431
+ - rbpap
432
+ - rbpri
433
+ - rbprov
434
+ - rbpub
435
+ - rbtyp
436
+ - rda
437
+ - rdaar
438
+ - rdabf
439
+ - rdabs
440
+ - rdacarrier
441
+ - rdacc
442
+ - rdaco
443
+ - rdacontent
444
+ - rdacpc
445
+ - rdact
446
+ - rdaep
447
+ - rdafmn
448
+ - rdafnm
449
+ - rdafr
450
+ - rdafs
451
+ - rdaft
452
+ - rdagen
453
+ - rdagrp
454
+ - rdagw
455
+ - rdaill
456
+ - rdalay
457
+ - rdamat
458
+ - rdamedia
459
+ - rdami
460
+ - rdamt
461
+ - rdapf
462
+ - rdapm
463
+ - rdapo
464
+ - rdare
465
+ - rdarm
466
+ - rdarr
467
+ - rdasco
468
+ - rdaspc
469
+ - rdatb
470
+ - rdatc
471
+ - rdatr
472
+ - rdavf
473
+ - renib
474
+ - reo
475
+ - rero
476
+ - rerovoc
477
+ - reveal
478
+ - rma
479
+ - root
480
+ - rpe
481
+ - rswk
482
+ - rswkaf
483
+ - rugeo
484
+ - rurkp
485
+ - rvm
486
+ - rvmfast
487
+ - rvmgd
488
+ - rvmgf
489
+ - samisk
490
+ - sanb
491
+ - sao
492
+ - saogf
493
+ - sbaa
494
+ - sbiao
495
+ - sbt
496
+ - scbi
497
+ - scgdst
498
+ - scisshl
499
+ - scot
500
+ - sears
501
+ - sesca
502
+ - sfit
503
+ - sgc
504
+ - sgce
505
+ - sgp
506
+ - shbe
507
+ - she
508
+ - shsples
509
+ - sigle
510
+ - sipri
511
+ - sk
512
+ - skbb
513
+ - skish
514
+ - skon
515
+ - slem
516
+ - slm
517
+ - smda
518
+ - snt
519
+ - socio
520
+ - solstad
521
+ - sosa
522
+ - soto
523
+ - spines
524
+ - ssg
525
+ - stcv
526
+ - sthus
527
+ - stw
528
+ - swd
529
+ - swemesh
530
+ - taika
531
+ - tasmas
532
+ - taxhs
533
+ - tbjvp
534
+ - tef
535
+ - tekord
536
+ - tept
537
+ - tero
538
+ - tesa
539
+ - tesbhaecid
540
+ - test
541
+ - tgfbne
542
+ - tgfc
543
+ - tgn
544
+ - tha
545
+ - thema
546
+ - thesoz
547
+ - thia
548
+ - thla
549
+ - tho
550
+ - thub
551
+ - tips
552
+ - tisa
553
+ - tlka
554
+ - tlsh
555
+ - tmdbm
556
+ - tmdbp
557
+ - tmdbtv
558
+ - tpro
559
+ - trfarn
560
+ - trfbmb
561
+ - trfdh
562
+ - trfgr
563
+ - trfoba
564
+ - trfzb
565
+ - trt
566
+ - trtsa
567
+ - tsaij
568
+ - tshd
569
+ - tsht
570
+ - tsr
571
+ - ttka
572
+ - ttll
573
+ - tucua
574
+ - udc
575
+ - ukslc
576
+ - ula
577
+ - ulan
578
+ - umitrist
579
+ - unbisn
580
+ - unbist
581
+ - unescot
582
+ - unicefirc
583
+ - usaidt
584
+ - usgst
585
+ - valo
586
+ - vcaadu
587
+ - vffyl
588
+ - vgmsgg
589
+ - vgmsng
590
+ - vmj
591
+ - waqaf
592
+ - watrest
593
+ - wgst
594
+ - wikidata
595
+ - worldcat
596
+ - wot
597
+ - wpicsh
598
+ - ysa
599
+ - yso
600
+ - zst
@@ -21,9 +21,6 @@ module Cocina
21
21
  attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
22
22
  # Language of the descriptive element value
23
23
  attribute? :valueLanguage, DescriptiveValueLanguage.optional
24
- # For multiple representations of information about the same event (e.g. in different
25
- # languages)
26
- attribute :parallelEvent, Types::Strict::Array.of(DescriptiveParallelEvent).default([].freeze)
27
24
  end
28
25
  end
29
26
  end
@@ -104,58 +104,9 @@ module Cocina
104
104
  end
105
105
 
106
106
  def build_grouped_origin_infos(grouped_origin_infos)
107
- grouped_origin_infos.map do |origin_info_nodes|
108
- common_event_type = event_type_in_common(origin_info_nodes)
109
- common_display_label = display_label_in_common(origin_info_nodes)
110
-
111
- parallel_event = {
112
- type: common_event_type,
113
- displayLabel: common_display_label,
114
- parallelEvent: build_parallel_origin_infos(origin_info_nodes, common_event_type,
115
- common_display_label)
116
- }
117
-
118
- parallel_event.compact
119
- end.flatten
120
- end
121
-
122
- # For parallelEvent items, the valueLanguage construct is at the same level as the rest
123
- # of the event attributes, rather than inside each event attribute
124
- def build_parallel_origin_infos(origin_infos, common_event_type, common_display_label)
125
- origin_infos.flat_map do |origin_info|
126
- event = build_event_for_parallel_origin_info(origin_info)
127
- event[:valueLanguage] = LanguageScript.build(node: origin_info)
128
- event[:type] = display_label(origin_info) if common_event_type.blank?
129
- event[:displayLabel] = display_label(origin_info) if common_display_label.blank?
130
-
131
- event.compact
132
- end.compact
133
- end
134
-
135
- def build_event_for_parallel_origin_info(origin_info_node)
136
- return build_copyright_notice_event(origin_info_node) if origin_info_node['eventType'] == 'copyright notice'
137
-
138
- event = {}
139
- add_info_to_event(event, origin_info_node)
140
- event.compact
141
- end
142
-
143
- # @return String type for the cocina event if it is the same for all the origin_info_nodes, o.w. nil
144
- def event_type_in_common(origin_info_nodes)
145
- raw_type = origin_info_nodes.first['eventType']
146
- return if raw_type.blank?
147
-
148
- first_event_type = event_type(origin_info_nodes.first)
149
- first_event_type if origin_info_nodes.all? { |node| event_type(node) == first_event_type }
150
- end
151
-
152
- # @return String displayLabel for the cocina event if it is the same for all the origin_info_nodes, o.w. nil
153
- def display_label_in_common(origin_info_nodes)
154
- raw_label = origin_info_nodes.first['displayLabel']
155
- return if raw_label.blank?
156
-
157
- first_label = display_label(origin_info_nodes.first)
158
- first_label if origin_info_nodes.all? { |node| display_label(node) == first_label }
107
+ grouped_origin_infos.flat_map do |origin_info_nodes|
108
+ origin_info_nodes.map { |origin_info| build_event_for_origin_info(origin_info) }
109
+ end
159
110
  end
160
111
 
161
112
  def add_info_to_event(event, origin_info_node)
@@ -88,7 +88,7 @@ module Cocina
88
88
  uri: ValueURI.sniff(subject_node['valueURI'], notifier)
89
89
  }.tap do |attrs|
90
90
  source = {
91
- code: subject_node['authority'],
91
+ value: subject_node['authority'],
92
92
  uri: subject_node['authorityURI']
93
93
  }.compact
94
94
  attrs[:source] = source if source.present?
@@ -20,7 +20,7 @@ module Cocina
20
20
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
21
21
  # Description that is included in a request to create a DRO. This is the same as a
22
22
  # Description, except excludes PURL.
23
- attribute? :description, RequestDescription.optional
23
+ attribute(:description, RequestDescription.default { RequestDescription.new })
24
24
  end
25
25
  end
26
26
  end
@@ -12,7 +12,18 @@ module Cocina
12
12
  Thread.current[:top_level_validate] = validate unless Thread.current.key?(:top_level_validate)
13
13
 
14
14
  Validators::Validator.validate(self, attributes) if Thread.current[:top_level_validate]
15
- super(attributes, safe, &)
15
+
16
+ # Tracks that any Validatable construction triggered by `super` below is nested inside this one, so
17
+ # JsonSchemaValidator can skip it: this object's own schema check above already covers.
18
+ # See JsonSchemaValidator#validate.
19
+ # In practice, this avoids doing schema validation on a DRO / AdminPolicy / Collection and
20
+ # its nested Description.
21
+ Thread.current[:cocina_construction_depth] = Thread.current[:cocina_construction_depth].to_i + 1
22
+ begin
23
+ super(attributes, safe, &)
24
+ ensure
25
+ Thread.current[:cocina_construction_depth] -= 1
26
+ end
16
27
  ensure
17
28
  Thread.current[:top_level_validate] = nil
18
29
  end
@@ -20,7 +31,14 @@ module Cocina
20
31
 
21
32
  def new(*args)
22
33
  validate = args.first.delete(:validate) if args.present?
23
- new_model = super
34
+
35
+ Thread.current[:cocina_construction_depth] = Thread.current[:cocina_construction_depth].to_i + 1
36
+ begin
37
+ new_model = super
38
+ ensure
39
+ Thread.current[:cocina_construction_depth] -= 1
40
+ end
41
+
24
42
  Validators::Validator.validate(new_model.class, new_model) if validate || validate.nil?
25
43
  new_model
26
44
  end
@@ -11,6 +11,7 @@ module Cocina
11
11
  DescriptionRoleSourceCodeVisitorValidator,
12
12
  DescriptionNameSourceCodeVisitorValidator,
13
13
  DescriptionFormResourceTypeVisitorValidator,
14
+ DescriptionFormSourceCodeVisitorValidator,
14
15
  DescriptionLanguageCodeVisitorValidator,
15
16
  DescriptionSubjectSourceCodeVisitorValidator,
16
17
  DescriptionValuesVisitorValidator,
@@ -30,7 +31,7 @@ module Cocina
30
31
  def initialize(clazz, attributes, validators: VALIDATORS)
31
32
  @clazz = clazz
32
33
  @attributes = attributes
33
- @validators = validators.map(&:new)
34
+ @validators = meets_preconditions? ? validators.map(&:new) : []
34
35
  end
35
36
 
36
37
  def validate