cocina-models 0.73.6 → 0.74.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 010b22a3ad2f8bfe8f1c9fc020538adf0b89b2c77dc0ad0219c2321dfec5f6da
4
- data.tar.gz: c51eae2641ca506f08abaedbd99e8385b291b4ac144f6bdffacb9cc5c5379576
3
+ metadata.gz: de6cff9bb4c5ec4f7b2533f024c37a6536d4c94ca1ba19cb91f4203ee8e9588f
4
+ data.tar.gz: 2b01b63cbccae36d295b825ffd44f435dd03e95ea84daf54caa62b13d696f9c5
5
5
  SHA512:
6
- metadata.gz: 0b65ccf18b933dc8287371765ff66f1d17b13f3d206a960b6afcdaf337819fd3d1ddebb4146458c0eaacdc77064817f41aae5fe86edf2a58ab07de24ba5902a7
7
- data.tar.gz: bb93e938a05ce9a3370f245074a72e5c0ad009e6bd81c1330db7bc595578caaeb93f068550ec0b92060b9c1d299ff6250bb598bee37b43f1f685405881bb7f24
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.
@@ -176,7 +178,7 @@ event.date:
176
178
  description: The delivery of the resource to an external audience.
177
179
  - value: generation
178
180
  description: The creation of a resource by an automatic or natural process.
179
- - value: Hijiri calendar
181
+ - value: Hijri calendar
180
182
  - value: Islamic
181
183
  - value: Julian
182
184
  - value: letter
@@ -285,6 +287,9 @@ geographic.subject.structuredValue:
285
287
  - value: south
286
288
  - value: west
287
289
  identifier:
290
+ - value: accession
291
+ status: deprecated
292
+ use: accession number
288
293
  - value: accession number
289
294
  - value: alternate case number
290
295
  - value: anchor
@@ -296,8 +301,11 @@ identifier:
296
301
  code: arxiv
297
302
  - value: case identifier
298
303
  - value: case number
304
+ - value: CCP
305
+ - value: CLC
299
306
  - value: CSt
300
307
  - value: CStRLIN
308
+ - value: CTC
301
309
  - value: Data Provider Digital Object Identifier
302
310
  - value: document number
303
311
  - value: DOI
@@ -359,6 +367,14 @@ identifier:
359
367
  - value: West Mat \#
360
368
  - value: Wikidata
361
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
362
378
  note:
363
379
  - value: abstract
364
380
  - value: access
@@ -480,6 +496,8 @@ note:
480
496
  - value: version
481
497
  - value: version identification
482
498
  - value: writing
499
+ - value: note
500
+ status: TEMP
483
501
  note.groupedValue:
484
502
  - value: caption
485
503
  - value: date
@@ -534,6 +552,8 @@ subject:
534
552
  - value: time
535
553
  - value: title
536
554
  - value: topic
555
+ - value: surname
556
+ status: TEMP
537
557
  subject.note:
538
558
  - value: affiliation
539
559
  - value: description
@@ -574,7 +594,6 @@ subject.structuredValue:
574
594
  - value: south
575
595
  - value: start
576
596
  - value: state
577
- - value: subtitle
578
597
  - value: surname
579
598
  - value: term of address
580
599
  - value: territory
@@ -604,6 +623,10 @@ title:
604
623
  description: Title transliterated from non-Latin script to Latin script.
605
624
  - value: uniform
606
625
  description: Form of title in Library of Congress title authority.
626
+ - value: main
627
+ status: TEMP
628
+ - value: other title
629
+ status: TEMP
607
630
  title.note:
608
631
  - value: associated name
609
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_
@@ -119,7 +120,7 @@ _Path: event.date_
119
120
  * development: The creation of a print from a photographic negative or other source medium.
120
121
  * distribution: The delivery of the resource to an external audience.
121
122
  * generation: The creation of a resource by an automatic or natural process.
122
- * Hijiri calendar
123
+ * Hijri calendar
123
124
  * Islamic
124
125
  * Julian
125
126
  * letter: Athanasius
@@ -208,6 +209,7 @@ _Path: geographic.subject.structuredValue_
208
209
 
209
210
  # Identifier types
210
211
  _Path: identifier_
212
+ * accession
211
213
  * accession number
212
214
  * alternate case number
213
215
  * anchor
@@ -216,8 +218,11 @@ _Path: identifier_
216
218
  * arXiv
217
219
  * case identifier
218
220
  * case number
221
+ * CCP
222
+ * CLC
219
223
  * CSt
220
224
  * CStRLIN
225
+ * CTC
221
226
  * Data Provider Digital Object Identifier
222
227
  * document number
223
228
  * DOI
@@ -256,6 +261,10 @@ _Path: identifier_
256
261
  * videorecording identifier
257
262
  * West Mat \#
258
263
  * Wikidata
264
+ * Bodley 342
265
+ * vintage
266
+ * accesion
267
+ * Suri UUID
259
268
 
260
269
  # Note types
261
270
  _Path: note_
@@ -363,6 +372,7 @@ _Path: note_
363
372
  * version
364
373
  * version identification
365
374
  * writing
375
+ * note
366
376
 
367
377
  ## Note types for grouped value (MODS legacy)
368
378
  _Path: note.groupedValue_
@@ -410,6 +420,7 @@ _Path: subject_
410
420
  * time
411
421
  * title
412
422
  * topic
423
+ * surname
413
424
 
414
425
  ## Subject note types
415
426
  _Path: subject.note_
@@ -454,7 +465,6 @@ _Path: subject.structuredValue_
454
465
  * south
455
466
  * start
456
467
  * state
457
- * subtitle
458
468
  * surname
459
469
  * term of address
460
470
  * territory
@@ -481,6 +491,8 @@ _Path: title_
481
491
  * translated: Title translated into another language.
482
492
  * transliterated: Title transliterated from non-Latin script to Latin script.
483
493
  * uniform: Form of title in Library of Congress title authority.
494
+ * main
495
+ * other title
484
496
 
485
497
  ## Title note types
486
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.6'
5
+ VERSION = '0.74.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.73.6
4
+ version: 0.74.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -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