cocina-models 0.129.0 → 0.131.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: e825fe93a987da1a8c23ce57093eb0ee376229a605d4e7bb548e56cabb03fc86
4
- data.tar.gz: 542a860bd40cd64f31232cd4dfd0b65e2b8ae53dddc1f86597a0b86951d0327a
3
+ metadata.gz: 7896b08d2d0a1f99608ce6dfd4fe2a92cc0d9786f68f3f2eb971793444fd7194
4
+ data.tar.gz: 5dcbd075841e70fc116a0bc720411f52fb8823f1be2c401c7dcfa48ff50b9775
5
5
  SHA512:
6
- metadata.gz: 0a31ff1218930150d45c3457bd8f7915934416fae3ba9b37abbbc7acfea177e38943b9493d00335933ae9d7cde8a02def61a37780d805762fd9ac0f65fb6a46c
7
- data.tar.gz: bf0406a3f1d6267a40de10d1e747ac90bd9b57d75f11eeb33826b5161b7a7c46fcd84447f74e57b5b6e2e33c8313c7d493f5e0da682799a7bcf784bbc2c458e7
6
+ metadata.gz: 04cceeb51f7dbddb72946b4a668d87f4078b88bf2256b5a322d49a21eda870e9d832b648bf9f0ff9969b845fd0290236b14481dbde95c55cb1468cba3c09f8f9
7
+ data.tar.gz: 540ba204efa81c747c6ebbddd53f25452fcfa26a961d2bb3b123be9d90d0d7f2d0156207e7d8b5050d70ff095e59a74130850452a56954169e14f38bb7d81251
data/.gitignore CHANGED
@@ -10,7 +10,8 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
 
13
+ *.jsonl.zst
13
14
  *.jq.txt
14
15
  *.jsonl.xz
15
16
  *.csv
16
- *-playground.html
17
+ *-playground.html
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.129.0)
4
+ cocina-models (0.131.0)
5
5
  activesupport
6
6
  cocina_display
7
7
  deprecation
@@ -45,9 +45,9 @@ GEM
45
45
  iso8601 (~> 0.13.0)
46
46
  janeway-jsonpath (>= 0.6, < 2)
47
47
  zeitwerk (~> 2.7)
48
- concurrent-ruby (1.3.7)
48
+ concurrent-ruby (1.3.8)
49
49
  connection_pool (3.0.2)
50
- csv (3.3.5)
50
+ csv (3.3.6)
51
51
  debug (1.11.1)
52
52
  irb (~> 1.10)
53
53
  reline (>= 0.3.8)
@@ -81,7 +81,7 @@ GEM
81
81
  activesupport (>= 3.0, < 9.0)
82
82
  equivalent-xml (0.6.0)
83
83
  nokogiri (>= 1.4.3)
84
- erb (6.0.4)
84
+ erb (6.0.6)
85
85
  faraday (2.14.3)
86
86
  faraday-net_http (>= 2.0, < 3.5)
87
87
  json
@@ -101,9 +101,9 @@ GEM
101
101
  iso8601 (0.13.0)
102
102
  janeway-jsonpath (1.0.0)
103
103
  json (2.21.1)
104
- jsonschema_rs (0.47.0-arm64-darwin)
104
+ jsonschema_rs (0.49.1-arm64-darwin)
105
105
  bigdecimal (>= 3.1, < 5)
106
- jsonschema_rs (0.47.0-x86_64-linux)
106
+ jsonschema_rs (0.49.1-x86_64-linux)
107
107
  bigdecimal (>= 3.1, < 5)
108
108
  language_server-protocol (3.17.0.6)
109
109
  lint_roller (1.1.0)
@@ -119,7 +119,7 @@ GEM
119
119
  racc (~> 1.4)
120
120
  optimist (3.2.1)
121
121
  parallel (2.1.0)
122
- parser (3.3.11.1)
122
+ parser (3.3.12.0)
123
123
  ast (~> 2.4.1)
124
124
  racc
125
125
  patience_diff (1.2.0)
@@ -131,7 +131,7 @@ GEM
131
131
  racc (1.8.1)
132
132
  rainbow (3.1.1)
133
133
  rake (13.4.2)
134
- rbs (4.0.3)
134
+ rbs (4.1.0)
135
135
  logger
136
136
  prism (>= 1.6.0)
137
137
  tsort
@@ -184,7 +184,7 @@ GEM
184
184
  rubocop (~> 1.86, >= 1.86.2)
185
185
  ruby-progressbar (1.13.0)
186
186
  securerandom (0.4.1)
187
- simplecov (1.0.0)
187
+ simplecov (1.0.3)
188
188
  super_diff (0.19.0)
189
189
  attr_extras (>= 6.2.4, < 8)
190
190
  diff-lcs (~> 1.5)
@@ -225,12 +225,12 @@ CHECKSUMS
225
225
  base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
226
226
  bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
227
227
  builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
228
- bundler (4.0.16) sha256=d6ca5dd440c24f9abce9844cf44cc8e18c6a553de65a47efb4544137af92c47d
229
- cocina-models (0.129.0)
228
+ bundler (4.0.17) sha256=214e21431b5665dd2f99df8a5511c6b151d7a72e8015c8b38f8b775b61cbb6c1
229
+ cocina-models (0.131.0)
230
230
  cocina_display (2.9.0) sha256=00e97cf826dafd5c547ca87b58e55f1d3bfa68fa4ddcddbbe25b4d9d9ed05d8f
231
- concurrent-ruby (1.3.7) sha256=4412caec3a5ea2e5fdc52076724c071a81f2c0593d83b2ac8cbb8ca63b3151b0
231
+ concurrent-ruby (1.3.8) sha256=b2f1be836e968ccc78ccfce277ea79c72a88633f22306782c16ff23fb415d1e1
232
232
  connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
233
- csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f
233
+ csv (3.3.6) sha256=aba61e7e507a66f03d45cb1f3c4b6359861c3504038b422962875dce099e4456
234
234
  debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6
235
235
  deprecation (1.1.0) sha256=01707cea9a6ed2d7270377457941f43394a345e6dd8048e1be6d18ff2f2a01e1
236
236
  diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
@@ -242,7 +242,7 @@ CHECKSUMS
242
242
  dry-types (1.9.1) sha256=baebeecdb9f8395d6c9d227b62011279440943e3ef2468fe8ccc1ba11467f178
243
243
  edtf (3.3.0) sha256=0ce2b80f5cf222870e5a3df130701f4d24b75c29e23e5bf3130f574d75073487
244
244
  equivalent-xml (0.6.0) sha256=8919761efa848ad0846369ff8be1f646b17e5061698c4867b09829000cc3f487
245
- erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9
245
+ erb (6.0.6) sha256=a9b24986700f5bf127c4f297c5403c3ca41b83b0a316c0cd09a096b56e644ae5
246
246
  faraday (2.14.3) sha256=1882247e6766615c8220b4392bf1d27f6ebb63d8e28267587cef1fb0bf37f278
247
247
  faraday-net_http (3.4.4) sha256=0e78af151747ed1b00f33e25973b4bc220d7f16c00c39676817c8b12331eb588
248
248
  geo_coord (0.2.0) sha256=ae4e2dc5799deafa4db9138f3d7e85cf5e7dbd00b3b8395f1e1dbd34e007d7e8
@@ -253,8 +253,8 @@ CHECKSUMS
253
253
  iso8601 (0.13.0) sha256=298c2b15b7be5fa95a1372813d36a2257656cd8e906dfbc1f5cb409851425aa2
254
254
  janeway-jsonpath (1.0.0) sha256=c8293f009f2aea9487ddee3067ca735a1f758eb1c8834ff4fab3ffd06c56d0a3
255
255
  json (2.21.1) sha256=13a43df75d95641443f5702dff350f237164a9d811ff0f2c2800d4d980220583
256
- jsonschema_rs (0.47.0-arm64-darwin) sha256=ab3aae9da5796999d2686dfacaa2b4c9a5510b9194b4e4b73a6aa8767a78ac8a
257
- jsonschema_rs (0.47.0-x86_64-linux) sha256=5dfc5c14362cf5efee24242be23feb4342665f489b63e1eba4c256aac8c96047
256
+ jsonschema_rs (0.49.1-arm64-darwin) sha256=1c3a72c95f60e6c1dad6873b206eebaaa57ac947049675d0504bddc79be6db67
257
+ jsonschema_rs (0.49.1-x86_64-linux) sha256=de9c96bc0d68f818b1dd59fba09d954a13e02deaf2121aef803ad9c47dc3204b
258
258
  language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
259
259
  lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
260
260
  logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
@@ -264,7 +264,7 @@ CHECKSUMS
264
264
  nokogiri (1.19.4-x86_64-linux-gnu) sha256=379fae440b28915e3f19d752ce2dcf8465ed2b2fbefd2a7ca0dd497bc981a06a
265
265
  optimist (3.2.1) sha256=8cf8a0fd69f3aa24ab48885d3a666717c27bc3d9edd6e976e18b9d771e72e34e
266
266
  parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356
267
- parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54
267
+ parser (3.3.12.0) sha256=21a6d7f755d5a24dfbdc6e6b772e4e879a52e7631a88bc5a3a134606052c9828
268
268
  patience_diff (1.2.0) sha256=f492094486af02fff4a80070fa6b4d0ebbcf4d42fb38bba29d095eef43f6822c
269
269
  pp (0.6.4) sha256=dfcb0fce700c41456265922884f9fe195d7fbb0674a3578e6c0f69588e82b570
270
270
  prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
@@ -272,7 +272,7 @@ CHECKSUMS
272
272
  racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
273
273
  rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
274
274
  rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
275
- rbs (4.0.3) sha256=5a7bf70e2628549d9a1f44eae447b2cfe55968a9c60cfff52693a4bdcc020e14
275
+ rbs (4.1.0) sha256=8baba59008b0643b4ba2090e9b1d0149655b0bbd42eb2ffe42b1d0eb6923fd72
276
276
  rdoc (8.0.0) sha256=03bf8c08a9639658855a0cfd77c0abca8325c227693f7f33f82957811348c469
277
277
  regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb
278
278
  reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
@@ -289,7 +289,7 @@ CHECKSUMS
289
289
  rubocop-rspec (3.10.2) sha256=0b3e2ecc592cd10ecbf0095bb58d1e357905276e069643523cc19eb7495f65e2
290
290
  ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
291
291
  securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
292
- simplecov (1.0.0) sha256=bdc50b41fa4a8b3c860da4bf5d61ba4704479c51d08a8f53cbd56ae50778dca8
292
+ simplecov (1.0.3) sha256=38ef0514f16ae7562f0d0f4df02610071115103d301b6de7dacbcc000082e39b
293
293
  super_diff (0.19.0) sha256=c35fc1c0daa223d67b203fe3fb49a6cfd67850a53920319565c3c654e03ec902
294
294
  thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
295
295
  tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
@@ -300,4 +300,4 @@ CHECKSUMS
300
300
  zeitwerk (2.8.2) sha256=7212a61311083c604184b1ea2574b9aa05cd14f855a0841c06985cabe9181d12
301
301
 
302
302
  BUNDLED WITH
303
- 4.0.16
303
+ 4.0.17
data/README.md CHANGED
@@ -62,7 +62,7 @@ Beyond what is necessary to test the generator, the Cocina model classes are not
62
62
 
63
63
  ## Testing validation changes
64
64
 
65
- If there is a possibility that a model, mapping, or validation change will conflict with some existing objects then `bin/validate-data` should be used for testing. This operates on an export of objects from the repository and reports any validation errors. You may get the file by running the script [bin/export-cocina-head-versions](https://github.com/sul-dlss/dor-services-app#export-cocina-json-data) and downloading the data file to your computer. See the [DSA README](https://github.com/sul-dlss/dor-services-app#scheduled-cocina-json-data-exports) for more info about the files and locations. Running a full validation takes about 2 hours.
65
+ If there is a possibility that a model, mapping, or validation change will conflict with some existing objects then `bin/validate-data` should be used for testing. This operates on an export of objects from the repository and reports any validation errors. You may get the file by running the script [bin/export-cocina-head-versions](https://github.com/sul-dlss/dor-services-app#export-cocina-json-data) and downloading the data file to your computer. See the [DSA README](https://github.com/sul-dlss/dor-services-app#scheduled-cocina-json-data-exports) for more info about the files and locations. Running a full validation takes about 2 hours.
66
66
 
67
67
 
68
68
  Alternatively, you can use [validate-cocina](https://github.com/sul-dlss/dor-services-app/blob/main/bin/validate-cocina) for testing. This must be run on the `sdr-infra` VM since it requires deploying a branch of cocina-models. It is slower than using `bin/validate-data`, but all of the data is completely up to date.
@@ -70,7 +70,8 @@ Alternatively, you can use [validate-cocina](https://github.com/sul-dlss/dor-ser
70
70
  For background on object validation, as it relates to migrating versions, see: https://github.com/sul-dlss/dor-services-app/wiki/Migrating-Cocina
71
71
 
72
72
  1. Create a cocina-models branch containing the proposed change and push to GitHub.
73
- 2. On the `sdr-infra` VM, while logged in as the `deploy` user, check out `main`, update the `Gemfile` so that cocina-models references the branch, and `bundle install`.
73
+ 2. On the `sdr-infra` VM, while logged in as the `deploy` user, check out `main`, update the `Gemfile` so that cocina-models references the branch, and `bundle install`, e.g.
74
+ gem 'cocina-models', git: 'https://github.com/sul-dlss/cocina-models', branch: 'my-branch'
74
75
  3. Select the appropriate environment vars below - they are set to values in puppet. (first 2 lines are the same; last two lines use different variables)
75
76
 
76
77
  For QA:
@@ -109,6 +110,11 @@ export RUBYOPT='-W:no-deprecated -W:no-experimental'
109
110
  RAILS_ENV=production bin/validate-cocina -p 8 -l
110
111
  ```
111
112
 
113
+ To run against only a specific list of druids, pass in a CSV file with druids in the first column and no header (druids should have the "druid:" prefix). This matches the format that comes from the `bin/validate-data` script in cocina-models repo, so you can the use the CSV file and re-run against just those objects once they have been remediated.
114
+ ```
115
+ RAILS_ENV=production bin/validate-cocina -f validate-data-errors.csv
116
+ ```
117
+
112
118
  5. Check `validate-cocina.csv` for validation errors.
113
119
 
114
120
  ## Running Reports in DSA
@@ -0,0 +1,15 @@
1
+ # Language Code and Term Source Codes
2
+ # Source: https://www.loc.gov/standards/sourcelist/language.html
3
+ - austlang
4
+ - din2335
5
+ - glotto
6
+ - iso639-1
7
+ - iso639-2b
8
+ - iso639-3
9
+ - iso639-5
10
+ - knia
11
+ - lrwl
12
+ - rfc3066
13
+ - rfc4646
14
+ - rfc5646
15
+ - walso
@@ -15,11 +15,10 @@ module Cocina
15
15
  attribute :type, Types::Strict::String.enum(*AdminPolicy::TYPES)
16
16
  # example: druid:bc123df4567
17
17
  attribute :externalIdentifier, Druid
18
- attribute? :label, Types::Strict::String.default('')
19
18
  attribute :version, Types::Strict::Integer
20
19
  # Administrative properties for an AdminPolicy
21
20
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
22
- attribute? :description, Description.optional
21
+ attribute(:description, Description.default { Description.new })
23
22
  end
24
23
  end
25
24
  end
@@ -13,7 +13,6 @@ module Cocina
13
13
  attribute :type, Types::Strict::String.enum(*AdminPolicyLite::TYPES)
14
14
  # example: druid:bc123df4567
15
15
  attribute :externalIdentifier, Druid
16
- attribute? :label, Types::Strict::String.default('')
17
16
  attribute :version, Types::Strict::Integer
18
17
  # Administrative properties for an AdminPolicy
19
18
  # Validation of this property is relaxed. See the schema.json for full validation.
@@ -16,11 +16,10 @@ module Cocina
16
16
  attribute :type, Types::Strict::String.enum(*AdminPolicyWithMetadata::TYPES)
17
17
  # example: druid:bc123df4567
18
18
  attribute :externalIdentifier, Druid
19
- attribute? :label, Types::Strict::String.default('')
20
19
  attribute :version, Types::Strict::Integer
21
20
  # Administrative properties for an AdminPolicy
22
21
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
23
- attribute? :description, Description.optional
22
+ attribute(:description, Description.default { Description.new })
24
23
  # When the object was created.
25
24
  attribute? :created, Types::Params::DateTime
26
25
  # When the object was modified.
@@ -22,8 +22,6 @@ module Cocina
22
22
  attribute :type, Types::Strict::String.enum(*Collection::TYPES)
23
23
  # example: druid:bc123df4567
24
24
  attribute :externalIdentifier, Druid
25
- # Primary processing label (can be same as title) for a Collection.
26
- attribute? :label, Types::Strict::String.default('')
27
25
  # Version for the Collection within SDR.
28
26
  attribute :version, Types::Strict::Integer
29
27
  # Access metadata for collections
@@ -20,8 +20,6 @@ module Cocina
20
20
  attribute :type, Types::Strict::String.enum(*CollectionLite::TYPES)
21
21
  # example: druid:bc123df4567
22
22
  attribute :externalIdentifier, Druid
23
- # Primary processing label (can be same as title) for a Collection.
24
- attribute? :label, Types::Strict::String.default('')
25
23
  # Version for the Collection within SDR.
26
24
  attribute :version, Types::Strict::Integer
27
25
  # Access metadata for collections
@@ -21,8 +21,6 @@ module Cocina
21
21
  attribute :type, Types::Strict::String.enum(*CollectionWithMetadata::TYPES)
22
22
  # example: druid:bc123df4567
23
23
  attribute :externalIdentifier, Druid
24
- # Primary processing label (can be same as title) for a Collection.
25
- attribute? :label, Types::Strict::String.default('')
26
24
  # Version for the Collection within SDR.
27
25
  attribute :version, Types::Strict::Integer
28
26
  # Access metadata for collections
@@ -32,8 +32,6 @@ module Cocina
32
32
  attribute :type, Types::Strict::String.enum(*DRO::TYPES)
33
33
  # example: druid:bc123df4567
34
34
  attribute :externalIdentifier, Druid
35
- # Primary processing label (can be same as title) for a DRO.
36
- attribute? :label, Types::Strict::String.default('')
37
35
  # Version for the DRO within SDR.
38
36
  attribute :version, Types::Strict::Integer
39
37
  attribute(:access, DROAccess.default { DROAccess.new })
@@ -30,8 +30,6 @@ module Cocina
30
30
  attribute :type, Types::Strict::String.enum(*DROLite::TYPES)
31
31
  # example: druid:bc123df4567
32
32
  attribute :externalIdentifier, Druid
33
- # Primary processing label (can be same as title) for a DRO.
34
- attribute? :label, Types::Strict::String.default('')
35
33
  # Version for the DRO within SDR.
36
34
  attribute :version, Types::Strict::Integer
37
35
  # Validation of this property is relaxed. See the schema.json for full validation.
@@ -31,8 +31,6 @@ module Cocina
31
31
  attribute :type, Types::Strict::String.enum(*DROWithMetadata::TYPES)
32
32
  # example: druid:bc123df4567
33
33
  attribute :externalIdentifier, Druid
34
- # Primary processing label (can be same as title) for a DRO.
35
- attribute? :label, Types::Strict::String.default('')
36
34
  # Version for the DRO within SDR.
37
35
  attribute :version, Types::Strict::Integer
38
36
  attribute(:access, DROAccess.default { DROAccess.new })
@@ -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
@@ -11,20 +11,18 @@ module Cocina
11
11
 
12
12
  # @param [Nokogiri::XML] mods
13
13
  # @param [String] druid
14
- # @oaram [String] label
15
14
  # @param [TitleBuilder] title_builder - defaults to Title class
16
15
  # @param [Cocina::Models::Mapping::ErrorNotifier] notifier
17
16
  # @return [Hash] a hash that can be mapped to a cocina descriptive model
18
- def self.props(mods:, druid:, label:, title_builder: Title, notifier: nil)
19
- new(title_builder: title_builder, mods: mods, druid: druid, label: label, notifier: notifier).props
17
+ def self.props(mods:, druid:, title_builder: Title, notifier: nil)
18
+ new(title_builder: title_builder, mods: mods, druid: druid, notifier: notifier).props
20
19
  end
21
20
 
22
- def initialize(title_builder:, mods:, label:, druid:, notifier:)
21
+ def initialize(title_builder:, mods:, druid:, notifier:)
23
22
  @title_builder = title_builder
24
23
  @ng_xml = mods
25
24
  @notifier = notifier || ErrorNotifier.new(druid: druid)
26
25
  @druid = druid
27
- @label = label
28
26
  end
29
27
 
30
28
  # @return [Hash] a hash that can be mapped to a cocina descriptive model
@@ -34,17 +32,15 @@ module Cocina
34
32
 
35
33
  check_altrepgroups
36
34
  check_version
37
- props = DescriptionBuilder.build(title_builder: title_builder,
38
- resource_element: ng_xml.root,
39
- notifier: notifier,
40
- purl: druid ? Cocina::Models::Mapping::Purl.for(druid: druid) : nil)
41
- props[:title] = [{ value: label }] unless props.key?(:title)
42
- props
35
+ DescriptionBuilder.build(title_builder: title_builder,
36
+ resource_element: ng_xml.root,
37
+ notifier: notifier,
38
+ purl: druid ? Cocina::Models::Mapping::Purl.for(druid: druid) : nil)
43
39
  end
44
40
 
45
41
  private
46
42
 
47
- attr_reader :title_builder, :ng_xml, :notifier, :druid, :label
43
+ attr_reader :title_builder, :ng_xml, :notifier, :druid
48
44
 
49
45
  def check_altrepgroups
50
46
  ng_xml.xpath('//mods:*[@altRepGroup]', mods: DESC_METADATA_NS)
@@ -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)
@@ -14,7 +14,6 @@ module Cocina
14
14
  # example: 1.2.3
15
15
  attribute :cocinaVersion, CocinaVersion.default(VERSION)
16
16
  attribute :type, Types::Strict::String.enum(*RequestAdminPolicy::TYPES)
17
- attribute? :label, Types::Strict::String.default('')
18
17
  attribute :version, Types::Strict::Integer.default(1).enum(1)
19
18
  # Administrative properties for an AdminPolicy
20
19
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
@@ -18,7 +18,6 @@ module Cocina
18
18
  # example: 1.2.3
19
19
  attribute :cocinaVersion, CocinaVersion.default(VERSION)
20
20
  attribute :type, Types::Strict::String.enum(*RequestCollection::TYPES)
21
- attribute? :label, Types::Strict::String.default('')
22
21
  attribute :version, Types::Strict::Integer.default(1).enum(1)
23
22
  # Access metadata for collections
24
23
  attribute(:access, CollectionAccess.default { CollectionAccess.new })
@@ -30,7 +30,6 @@ module Cocina
30
30
  # example: 1.2.3
31
31
  attribute :cocinaVersion, CocinaVersion.default(VERSION)
32
32
  attribute :type, Types::Strict::String.enum(*RequestDRO::TYPES)
33
- attribute? :label, Types::Strict::String.default('')
34
33
  attribute :version, Types::Strict::Integer.default(1).enum(1)
35
34
  attribute? :access, DROAccess.optional
36
35
  attribute(:administrative, RequestAdministrative.default { RequestAdministrative.new })
@@ -20,6 +20,7 @@ module Cocina
20
20
  DescriptionSubjectTemporalEncodingVisitorValidator,
21
21
  DescriptionTitleSourceCodeVisitorValidator,
22
22
  DescriptionLanguageUriVisitorValidator,
23
+ DescriptionLanguageSourceCodeVisitorValidator,
23
24
  DescriptionScriptVisitorValidator,
24
25
  DescriptionLocationVisitorValidator
25
26
  ].freeze
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ module Validators
6
+ # Validates language.source.code and valueLanguage.source.code values against language_source_codes.yml.
7
+ class DescriptionLanguageSourceCodeVisitorValidator < BaseDescriptionVisitorValidator
8
+ def validate!
9
+ return if error_paths.empty?
10
+
11
+ raise ValidationError, "Unrecognized language source codes in description: #{error_paths.join(', ')}"
12
+ end
13
+
14
+ def visit_hash(hash:, path:)
15
+ return unless language_or_value_language_path?(path)
16
+
17
+ source_code = hash.dig(:source, :code)
18
+ return unless source_code
19
+ return if valid_codes.include?(source_code.downcase)
20
+
21
+ error_paths << "#{path_to_s(path)}.source.code (#{source_code})"
22
+ end
23
+
24
+ private
25
+
26
+ def error_paths
27
+ @error_paths ||= []
28
+ end
29
+
30
+ def language_or_value_language_path?(path)
31
+ language_path?(path) || value_language_path?(path)
32
+ end
33
+
34
+ def language_path?(path)
35
+ # language is a typed array (Array.of(Language)), so the visitor descends through
36
+ # an integer index. Path ends with [:language, <Integer>].
37
+ path.length >= 2 && path[-1].is_a?(Integer) && path[-2].to_s == 'language'
38
+ end
39
+
40
+ def value_language_path?(path)
41
+ # valueLanguage is a single optional hash (not an array), so the visitor descends
42
+ # directly by key. Path ends with [:valueLanguage].
43
+ path.length >= 1 && path[-1].to_s == 'valueLanguage'
44
+ end
45
+
46
+ # rubocop:disable Style/ClassVars
47
+ def valid_codes
48
+ @@valid_codes ||= YAML.load_file(::File.expand_path('../../../../language_source_codes.yml', __dir__)).to_set(&:downcase)
49
+ end
50
+ # rubocop:enable Style/ClassVars
51
+ end
52
+ end
53
+ end
54
+ end
@@ -41,7 +41,7 @@ module Cocina
41
41
  # Some part of the path are ignored for the purpose of matching.
42
42
  def clean_path(path)
43
43
  new_path = path.reject do |part|
44
- part.is_a?(Integer) || %i[parallelValue parallelEvent].include?(part.to_sym)
44
+ part.is_a?(Integer) || %i[parallelValue].include?(part.to_sym)
45
45
  end.map(&:to_sym)
46
46
  # This needs to happen after parallelValue is removed
47
47
  # to handle structuredValue > parallelValue > structuredValue
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ module Validators
6
+ # Validates that not all titles have type 'alternative'
7
+ class NonAlternativeTitleValidator
8
+ def self.validate(...)
9
+ new(...).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 unless titles.all? { |title| title[:type] == 'alternative' }
21
+
22
+ raise ValidationError, "At least one title must have no type or a type other than 'alternative'."
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :clazz, :attributes
28
+
29
+ def meets_preconditions?
30
+ [Cocina::Models::Description, Cocina::Models::RequestDescription].include?(clazz) &&
31
+ titles.present?
32
+ end
33
+
34
+ def titles
35
+ @titles ||= Array(attributes[:title])
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -12,7 +12,8 @@ module Cocina
12
12
  PurlValidator,
13
13
  CatalogLinksValidator,
14
14
  AssociatedNameValidator,
15
- MarcRelatorRoleValidator
15
+ MarcRelatorRoleValidator,
16
+ NonAlternativeTitleValidator
16
17
  ].freeze
17
18
 
18
19
  def self.validate(clazz, attributes, validators: VALIDATORS)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.129.0'
5
+ VERSION = '0.131.0'
6
6
  end
7
7
  end
data/schema.json CHANGED
@@ -106,10 +106,6 @@
106
106
  "externalIdentifier": {
107
107
  "$ref": "#/$defs/Druid"
108
108
  },
109
- "label": {
110
- "type": "string",
111
- "default": ""
112
- },
113
109
  "version": {
114
110
  "type": "integer"
115
111
  },
@@ -125,7 +121,8 @@
125
121
  "administrative",
126
122
  "externalIdentifier",
127
123
  "type",
128
- "version"
124
+ "version",
125
+ "description"
129
126
  ]
130
127
  },
131
128
  "AdminPolicy": {
@@ -372,11 +369,6 @@
372
369
  "externalIdentifier": {
373
370
  "$ref": "#/$defs/Druid"
374
371
  },
375
- "label": {
376
- "description": "Primary processing label (can be same as title) for a Collection.",
377
- "type": "string",
378
- "default": ""
379
- },
380
372
  "version": {
381
373
  "description": "Version for the Collection within SDR.",
382
374
  "type": "integer"
@@ -645,11 +637,6 @@
645
637
  ]
646
638
  },
647
639
  "externalIdentifier": { "$ref": "#/$defs/Druid" },
648
- "label": {
649
- "description": "Primary processing label (can be same as title) for a DRO.",
650
- "type": "string",
651
- "default": ""
652
- },
653
640
  "version": {
654
641
  "description": "Version for the DRO within SDR.",
655
642
  "type": "integer"
@@ -1270,70 +1257,6 @@
1270
1257
  }
1271
1258
  }
1272
1259
  },
1273
- "DescriptiveParallelEvent": {
1274
- "description": "Value model for multiple representations of information about the same event (e.g. in different languages).",
1275
- "type": "object",
1276
- "allOf": [
1277
- {
1278
- "$ref": "#/$defs/DescriptiveStructuredValue"
1279
- },
1280
- {
1281
- "type": "object",
1282
- "properties": {
1283
- "type": {
1284
- "description": "Description of the event (creation, publication, etc.).",
1285
- "type": "string"
1286
- },
1287
- "displayLabel": {
1288
- "description": "The preferred display label to use for the event in access systems.",
1289
- "type": [
1290
- "string",
1291
- "null"
1292
- ]
1293
- },
1294
- "date": {
1295
- "description": "Dates associated with the event.",
1296
- "type": "array",
1297
- "items": {
1298
- "$ref": "#/$defs/DescriptiveValue"
1299
- }
1300
- },
1301
- "contributor": {
1302
- "description": "Contributors associated with the event.",
1303
- "type": "array",
1304
- "items": {
1305
- "$ref": "#/$defs/Contributor"
1306
- }
1307
- },
1308
- "location": {
1309
- "description": "Locations associated with the event.",
1310
- "type": "array",
1311
- "items": {
1312
- "$ref": "#/$defs/DescriptiveValue"
1313
- }
1314
- },
1315
- "identifier": {
1316
- "description": "Identifiers and URIs associated with the event.",
1317
- "type": "array",
1318
- "items": {
1319
- "$ref": "#/$defs/DescriptiveIdentifier"
1320
- }
1321
- },
1322
- "note": {
1323
- "description": "Other information about the event.",
1324
- "type": "array",
1325
- "items": {
1326
- "$ref": "#/$defs/DescriptiveValue"
1327
- }
1328
- },
1329
- "valueLanguage": {
1330
- "$ref": "#/$defs/DescriptiveValueLanguage"
1331
- }
1332
- }
1333
- }
1334
- ],
1335
- "unevaluatedProperties": false
1336
- },
1337
1260
  "DescriptiveParallelValue": {
1338
1261
  "description": "Value model for multiple representations of the same information (e.g. in different languages).",
1339
1262
  "type": "object",
@@ -1529,13 +1452,6 @@
1529
1452
  },
1530
1453
  "valueLanguage": {
1531
1454
  "$ref": "#/$defs/DescriptiveValueLanguage"
1532
- },
1533
- "parallelEvent": {
1534
- "description": "For multiple representations of information about the same event (e.g. in different languages)",
1535
- "type": "array",
1536
- "items": {
1537
- "$ref": "#/$defs/DescriptiveParallelEvent"
1538
- }
1539
1455
  }
1540
1456
  }
1541
1457
  }
@@ -1589,14 +1505,6 @@
1589
1505
  "minItems": 1
1590
1506
  }
1591
1507
  }
1592
- },
1593
- {
1594
- "required": ["parallelEvent"],
1595
- "properties": {
1596
- "parallelEvent": {
1597
- "minItems": 1
1598
- }
1599
- }
1600
1508
  }
1601
1509
  ]
1602
1510
  },
@@ -2525,10 +2433,6 @@
2525
2433
  "https://cocina.sul.stanford.edu/models/admin_policy"
2526
2434
  ]
2527
2435
  },
2528
- "label": {
2529
- "type": "string",
2530
- "default": ""
2531
- },
2532
2436
  "version": {
2533
2437
  "type": "integer",
2534
2438
  "default": 1,
@@ -2597,10 +2501,6 @@
2597
2501
  "https://cocina.sul.stanford.edu/models/series"
2598
2502
  ]
2599
2503
  },
2600
- "label": {
2601
- "type": "string",
2602
- "default": ""
2603
- },
2604
2504
  "version": {
2605
2505
  "type": "integer",
2606
2506
  "default": 1,
@@ -2698,10 +2598,6 @@
2698
2598
  "https://cocina.sul.stanford.edu/models/webarchive-seed"
2699
2599
  ]
2700
2600
  },
2701
- "label": {
2702
- "type": "string",
2703
- "default": ""
2704
- },
2705
2601
  "version": {
2706
2602
  "type": "integer",
2707
2603
  "default": 1,
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.129.0
4
+ version: 0.131.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -329,6 +329,7 @@ files:
329
329
  - form_source_codes.yml
330
330
  - identifier_source_codes.yml
331
331
  - iso15924_codes.yml
332
+ - language_source_codes.yml
332
333
  - language_uri_iso639_2_codes.yml
333
334
  - language_uri_languages_codes.yml
334
335
  - lib/cocina/generator.rb
@@ -382,7 +383,6 @@ files:
382
383
  - lib/cocina/models/descriptive_geographic_metadata.rb
383
384
  - lib/cocina/models/descriptive_grouped_value.rb
384
385
  - lib/cocina/models/descriptive_identifier.rb
385
- - lib/cocina/models/descriptive_parallel_event.rb
386
386
  - lib/cocina/models/descriptive_parallel_value.rb
387
387
  - lib/cocina/models/descriptive_structured_value.rb
388
388
  - lib/cocina/models/descriptive_value.rb
@@ -442,7 +442,6 @@ files:
442
442
  - lib/cocina/models/mapping/from_mods/subject_authority_codes.rb
443
443
  - lib/cocina/models/mapping/from_mods/title.rb
444
444
  - lib/cocina/models/mapping/from_mods/title_builder.rb
445
- - lib/cocina/models/mapping/from_mods/title_builder_strategy.rb
446
445
  - lib/cocina/models/mapping/from_mods/value_uri.rb
447
446
  - lib/cocina/models/mapping/purl.rb
448
447
  - lib/cocina/models/message_digest.rb
@@ -489,6 +488,7 @@ files:
489
488
  - lib/cocina/models/validators/description_form_source_code_visitor_validator.rb
490
489
  - lib/cocina/models/validators/description_identifier_source_code_visitor_validator.rb
491
490
  - lib/cocina/models/validators/description_language_code_visitor_validator.rb
491
+ - lib/cocina/models/validators/description_language_source_code_visitor_validator.rb
492
492
  - lib/cocina/models/validators/description_language_uri_visitor_validator.rb
493
493
  - lib/cocina/models/validators/description_location_visitor_validator.rb
494
494
  - lib/cocina/models/validators/description_name_source_code_visitor_validator.rb
@@ -503,6 +503,7 @@ files:
503
503
  - lib/cocina/models/validators/language_tag_visitor_validator.rb
504
504
  - lib/cocina/models/validators/marc_date_validator.rb
505
505
  - lib/cocina/models/validators/marc_relator_role_validator.rb
506
+ - lib/cocina/models/validators/non_alternative_title_validator.rb
506
507
  - lib/cocina/models/validators/purl_validator.rb
507
508
  - lib/cocina/models/validators/reserved_filename_visitor_validator.rb
508
509
  - lib/cocina/models/validators/validator.rb
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cocina
4
- module Models
5
- # Value model for multiple representations of information about the same event (e.g.
6
- # in different languages).
7
- class DescriptiveParallelEvent < Struct
8
- attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
9
- # Description of the event (creation, publication, etc.).
10
- attribute? :type, Types::Strict::String
11
- # The preferred display label to use for the event in access systems.
12
- attribute? :displayLabel, Types::Strict::String.optional
13
- # Dates associated with the event.
14
- attribute :date, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
15
- # Contributors associated with the event.
16
- attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
17
- # Locations associated with the event.
18
- attribute :location, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
19
- # Identifiers and URIs associated with the event.
20
- attribute :identifier, Types::Strict::Array.of(DescriptiveIdentifier).default([].freeze)
21
- # Other information about the event.
22
- attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
23
- # Language of the descriptive element value
24
- attribute? :valueLanguage, DescriptiveValueLanguage.optional
25
- end
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cocina
4
- module Models
5
- module Mapping
6
- module FromMods
7
- # Decides how to build a title based on whether this is a registered Hydrus object or not.
8
- class TitleBuilderStrategy
9
- # @param [String] label
10
- # @return [#build] a class that can build a title
11
- def self.find(label:)
12
- # Some hydrus items don't have titles, so using label. See https://github.com/sul-dlss/hydrus/issues/421
13
- label == 'Hydrus' ? HydrusDefaultTitleBuilder : Title
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end