cocina-models 0.53.0 → 0.55.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: 328b1cc6267ee00ff250c1a255e1639cd99ee687e31ef1eb3644bae1b2b32435
4
- data.tar.gz: 0131a0371050510c23a902c5e5dc14c848bb828b00bc3408bd74757c258d4642
3
+ metadata.gz: fbed8aec9255570088565182862681d94908cb165e5f6be489ad103052a5f708
4
+ data.tar.gz: 526b172620cbe31ea3ca59871d0ed0a816bec3c01726214fd3634bf54ec24eba
5
5
  SHA512:
6
- metadata.gz: 98649a23bc16e020e6b8fff14d2ecd86978843ddd113aaafb6857f0dd525c735dc46522a71a3747bc3ac56018578dd1514777ffa8bfb7fcfd965f8fcd8b51f16
7
- data.tar.gz: 40508d78201cc8438abea8f5dfcdd04a013df6874bc788d31eb380fd135476defe3643eda79c908c5fdaac6102b0e079c2d779cab976e6262479d6e30bfc4068
6
+ metadata.gz: 6a555879230729f246d468589fb3e5ec261cebc36ae17d1282b663ef1b0ff0a5bd4afc9e9ee9688978da98bf20e7f709f989a6b46934a103ad0fabe40ee2353a
7
+ data.tar.gz: 332f3a59c67779ccb81340a352baa9894e9c3c76cbf5ff2bed383b501c5ff9ec7fb6e1d80aa3610b9a3ee289448a6b93e59e50345bd97b7f9279acf684191db3
data/README.md CHANGED
@@ -66,3 +66,12 @@ Once the above listed gems are updated all the following services that use cocin
66
66
  If you are using this gem in an application that has an API that accepts Cocina models (e.g., SDR API, Dor-Services-App), make sure that the `openapi.yml` for the application includes the schemas that match the schemas in this `openapi.yml`.
67
67
 
68
68
  This can be accomplished by cutting and pasting these schemas. By convention, these schemas are listed first in the `openapi.yml` of the associated projects, followed by the application-specific schemas.
69
+
70
+ ### Usage conventions
71
+
72
+ The following are the recommended naming conventions for code using Cocina models:
73
+
74
+ * cocina_item: Cocina::Models::DRO instance
75
+ * cocina_admin_policy: Cocina::Models::AdminPolicy instance
76
+ * cocina_collection: Cocina::Models::Collection instance
77
+ * cocina_object: Cocina::Models::DRO or Cocina::Models::AdminPolicy or Cocina::Models::Collection instance
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'fileutils'
4
+
3
5
  module Cocina
4
6
  module Generator
5
7
  # Class for generating Cocina models from openapi.
@@ -33,23 +33,40 @@ module Cocina
33
33
 
34
34
  attr_reader :schemas
35
35
 
36
- # rubocop:disable Style/MultilineBlockChain
36
+ BASE = 'http://cocina.sul.stanford.edu/models/'
37
+
37
38
  def vocabs
38
- schemas.values.map do |schema|
39
- type_property = schema.properties['type']
40
- type_property.nil? ? [] : type_property.enum.to_a
41
- end
42
- .flatten
43
- .uniq
44
- .sort
45
- .filter { |vocab| vocab.start_with?('http://cocina.sul.stanford.edu/models') }
39
+ type_properties = schemas.values.map { |schema| schema.properties['type'] }.compact
40
+ type_properties.map(&:enum).flat_map(&:to_a)
41
+ .filter { |vocab| vocab.start_with?(BASE) }
42
+ .uniq
43
+ .sort
46
44
  end
47
- # rubocop:enable Style/MultilineBlockChain
48
45
 
49
46
  def vocab_methods
50
- # Note special handling of 3d
51
- vocabs.map do |vocab|
52
- name = vocab[38, vocab.size - 45].gsub('-', '_').gsub('3d', 'three_dimensional')
47
+ names = vocabs.each_with_object({}) do |vocab, object|
48
+ # Note special handling of 3d
49
+ namespaced = vocab.delete_prefix(BASE).delete_suffix('.jsonld')
50
+ .gsub('-', '_').gsub('3d', 'three_dimensional')
51
+ namespace, name = namespaced.include?('/') ? namespaced.split('/') : [:root, namespaced]
52
+ object[namespace] ||= {}
53
+ object[namespace][name] = vocab
54
+ end
55
+ draw_namespaced_methods(names)
56
+ end
57
+
58
+ def draw_namespaced_methods(names)
59
+ names.flat_map do |namespace, methods|
60
+ [].tap do |items|
61
+ items << "class #{namespace.capitalize}" unless namespace == :root
62
+ items << draw_ruby_methods(methods)
63
+ items << 'end' unless namespace == :root
64
+ end
65
+ end.join("\n")
66
+ end
67
+
68
+ def draw_ruby_methods(methods)
69
+ methods.map do |name, vocab|
53
70
  <<~RUBY
54
71
  def self.#{name}
55
72
  "#{vocab}"
@@ -4,7 +4,7 @@ module Cocina
4
4
  module Models
5
5
  class AccessRole < Struct
6
6
  # Name of role
7
- attribute :name, Types::Strict::String.enum('sdr-administrator', 'sdr-viewer', 'dor-apo-manager', 'hydrus-collection-creator', 'hydrus-collection-manager', 'hydrus-collection-depositor', 'hydrus-collection-item-depositor', 'hydrus-collection-reviewer', 'hydrus-collection-viewer')
7
+ attribute :name, Types::Strict::String.enum('dor-apo-creator', 'dor-apo-depositor', 'dor-apo-manager', 'dor-apo-metadata', 'dor-apo-reviewer', 'dor-apo-viewer', 'sdr-administrator', 'sdr-viewer', 'hydrus-collection-creator', 'hydrus-collection-manager', 'hydrus-collection-depositor', 'hydrus-collection-item-depositor', 'hydrus-collection-reviewer', 'hydrus-collection-viewer')
8
8
  attribute :members, Types::Strict::Array.of(AccessRoleMember).default([].freeze)
9
9
  end
10
10
  end
@@ -13,6 +13,7 @@ module Cocina
13
13
  attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
14
14
  # URL or other pointer to the location of the contributor information.
15
15
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
16
+ attribute :parallelContributor, Types::Strict::Array.of(DescriptiveParallelContributor).meta(omittable: true)
16
17
  end
17
18
  end
18
19
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class DescriptiveParallelContributor < Struct
6
+ attribute :name, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
7
+ # Entity type of the contributor (person, organization, etc.).
8
+ attribute :type, Types::Strict::String.meta(omittable: true)
9
+ # Status of the contributor relative to other parallel contributors (e.g. the primary author among a group of contributors).
10
+ attribute :status, Types::Strict::String.meta(omittable: true)
11
+ attribute :role, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
12
+ attribute :identifier, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
13
+ attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
14
+ # URL or other pointer to the location of the contributor information.
15
+ attribute :valueAt, Types::Strict::String.meta(omittable: true)
16
+ attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)
17
+ end
18
+ end
19
+ end
@@ -3,6 +3,7 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class FileAdministrative < Struct
6
+ attribute :publish, Types::Strict::Bool.default(false)
6
7
  attribute :sdrPreserve, Types::Strict::Bool.default(true)
7
8
  attribute :shelve, Types::Strict::Bool.default(false)
8
9
  end
@@ -5,7 +5,22 @@ module Cocina
5
5
  class FileSet < Struct
6
6
  include Checkable
7
7
 
8
- TYPES = ['http://cocina.sul.stanford.edu/models/fileset.jsonld'].freeze
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/resources/audio.jsonld',
9
+ 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld',
10
+ 'http://cocina.sul.stanford.edu/models/resources/document.jsonld',
11
+ 'http://cocina.sul.stanford.edu/models/resources/file.jsonld',
12
+ 'http://cocina.sul.stanford.edu/models/resources/image.jsonld',
13
+ 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld',
14
+ 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld',
15
+ 'http://cocina.sul.stanford.edu/models/resources/media.jsonld',
16
+ 'http://cocina.sul.stanford.edu/models/resources/object.jsonld',
17
+ 'http://cocina.sul.stanford.edu/models/resources/page.jsonld',
18
+ 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld',
19
+ 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld',
20
+ 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld',
21
+ 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld',
22
+ 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld',
23
+ 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'].freeze
9
24
 
10
25
  # The content type of the Fileset.
11
26
  attribute :type, Types::Strict::String.enum(*FileSet::TYPES)
@@ -5,7 +5,22 @@ module Cocina
5
5
  class RequestFileSet < Struct
6
6
  include Checkable
7
7
 
8
- TYPES = ['http://cocina.sul.stanford.edu/models/fileset.jsonld'].freeze
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/resources/audio.jsonld',
9
+ 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld',
10
+ 'http://cocina.sul.stanford.edu/models/resources/document.jsonld',
11
+ 'http://cocina.sul.stanford.edu/models/resources/file.jsonld',
12
+ 'http://cocina.sul.stanford.edu/models/resources/image.jsonld',
13
+ 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld',
14
+ 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld',
15
+ 'http://cocina.sul.stanford.edu/models/resources/media.jsonld',
16
+ 'http://cocina.sul.stanford.edu/models/resources/object.jsonld',
17
+ 'http://cocina.sul.stanford.edu/models/resources/page.jsonld',
18
+ 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld',
19
+ 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld',
20
+ 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld',
21
+ 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld',
22
+ 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld',
23
+ 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'].freeze
9
24
 
10
25
  attribute :type, Types::Strict::String.enum(*RequestFileSet::TYPES)
11
26
  attribute :label, Types::Strict::String
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.53.0'
5
+ VERSION = '0.55.0'
6
6
  end
7
7
  end
@@ -40,10 +40,6 @@ module Cocina
40
40
  'http://cocina.sul.stanford.edu/models/file.jsonld'
41
41
  end
42
42
 
43
- def self.fileset
44
- 'http://cocina.sul.stanford.edu/models/fileset.jsonld'
45
- end
46
-
47
43
  def self.geo
48
44
  'http://cocina.sul.stanford.edu/models/geo.jsonld'
49
45
  end
@@ -95,6 +91,72 @@ module Cocina
95
91
  def self.webarchive_seed
96
92
  'http://cocina.sul.stanford.edu/models/webarchive-seed.jsonld'
97
93
  end
94
+
95
+ class Resources
96
+ def self.three_dimensional
97
+ 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld'
98
+ end
99
+
100
+ def self.attachment
101
+ 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld'
102
+ end
103
+
104
+ def self.audio
105
+ 'http://cocina.sul.stanford.edu/models/resources/audio.jsonld'
106
+ end
107
+
108
+ def self.document
109
+ 'http://cocina.sul.stanford.edu/models/resources/document.jsonld'
110
+ end
111
+
112
+ def self.file
113
+ 'http://cocina.sul.stanford.edu/models/resources/file.jsonld'
114
+ end
115
+
116
+ def self.image
117
+ 'http://cocina.sul.stanford.edu/models/resources/image.jsonld'
118
+ end
119
+
120
+ def self.main_augmented
121
+ 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld'
122
+ end
123
+
124
+ def self.main_original
125
+ 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld'
126
+ end
127
+
128
+ def self.media
129
+ 'http://cocina.sul.stanford.edu/models/resources/media.jsonld'
130
+ end
131
+
132
+ def self.object
133
+ 'http://cocina.sul.stanford.edu/models/resources/object.jsonld'
134
+ end
135
+
136
+ def self.page
137
+ 'http://cocina.sul.stanford.edu/models/resources/page.jsonld'
138
+ end
139
+
140
+ def self.permissions
141
+ 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld'
142
+ end
143
+
144
+ def self.preview
145
+ 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld'
146
+ end
147
+
148
+ def self.supplement
149
+ 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld'
150
+ end
151
+
152
+ def self.thumb
153
+ 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld'
154
+ end
155
+
156
+ def self.video
157
+ 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'
158
+ end
159
+ end
98
160
  end
99
161
  end
100
162
  end
data/openapi.yml CHANGED
@@ -127,9 +127,14 @@ components:
127
127
  description: Name of role
128
128
  type: string
129
129
  enum:
130
+ - 'dor-apo-creator'
131
+ - 'dor-apo-depositor'
132
+ - 'dor-apo-manager'
133
+ - 'dor-apo-metadata'
134
+ - 'dor-apo-reviewer'
135
+ - 'dor-apo-viewer'
130
136
  - 'sdr-administrator'
131
137
  - 'sdr-viewer'
132
- - 'dor-apo-manager'
133
138
  - 'hydrus-collection-creator'
134
139
  - 'hydrus-collection-manager'
135
140
  - 'hydrus-collection-depositor'
@@ -342,6 +347,11 @@ components:
342
347
  valueAt:
343
348
  description: URL or other pointer to the location of the contributor information.
344
349
  type: string
350
+ parallelContributor:
351
+ description: For multiple representations of information about the same contributor (e.g. in different languages).
352
+ type: array
353
+ items:
354
+ $ref: "#/components/schemas/DescriptiveParallelContributor"
345
355
  Description:
346
356
  type: object
347
357
  additionalProperties: false
@@ -576,6 +586,43 @@ components:
576
586
  type: array
577
587
  items:
578
588
  $ref: "#/components/schemas/DescriptiveValue"
589
+ DescriptiveParallelContributor:
590
+ description: Value model for multiple representations of information about the same contributor (e.g. in different languages).
591
+ type: object
592
+ additionalProperties: false
593
+ properties:
594
+ name:
595
+ description: Names associated with a contributor.
596
+ type: array
597
+ items:
598
+ $ref: "#/components/schemas/DescriptiveValue"
599
+ type:
600
+ description: Entity type of the contributor (person, organization, etc.).
601
+ type: string
602
+ status:
603
+ description: Status of the contributor relative to other parallel contributors (e.g. the primary author among a group of contributors).
604
+ type: string
605
+ role:
606
+ description: Relationships of the contributor to the resource or to an event in its history.
607
+ type: array
608
+ items:
609
+ $ref: "#/components/schemas/DescriptiveValue"
610
+ identifier:
611
+ description: Identifiers and URIs associated with the contributor entity.
612
+ type: array
613
+ items:
614
+ $ref: "#/components/schemas/DescriptiveValue"
615
+ note:
616
+ description: Other information associated with the contributor.
617
+ type: array
618
+ items:
619
+ $ref: "#/components/schemas/DescriptiveValue"
620
+ valueAt:
621
+ description: URL or other pointer to the location of the contributor information.
622
+ type: string
623
+ valueLanguage:
624
+ # description: Language of the descriptive element value
625
+ $ref: "#/components/schemas/DescriptiveValueLanguage"
579
626
  DescriptiveParallelEvent:
580
627
  description: Value model for multiple representations of information about the same event (e.g. in different languages).
581
628
  type: object
@@ -954,6 +1001,9 @@ components:
954
1001
  type: object
955
1002
  additionalProperties: false
956
1003
  properties:
1004
+ publish:
1005
+ type: boolean
1006
+ default: false
957
1007
  sdrPreserve:
958
1008
  type: boolean
959
1009
  default: true
@@ -961,6 +1011,7 @@ components:
961
1011
  type: boolean
962
1012
  default: false
963
1013
  required:
1014
+ - publish
964
1015
  - sdrPreserve
965
1016
  - shelve
966
1017
  FileSet:
@@ -972,7 +1023,22 @@ components:
972
1023
  description: The content type of the Fileset.
973
1024
  type: string
974
1025
  enum:
975
- - 'http://cocina.sul.stanford.edu/models/fileset.jsonld'
1026
+ - 'http://cocina.sul.stanford.edu/models/resources/audio.jsonld'
1027
+ - 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld'
1028
+ - 'http://cocina.sul.stanford.edu/models/resources/document.jsonld'
1029
+ - 'http://cocina.sul.stanford.edu/models/resources/file.jsonld'
1030
+ - 'http://cocina.sul.stanford.edu/models/resources/image.jsonld'
1031
+ - 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld'
1032
+ - 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld'
1033
+ - 'http://cocina.sul.stanford.edu/models/resources/media.jsonld'
1034
+ - 'http://cocina.sul.stanford.edu/models/resources/object.jsonld'
1035
+ - 'http://cocina.sul.stanford.edu/models/resources/page.jsonld'
1036
+ - 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld'
1037
+ - 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld'
1038
+ - 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld'
1039
+ - 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld'
1040
+ - 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld'
1041
+ - 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'
976
1042
  externalIdentifier:
977
1043
  type: string
978
1044
  label:
@@ -1389,7 +1455,22 @@ components:
1389
1455
  type:
1390
1456
  type: string
1391
1457
  enum:
1392
- - 'http://cocina.sul.stanford.edu/models/fileset.jsonld'
1458
+ - 'http://cocina.sul.stanford.edu/models/resources/audio.jsonld'
1459
+ - 'http://cocina.sul.stanford.edu/models/resources/attachment.jsonld'
1460
+ - 'http://cocina.sul.stanford.edu/models/resources/document.jsonld'
1461
+ - 'http://cocina.sul.stanford.edu/models/resources/file.jsonld'
1462
+ - 'http://cocina.sul.stanford.edu/models/resources/image.jsonld'
1463
+ - 'http://cocina.sul.stanford.edu/models/resources/main-augmented.jsonld'
1464
+ - 'http://cocina.sul.stanford.edu/models/resources/main-original.jsonld'
1465
+ - 'http://cocina.sul.stanford.edu/models/resources/media.jsonld'
1466
+ - 'http://cocina.sul.stanford.edu/models/resources/object.jsonld'
1467
+ - 'http://cocina.sul.stanford.edu/models/resources/page.jsonld'
1468
+ - 'http://cocina.sul.stanford.edu/models/resources/permissions.jsonld'
1469
+ - 'http://cocina.sul.stanford.edu/models/resources/preview.jsonld'
1470
+ - 'http://cocina.sul.stanford.edu/models/resources/supplement.jsonld'
1471
+ - 'http://cocina.sul.stanford.edu/models/resources/3d.jsonld'
1472
+ - 'http://cocina.sul.stanford.edu/models/resources/thumb.jsonld'
1473
+ - 'http://cocina.sul.stanford.edu/models/resources/video.jsonld'
1393
1474
  label:
1394
1475
  type: string
1395
1476
  version:
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.53.0
4
+ version: 0.55.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: 2021-03-04 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -271,6 +271,7 @@ files:
271
271
  - lib/cocina/models/descriptive_basic_value.rb
272
272
  - lib/cocina/models/descriptive_geographic_metadata.rb
273
273
  - lib/cocina/models/descriptive_grouped_value.rb
274
+ - lib/cocina/models/descriptive_parallel_contributor.rb
274
275
  - lib/cocina/models/descriptive_parallel_event.rb
275
276
  - lib/cocina/models/descriptive_parallel_value.rb
276
277
  - lib/cocina/models/descriptive_structured_value.rb
@@ -329,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
330
  - !ruby/object:Gem::Version
330
331
  version: '0'
331
332
  requirements: []
332
- rubygems_version: 3.1.2
333
+ rubygems_version: 3.1.4
333
334
  signing_key:
334
335
  specification_version: 4
335
336
  summary: Data models for the SDR