cocina-models 0.73.4 → 0.74.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e36c91847522f749650469baa62212b07632cb7f9911765ecf87ba4954b3b056
4
- data.tar.gz: a3491dee559e9d808710119bb37ae04c2bb7bbe132206cb43303d14e891502ba
3
+ metadata.gz: de6cff9bb4c5ec4f7b2533f024c37a6536d4c94ca1ba19cb91f4203ee8e9588f
4
+ data.tar.gz: 2b01b63cbccae36d295b825ffd44f435dd03e95ea84daf54caa62b13d696f9c5
5
5
  SHA512:
6
- metadata.gz: f54524fe21ca78880b045703d4c9083a11e82e15d37fa5c9b1ec68d2bcb97d41981effc17824b1def7dfb193c150fca4f72d051357c47d3872098e9e104d7c96
7
- data.tar.gz: 48f9104d7eafb5df6a10bb77962e888a5c372172a325f6b8ffbd494a0ca554d1c51d482403a5210a1b83daf611ba37bf1612d0d7750327c7687f0f90b3f7efe6
6
+ metadata.gz: 6cff72fbbe94becd71a3ad92f622650dba10b7a26d3eef9f34d8c856e47b2bfd87551f0e8a6bccd7974c36347d33f7a20c906e417e7a70346fa00f0d43f4a66f
7
+ data.tar.gz: fc2e259a1d7c9a2efeda647d6db82bce3a9116736b1d69fbd01e07bfae2f169a5b56510ad7e29b2b10a9efe3ecc9896b0bf16f203e27ad752cc2c3df55730a09
@@ -17,6 +17,8 @@ access.note:
17
17
  description: License describing allowed uses of the resource.
18
18
  - value: use and reproduction
19
19
  description: Information related to allowed uses of the resource in other contexts.
20
+ - value: access constraints
21
+ status: TEMP
20
22
  access.physicalLocation:
21
23
  - value: discovery
22
24
  description: Location where a user may find the resource.
@@ -142,12 +144,21 @@ event:
142
144
  - value: withdrawal
143
145
  description: The removal of previous access to a resource, often due to its obsolescence.
144
146
  event.date:
147
+ - value: accompanying letter
148
+ description: Athanasius
149
+ status: deprecated
145
150
  - value: acquisition
146
151
  description: The transferral of ownership of a resource to a repository.
147
152
  - value: capture
148
153
  description: A record of the resource in a fixed form at a specific time.
149
154
  - value: collection
150
155
  description: The addition of a resource to a set of other resources.
156
+ - value: composition
157
+ description: Athanasius
158
+ status: deprecated
159
+ - value: copy
160
+ description: Athanasius
161
+ status: deprecated
151
162
  - value: copyright
152
163
  description: The activity by which a resource may be considered subject to copyright law.
153
164
  - value: coverage
@@ -167,21 +178,54 @@ event.date:
167
178
  description: The delivery of the resource to an external audience.
168
179
  - value: generation
169
180
  description: The creation of a resource by an automatic or natural process.
170
- - value: Hijiri calendar
181
+ - value: Hijri calendar
171
182
  - value: Islamic
172
183
  - value: Julian
184
+ - value: letter
185
+ description: Athanasius
186
+ status: deprecated
187
+ - value: letter referred to
188
+ description: Athanasius
189
+ status: deprecated
173
190
  - value: manufacture
174
191
  description: The physical assembly of a resource, often in multiple copies, for publication or other distribution.
192
+ - value: manuscript
193
+ description: Athanasius
194
+ status: deprecated
195
+ - value: manuscript referred to
196
+ description: Athanasius
197
+ status: deprecated
175
198
  - value: modification
176
199
  description: A change to an existing resource.
200
+ - value: new document
201
+ description: Athanasius
202
+ - value: new style letter
203
+ status: deprecated
204
+ description: Athanasius
205
+ status: deprecated
206
+ - value: observation
207
+ description: Athanasius
208
+ status: deprecated
209
+ - value: old style letter
210
+ description: Athanasius
211
+ status: deprecated
212
+ - value: original sent
213
+ description: Athanasius
214
+ status: deprecated
177
215
  - value: performance
178
216
  description: The enactment of an artistic or cultural work for an audience, such as a play.
179
217
  - value: presentation
180
218
  description: The discussion of an academic or intellectual work for an audience, such as a seminar.
219
+ - value: proclamation
220
+ description: Athanasius
221
+ status: deprecated
181
222
  - value: production
182
223
  description: The physical assembly of a resource not considered published, such as page proofs for a book.
183
224
  - value: publication
184
225
  description: The publishing or issuing of a resource.
226
+ - value: quoted
227
+ description: Athanasius
228
+ status: deprecated
185
229
  - value: recording
186
230
  description: The initial fixation to a medium of live audio and/or visual activity.
187
231
  - value: release
@@ -243,6 +287,9 @@ geographic.subject.structuredValue:
243
287
  - value: south
244
288
  - value: west
245
289
  identifier:
290
+ - value: accession
291
+ status: deprecated
292
+ use: accession number
246
293
  - value: accession number
247
294
  - value: alternate case number
248
295
  - value: anchor
@@ -254,8 +301,11 @@ identifier:
254
301
  code: arxiv
255
302
  - value: case identifier
256
303
  - value: case number
304
+ - value: CCP
305
+ - value: CLC
257
306
  - value: CSt
258
307
  - value: CStRLIN
308
+ - value: CTC
259
309
  - value: Data Provider Digital Object Identifier
260
310
  - value: document number
261
311
  - value: DOI
@@ -317,6 +367,14 @@ identifier:
317
367
  - value: West Mat \#
318
368
  - value: Wikidata
319
369
  code: wikidata
370
+ - value: Bodley 342
371
+ status: TEMP
372
+ - value: vintage
373
+ status: TEMP
374
+ - value: accesion
375
+ status: TEMP
376
+ - value: Suri UUID
377
+ status: TEMP
320
378
  note:
321
379
  - value: abstract
322
380
  - value: access
@@ -438,6 +496,8 @@ note:
438
496
  - value: version
439
497
  - value: version identification
440
498
  - value: writing
499
+ - value: note
500
+ status: TEMP
441
501
  note.groupedValue:
442
502
  - value: caption
443
503
  - value: date
@@ -492,6 +552,8 @@ subject:
492
552
  - value: time
493
553
  - value: title
494
554
  - value: topic
555
+ - value: surname
556
+ status: TEMP
495
557
  subject.note:
496
558
  - value: affiliation
497
559
  - value: description
@@ -519,6 +581,7 @@ subject.structuredValue:
519
581
  - value: longitude
520
582
  - value: main title
521
583
  - value: name
584
+ - value: nonsorting characters
522
585
  - value: north
523
586
  - value: occupation
524
587
  - value: ordinal
@@ -560,6 +623,10 @@ title:
560
623
  description: Title transliterated from non-Latin script to Latin script.
561
624
  - value: uniform
562
625
  description: Form of title in Library of Congress title authority.
626
+ - value: main
627
+ status: TEMP
628
+ - value: other title
629
+ status: TEMP
563
630
  title.note:
564
631
  - value: associated name
565
632
  description: A name linked to the title, such as for a name-title heading.
@@ -15,6 +15,7 @@ _Path: access.note_
15
15
  * display label: Display label for the purl.
16
16
  * license: License describing allowed uses of the resource.
17
17
  * use and reproduction: Information related to allowed uses of the resource in other contexts.
18
+ * access constraints
18
19
 
19
20
  ## Access physicallocation types
20
21
  _Path: access.physicalLocation_
@@ -103,9 +104,12 @@ _Path: event_
103
104
 
104
105
  ## Event date types
105
106
  _Path: event.date_
107
+ * accompanying letter: Athanasius
106
108
  * acquisition: The transferral of ownership of a resource to a repository.
107
109
  * capture: A record of the resource in a fixed form at a specific time.
108
110
  * collection: The addition of a resource to a set of other resources.
111
+ * composition: Athanasius
112
+ * copy: Athanasius
109
113
  * copyright: The activity by which a resource may be considered subject to copyright law.
110
114
  * coverage
111
115
  * creation: The coming into being of a resource.
@@ -116,15 +120,26 @@ _Path: event.date_
116
120
  * development: The creation of a print from a photographic negative or other source medium.
117
121
  * distribution: The delivery of the resource to an external audience.
118
122
  * generation: The creation of a resource by an automatic or natural process.
119
- * Hijiri calendar
123
+ * Hijri calendar
120
124
  * Islamic
121
125
  * Julian
126
+ * letter: Athanasius
127
+ * letter referred to: Athanasius
122
128
  * manufacture: The physical assembly of a resource, often in multiple copies, for publication or other distribution.
129
+ * manuscript: Athanasius
130
+ * manuscript referred to: Athanasius
123
131
  * modification: A change to an existing resource.
132
+ * new document: Athanasius
133
+ * new style letter: Athanasius
134
+ * observation: Athanasius
135
+ * old style letter: Athanasius
136
+ * original sent: Athanasius
124
137
  * performance: The enactment of an artistic or cultural work for an audience, such as a play.
125
138
  * presentation: The discussion of an academic or intellectual work for an audience, such as a seminar.
139
+ * proclamation: Athanasius
126
140
  * production: The physical assembly of a resource not considered published, such as page proofs for a book.
127
141
  * publication: The publishing or issuing of a resource.
142
+ * quoted: Athanasius
128
143
  * recording: The initial fixation to a medium of live audio and/or visual activity.
129
144
  * release: Making a resource available to a broader audience.
130
145
  * Revolutionary calendar
@@ -194,6 +209,7 @@ _Path: geographic.subject.structuredValue_
194
209
 
195
210
  # Identifier types
196
211
  _Path: identifier_
212
+ * accession
197
213
  * accession number
198
214
  * alternate case number
199
215
  * anchor
@@ -202,8 +218,11 @@ _Path: identifier_
202
218
  * arXiv
203
219
  * case identifier
204
220
  * case number
221
+ * CCP
222
+ * CLC
205
223
  * CSt
206
224
  * CStRLIN
225
+ * CTC
207
226
  * Data Provider Digital Object Identifier
208
227
  * document number
209
228
  * DOI
@@ -242,6 +261,10 @@ _Path: identifier_
242
261
  * videorecording identifier
243
262
  * West Mat \#
244
263
  * Wikidata
264
+ * Bodley 342
265
+ * vintage
266
+ * accesion
267
+ * Suri UUID
245
268
 
246
269
  # Note types
247
270
  _Path: note_
@@ -349,6 +372,7 @@ _Path: note_
349
372
  * version
350
373
  * version identification
351
374
  * writing
375
+ * note
352
376
 
353
377
  ## Note types for grouped value (MODS legacy)
354
378
  _Path: note.groupedValue_
@@ -396,6 +420,7 @@ _Path: subject_
396
420
  * time
397
421
  * title
398
422
  * topic
423
+ * surname
399
424
 
400
425
  ## Subject note types
401
426
  _Path: subject.note_
@@ -427,6 +452,7 @@ _Path: subject.structuredValue_
427
452
  * longitude
428
453
  * main title
429
454
  * name
455
+ * nonsorting characters
430
456
  * north
431
457
  * occupation
432
458
  * ordinal
@@ -465,6 +491,8 @@ _Path: title_
465
491
  * translated: Title translated into another language.
466
492
  * transliterated: Title transliterated from non-Latin script to Latin script.
467
493
  * uniform: Form of title in Library of Congress title authority.
494
+ * main
495
+ * other title
468
496
 
469
497
  ## Title note types
470
498
  _Path: title.note_
@@ -8,7 +8,7 @@ module Cocina
8
8
 
9
9
  class_methods do
10
10
  def new(attributes = default_attributes, safe = false, validate = true, &block)
11
- Validators::Validator.validate(self, attributes.with_indifferent_access) if validate
11
+ Validators::Validator.validate(self, attributes) if validate
12
12
  super(attributes, safe, &block)
13
13
  end
14
14
  end
@@ -16,7 +16,7 @@ module Cocina
16
16
  def new(*args)
17
17
  validate = args.first.delete(:validate) if args.present?
18
18
  new_model = super(*args)
19
- Validators::Validator.validate(new_model.class, new_model.to_h) if validate || validate.nil?
19
+ Validators::Validator.validate(new_model.class, new_model) if validate || validate.nil?
20
20
  new_model
21
21
  end
22
22
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ module Validators
6
+ # Validates that Purl matches the external identifier (druid)
7
+ class PurlValidator
8
+ def self.validate(clazz, attributes)
9
+ new(clazz, attributes).validate
10
+ end
11
+
12
+ def initialize(clazz, attributes)
13
+ @clazz = clazz
14
+ @attributes = attributes
15
+ end
16
+
17
+ def validate
18
+ return unless meets_preconditions?
19
+
20
+ return if identifier_from_druid == identifier_from_purl
21
+
22
+ raise ValidationError, "Purl mismatch: #{druid} purl does not match object druid."
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :clazz, :attributes
28
+
29
+ def meets_preconditions?
30
+ purl
31
+ end
32
+
33
+ def druid
34
+ @druid ||= attributes[:externalIdentifier]
35
+ end
36
+
37
+ def purl
38
+ @purl ||= attributes.dig(:description, :purl)
39
+ end
40
+
41
+ def identifier_from_druid
42
+ druid.delete_prefix('druid:')
43
+ end
44
+
45
+ def identifier_from_purl
46
+ purl.split('/').last
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -8,13 +8,38 @@ module Cocina
8
8
  VALIDATORS = [
9
9
  OpenApiValidator,
10
10
  DarkValidator,
11
+ PurlValidator,
11
12
  CatalogLinksValidator,
12
13
  DescriptionTypesValidator
13
14
  ].freeze
14
15
 
15
16
  def self.validate(clazz, attributes)
16
- VALIDATORS.each { |validator| validator.validate(clazz, attributes) }
17
+ # This gets rid of nested model objects.
18
+ # Once DSA is on Rails 6, this can be:
19
+ # attributes_hash = attributes.to_h.deep_transform_values do |value|
20
+ # value.class.name.starts_with?('Cocina::Models') ? value.to_h : value
21
+ # end.with_indifferent_access
22
+ # And add require 'active_support/core_ext/hash/deep_transform_values' to models file.
23
+
24
+ # In the meantime, copying code.
25
+ attributes_hash = deep_transform_values(attributes.to_h) do |value|
26
+ value.class.name.starts_with?('Cocina::Models') ? value.to_h : value
27
+ end.with_indifferent_access
28
+
29
+ VALIDATORS.each { |validator| validator.validate(clazz, attributes_hash) }
30
+ end
31
+
32
+ def self.deep_transform_values(object, &block)
33
+ case object
34
+ when Hash
35
+ object.transform_values { |value| deep_transform_values(value, &block) }
36
+ when Array
37
+ object.map { |e| deep_transform_values(e, &block) }
38
+ else
39
+ yield(object)
40
+ end
17
41
  end
42
+ private_class_method :deep_transform_values
18
43
  end
19
44
  end
20
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.73.4'
5
+ VERSION = '0.74.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.73.4
4
+ version: 0.74.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-14 00:00:00.000000000 Z
11
+ date: 2022-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -391,6 +391,7 @@ files:
391
391
  - lib/cocina/models/validators/dark_validator.rb
392
392
  - lib/cocina/models/validators/description_types_validator.rb
393
393
  - lib/cocina/models/validators/open_api_validator.rb
394
+ - lib/cocina/models/validators/purl_validator.rb
394
395
  - lib/cocina/models/validators/validator.rb
395
396
  - lib/cocina/models/version.rb
396
397
  - lib/cocina/models/vocabulary.rb