cocina-models 0.74.0 → 0.76.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +40 -11
  3. data/.rubocop_todo.yml +71 -2
  4. data/README.md +19 -3
  5. data/cocina-models.gemspec +2 -0
  6. data/description_types.yml +167 -39
  7. data/docs/description_types.md +470 -216
  8. data/lib/cocina/generator/generator.rb +7 -15
  9. data/lib/cocina/generator/schema.rb +1 -3
  10. data/lib/cocina/generator/schema_base.rb +0 -8
  11. data/lib/cocina/generator/schema_ref.rb +1 -1
  12. data/lib/cocina/generator/schema_value.rb +14 -4
  13. data/lib/cocina/models/access.rb +4 -4
  14. data/lib/cocina/models/admin_policy.rb +1 -1
  15. data/lib/cocina/models/admin_policy_access_template.rb +7 -7
  16. data/lib/cocina/models/admin_policy_administrative.rb +1 -1
  17. data/lib/cocina/models/admin_policy_with_metadata.rb +3 -3
  18. data/lib/cocina/models/builders/dro_rights_description_builder.rb +69 -0
  19. data/lib/cocina/models/builders/name_title_group_builder.rb +130 -0
  20. data/lib/cocina/models/builders/rights_description_builder.rb +83 -0
  21. data/lib/cocina/models/builders/title_builder.rb +211 -0
  22. data/lib/cocina/models/citation_only_access.rb +2 -2
  23. data/lib/cocina/models/collection_access.rb +4 -4
  24. data/lib/cocina/models/collection_identification.rb +1 -1
  25. data/lib/cocina/models/collection_with_metadata.rb +2 -2
  26. data/lib/cocina/models/contributor.rb +4 -4
  27. data/lib/cocina/models/controlled_digital_lending_access.rb +2 -2
  28. data/lib/cocina/models/dark_access.rb +4 -4
  29. data/lib/cocina/models/description.rb +3 -3
  30. data/lib/cocina/models/descriptive_basic_value.rb +13 -13
  31. data/lib/cocina/models/descriptive_parallel_contributor.rb +5 -5
  32. data/lib/cocina/models/descriptive_parallel_event.rb +3 -3
  33. data/lib/cocina/models/descriptive_value.rb +13 -13
  34. data/lib/cocina/models/descriptive_value_language.rb +6 -6
  35. data/lib/cocina/models/dro.rb +1 -1
  36. data/lib/cocina/models/dro_access.rb +8 -8
  37. data/lib/cocina/models/dro_with_metadata.rb +3 -3
  38. data/lib/cocina/models/embargo.rb +5 -5
  39. data/lib/cocina/models/event.rb +3 -3
  40. data/lib/cocina/models/file.rb +4 -4
  41. data/lib/cocina/models/file_access.rb +4 -4
  42. data/lib/cocina/models/identification.rb +2 -2
  43. data/lib/cocina/models/language.rb +12 -12
  44. data/lib/cocina/models/location_based_access.rb +1 -1
  45. data/lib/cocina/models/location_based_download_access.rb +1 -1
  46. data/lib/cocina/models/mapping/error_notifier.rb +36 -0
  47. data/lib/cocina/models/mapping/from_mods/access.rb +177 -0
  48. data/lib/cocina/models/mapping/from_mods/admin_metadata.rb +217 -0
  49. data/lib/cocina/models/mapping/from_mods/alt_rep_group.rb +26 -0
  50. data/lib/cocina/models/mapping/from_mods/authority.rb +51 -0
  51. data/lib/cocina/models/mapping/from_mods/contributor.rb +161 -0
  52. data/lib/cocina/models/mapping/from_mods/description.rb +99 -0
  53. data/lib/cocina/models/mapping/from_mods/description_builder.rb +61 -0
  54. data/lib/cocina/models/mapping/from_mods/event.rb +543 -0
  55. data/lib/cocina/models/mapping/from_mods/form.rb +381 -0
  56. data/lib/cocina/models/mapping/from_mods/geographic.rb +219 -0
  57. data/lib/cocina/models/mapping/from_mods/hydrus_default_title_builder.rb +28 -0
  58. data/lib/cocina/models/mapping/from_mods/identifier.rb +51 -0
  59. data/lib/cocina/models/mapping/from_mods/identifier_builder.rb +71 -0
  60. data/lib/cocina/models/mapping/from_mods/identifier_type.rb +292 -0
  61. data/lib/cocina/models/mapping/from_mods/language.rb +36 -0
  62. data/lib/cocina/models/mapping/from_mods/language_script.rb +30 -0
  63. data/lib/cocina/models/mapping/from_mods/language_term.rb +106 -0
  64. data/lib/cocina/models/mapping/from_mods/name_builder.rb +307 -0
  65. data/lib/cocina/models/mapping/from_mods/note.rb +162 -0
  66. data/lib/cocina/models/mapping/from_mods/part_builder.rb +147 -0
  67. data/lib/cocina/models/mapping/from_mods/primary.rb +27 -0
  68. data/lib/cocina/models/mapping/from_mods/purl.rb +53 -0
  69. data/lib/cocina/models/mapping/from_mods/related_resource.rb +105 -0
  70. data/lib/cocina/models/mapping/from_mods/subject.rb +413 -0
  71. data/lib/cocina/models/mapping/from_mods/subject_authority_codes.rb +794 -0
  72. data/lib/cocina/models/mapping/from_mods/title.rb +160 -0
  73. data/lib/cocina/models/mapping/from_mods/title_builder.rb +106 -0
  74. data/lib/cocina/models/mapping/from_mods/title_builder_strategy.rb +19 -0
  75. data/lib/cocina/models/mapping/from_mods/value_uri.rb +25 -0
  76. data/lib/cocina/models/mapping/normalizers/base.rb +16 -0
  77. data/lib/cocina/models/mapping/normalizers/mods/geo_extension_normalizer.rb +69 -0
  78. data/lib/cocina/models/mapping/normalizers/mods/name_normalizer.rb +191 -0
  79. data/lib/cocina/models/mapping/normalizers/mods/origin_info_normalizer.rb +157 -0
  80. data/lib/cocina/models/mapping/normalizers/mods/subject_normalizer.rb +296 -0
  81. data/lib/cocina/models/mapping/normalizers/mods/title_normalizer.rb +91 -0
  82. data/lib/cocina/models/mapping/normalizers/mods_normalizer.rb +409 -0
  83. data/lib/cocina/models/mapping/purl.rb +28 -0
  84. data/lib/cocina/models/mapping/to_mods/access.rb +155 -0
  85. data/lib/cocina/models/mapping/to_mods/admin_metadata.rb +129 -0
  86. data/lib/cocina/models/mapping/to_mods/contributor.rb +49 -0
  87. data/lib/cocina/models/mapping/to_mods/description.rb +63 -0
  88. data/lib/cocina/models/mapping/to_mods/event.rb +200 -0
  89. data/lib/cocina/models/mapping/to_mods/form.rb +292 -0
  90. data/lib/cocina/models/mapping/to_mods/geographic.rb +151 -0
  91. data/lib/cocina/models/mapping/to_mods/id_generator.rb +25 -0
  92. data/lib/cocina/models/mapping/to_mods/identifier.rb +57 -0
  93. data/lib/cocina/models/mapping/to_mods/language.rb +82 -0
  94. data/lib/cocina/models/mapping/to_mods/mods_writer.rb +38 -0
  95. data/lib/cocina/models/mapping/to_mods/name_title_group.rb +29 -0
  96. data/lib/cocina/models/mapping/to_mods/name_writer.rb +228 -0
  97. data/lib/cocina/models/mapping/to_mods/note.rb +105 -0
  98. data/lib/cocina/models/mapping/to_mods/part_writer.rb +115 -0
  99. data/lib/cocina/models/mapping/to_mods/related_resource.rb +108 -0
  100. data/lib/cocina/models/mapping/to_mods/role_writer.rb +50 -0
  101. data/lib/cocina/models/mapping/to_mods/subject.rb +486 -0
  102. data/lib/cocina/models/mapping/to_mods/title.rb +260 -0
  103. data/lib/cocina/models/object_metadata.rb +2 -2
  104. data/lib/cocina/models/presentation.rb +2 -2
  105. data/lib/cocina/models/related_resource.rb +9 -9
  106. data/lib/cocina/models/release_tag.rb +4 -4
  107. data/lib/cocina/models/request_admin_policy.rb +1 -1
  108. data/lib/cocina/models/request_administrative.rb +1 -1
  109. data/lib/cocina/models/request_collection.rb +2 -2
  110. data/lib/cocina/models/request_description.rb +3 -3
  111. data/lib/cocina/models/request_dro.rb +4 -4
  112. data/lib/cocina/models/request_file.rb +5 -5
  113. data/lib/cocina/models/request_identification.rb +1 -1
  114. data/lib/cocina/models/sequence.rb +1 -1
  115. data/lib/cocina/models/source.rb +4 -4
  116. data/lib/cocina/models/standard.rb +5 -5
  117. data/lib/cocina/models/stanford_access.rb +2 -2
  118. data/lib/cocina/models/title.rb +13 -13
  119. data/lib/cocina/models/validators/associated_name_validator.rb +77 -0
  120. data/lib/cocina/models/validators/dark_validator.rb +4 -2
  121. data/lib/cocina/models/validators/open_api_validator.rb +0 -4
  122. data/lib/cocina/models/validators/validator.rb +1 -0
  123. data/lib/cocina/models/version.rb +1 -1
  124. data/lib/cocina/models/world_access.rb +2 -2
  125. data/lib/cocina/models.rb +4 -0
  126. data/lib/cocina/rspec/factories.rb +157 -0
  127. data/lib/cocina/rspec.rb +2 -0
  128. data/openapi.yml +4 -4
  129. metadata +93 -6
  130. data/docs/_config.yml +0 -1
  131. data/lib/cocina/models/dro_rights_description_builder.rb +0 -67
  132. data/lib/cocina/models/rights_description_builder.rb +0 -81
  133. data/lib/cocina/models/title_builder.rb +0 -208
@@ -0,0 +1,211 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'deprecation'
4
+
5
+ module Cocina
6
+ module Models
7
+ module Builders
8
+ # TitleBuilder selects the prefered title from the cocina object for solr indexing
9
+ # rubocop:disable Metrics/ClassLength
10
+ class TitleBuilder
11
+ extend Deprecation
12
+ # @param [[Array<Cocina::Models::Title,Cocina::Models::DescriptiveValue>] titles the titles to consider
13
+ # @param [Symbol] strategy ":first" is the strategy for selection when primary or display
14
+ # title are missing
15
+ # @param [Boolean] add_punctuation determines if the title should be formmated with punctuation
16
+ # @return [String] the title value for Solr
17
+ def self.build(titles, strategy: :first, add_punctuation: true)
18
+ if titles.respond_to?(:description)
19
+ Deprecation.warn(self,
20
+ "Calling TitleBuilder.build with a #{titles.class} is deprecated. " \
21
+ 'It must be called with an array of titles')
22
+ titles = titles.description.title
23
+ end
24
+ new(strategy: strategy, add_punctuation: add_punctuation).build(titles)
25
+ end
26
+
27
+ def initialize(strategy:, add_punctuation:)
28
+ @strategy = strategy
29
+ @add_punctuation = add_punctuation
30
+ end
31
+
32
+ # @param [[Array<Cocina::Models::Title>] titles the titles to consider
33
+ # @return [String] the title value for Solr
34
+ def build(titles)
35
+ cocina_title = primary_title(titles) || untyped_title(titles)
36
+ cocina_title = other_title(titles) if cocina_title.blank?
37
+
38
+ if strategy == :first
39
+ extract_title(cocina_title)
40
+ else
41
+ cocina_title.map { |one| extract_title(one) }
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ attr_reader :strategy
48
+
49
+ def extract_title(cocina_title)
50
+ result = if cocina_title.value
51
+ cocina_title.value
52
+ elsif cocina_title.structuredValue.present?
53
+ title_from_structured_values(cocina_title)
54
+ elsif cocina_title.parallelValue.present?
55
+ return build(cocina_title.parallelValue)
56
+ end
57
+ remove_trailing_punctuation(result.strip) if result.present?
58
+ end
59
+
60
+ def add_punctuation?
61
+ @add_punctuation
62
+ end
63
+
64
+ # @return [Cocina::Models::Title, nil] title that has status=primary
65
+ def primary_title(titles)
66
+ primary_title = titles.find do |title|
67
+ title.status == 'primary'
68
+ end
69
+ return primary_title if primary_title.present?
70
+
71
+ # NOTE: structuredValues would only have status primary assigned as a sibling, not as an attribute
72
+
73
+ titles.find do |title|
74
+ title.parallelValue&.find do |parallel_title|
75
+ parallel_title.status == 'primary'
76
+ end
77
+ end
78
+ end
79
+
80
+ def untyped_title(titles)
81
+ method = strategy == :first ? :find : :select
82
+ untyped_title_for(titles.public_send(method))
83
+ end
84
+
85
+ # @return [Array[Cocina::Models::Title]] first title that has no type attribute
86
+ def untyped_title_for(titles)
87
+ titles.each do |title|
88
+ if title.parallelValue.present?
89
+ untyped_title_for(title.parallelValue)
90
+ else
91
+ title.type.nil? || title.type == 'title'
92
+ end
93
+ end
94
+ end
95
+
96
+ # This handles 'main title', 'uniform' or 'translated'
97
+ def other_title(titles)
98
+ if strategy == :first
99
+ titles.first
100
+ else
101
+ titles
102
+ end
103
+ end
104
+
105
+ # rubocop:disable Metrics/BlockLength
106
+ # rubocop:disable Metrics/CyclomaticComplexity
107
+ # rubocop:disable Metrics/PerceivedComplexity
108
+ # rubocop:disable Metrics/MethodLength
109
+ # @param [Cocina::Models::Title] title with structured values
110
+ # @return [String] the title value from combining the pieces of the structured_values by type and order
111
+ # with desired punctuation per specs
112
+ def title_from_structured_values(title)
113
+ structured_title = ''
114
+ part_name_number = ''
115
+ # combine pieces of the cocina structuredValue into a single title
116
+ title.structuredValue.each do |structured_value|
117
+ # There can be a structuredValue inside a structuredValue. For example,
118
+ # a uniform title where both the name and the title have internal StructuredValue
119
+ return title_from_structured_values(structured_value) if structured_value.structuredValue.present?
120
+
121
+ value = structured_value.value&.strip
122
+ next unless value
123
+
124
+ # additional types: name, uniform ...
125
+ case structured_value.type&.downcase
126
+ when 'nonsorting characters'
127
+ non_sort_value = "#{value}#{non_sorting_padding(title, value)}"
128
+ structured_title = if structured_title.present?
129
+ "#{structured_title}#{non_sort_value}"
130
+ else
131
+ non_sort_value
132
+ end
133
+ when 'part name', 'part number'
134
+ if part_name_number.blank?
135
+ part_name_number = part_name_number(title.structuredValue)
136
+ structured_title = if !add_punctuation?
137
+ [structured_title, part_name_number].join(' ')
138
+ elsif structured_title.present?
139
+ "#{structured_title.sub(/[ .,]*$/, '')}. #{part_name_number}. "
140
+ else
141
+ "#{part_name_number}. "
142
+ end
143
+ end
144
+ when 'main title', 'title'
145
+ structured_title = "#{structured_title}#{value}"
146
+ when 'subtitle'
147
+ # subtitle is preceded by space colon space, unless it is at the beginning of the title string
148
+ structured_title = if !add_punctuation?
149
+ [structured_title, value].join(' ')
150
+ elsif structured_title.present?
151
+ "#{structured_title.sub(/[. :]+$/, '')} : #{value.sub(/^:/, '').strip}"
152
+ else
153
+ structured_title = value.sub(/^:/, '').strip
154
+ end
155
+ end
156
+ end
157
+ structured_title
158
+ end
159
+ # rubocop:enable Metrics/MethodLength
160
+ # rubocop:enable Metrics/BlockLength
161
+ # rubocop:enable Metrics/CyclomaticComplexity
162
+ # rubocop:enable Metrics/PerceivedComplexity
163
+
164
+ def remove_trailing_punctuation(title)
165
+ title.sub(%r{[ .,;:/\\]+$}, '')
166
+ end
167
+
168
+ def non_sorting_padding(title, non_sorting_value)
169
+ non_sort_note = title.note&.find { |note| note.type&.downcase == 'nonsorting character count' }
170
+ if non_sort_note
171
+ padding_count = [non_sort_note.value.to_i - non_sorting_value.length, 0].max
172
+ ' ' * padding_count
173
+ elsif ['\'', '-'].include?(non_sorting_value.last)
174
+ ''
175
+ else
176
+ ' '
177
+ end
178
+ end
179
+
180
+ # combine part name and part number:
181
+ # respect order of occurrence
182
+ # separated from each other by comma space
183
+ def part_name_number(structured_values)
184
+ title_from_part = ''
185
+ structured_values.each do |structured_value|
186
+ case structured_value.type&.downcase
187
+ when 'part name', 'part number'
188
+ value = structured_value.value&.strip
189
+ next unless value
190
+
191
+ title_from_part = append_part_to_title(title_from_part, value)
192
+
193
+ end
194
+ end
195
+ title_from_part
196
+ end
197
+
198
+ def append_part_to_title(title_from_part, value)
199
+ if !add_punctuation?
200
+ [title_from_part, value].select(&:presence).join(' ')
201
+ elsif title_from_part.strip.present?
202
+ "#{title_from_part.sub(/[ .,]*$/, '')}, #{value}"
203
+ else
204
+ value
205
+ end
206
+ end
207
+ end
208
+ # rubocop:enable Metrics/ClassLength
209
+ end
210
+ end
211
+ end
@@ -8,8 +8,8 @@ module Cocina
8
8
  # Download access level.
9
9
  attribute :download, Types::Strict::String.enum('none')
10
10
  # Not used for this access type, must be null.
11
- attribute :location, Types::Strict::String.optional.enum('').meta(omittable: true)
12
- attribute :controlledDigitalLending, Types::Strict::Bool.enum(false).meta(omittable: true)
11
+ attribute? :location, Types::Strict::String.optional.enum('')
12
+ attribute? :controlledDigitalLending, Types::Strict::Bool.default(false).enum(false)
13
13
  end
14
14
  end
15
15
  end
@@ -4,15 +4,15 @@ module Cocina
4
4
  module Models
5
5
  class CollectionAccess < Struct
6
6
  # Access level
7
- attribute :view, Types::Strict::String.default('dark').enum('world', 'dark').meta(omittable: true)
7
+ attribute? :view, Types::Strict::String.default('dark').enum('world', 'dark')
8
8
  # The human readable copyright statement that applies
9
9
  # example: Copyright World Trade Organization
10
- attribute :copyright, Types::Strict::String.optional.meta(omittable: true)
10
+ attribute? :copyright, Types::Strict::String.optional
11
11
  # The human readable use and reproduction statement that applies
12
12
  # example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
13
- attribute :useAndReproductionStatement, Types::Strict::String.optional.meta(omittable: true)
13
+ attribute? :useAndReproductionStatement, Types::Strict::String.optional
14
14
  # The license governing reuse of the Collection. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
15
- attribute :license, Types::Strict::String.optional.meta(omittable: true)
15
+ attribute? :license, Types::Strict::String.optional
16
16
  end
17
17
  end
18
18
  end
@@ -7,7 +7,7 @@ module Cocina
7
7
  # Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"
8
8
 
9
9
  # example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
10
- attribute :sourceId, Types::Strict::String.meta(omittable: true)
10
+ attribute? :sourceId, Types::Strict::String
11
11
  end
12
12
  end
13
13
  end
@@ -29,9 +29,9 @@ module Cocina
29
29
  attribute(:description, Description.default { Description.new })
30
30
  attribute(:identification, CollectionIdentification.default { CollectionIdentification.new })
31
31
  # When the object was created.
32
- attribute :created, Types::Params::DateTime.meta(omittable: true)
32
+ attribute? :created, Types::Params::DateTime
33
33
  # When the object was modified.
34
- attribute :modified, Types::Params::DateTime.meta(omittable: true)
34
+ attribute? :modified, Types::Params::DateTime
35
35
  # Key for optimistic locking. The contents of the key is not specified.
36
36
  attribute :lock, Types::Strict::String
37
37
  end
@@ -4,15 +4,15 @@ module Cocina
4
4
  module Models
5
5
  class Contributor < Struct
6
6
  attribute :name, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
- # Entity type of the contributor (person, organization, etc.).
8
- attribute :type, Types::Strict::String.meta(omittable: true)
7
+ # Entity type of the contributor (person, organization, etc.). See https://github.com/sul-dlss/cocina-models/blob/main/docs/description_types.md for valid types.
8
+ attribute? :type, Types::Strict::String
9
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)
10
+ attribute? :status, Types::Strict::String
11
11
  attribute :role, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
12
12
  attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
13
13
  attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
14
14
  # URL or other pointer to the location of the contributor information.
15
- attribute :valueAt, Types::Strict::String.meta(omittable: true)
15
+ attribute? :valueAt, Types::Strict::String
16
16
  attribute :parallelContributor, Types::Strict::Array.of(DescriptiveParallelContributor).default([].freeze)
17
17
  end
18
18
  end
@@ -8,9 +8,9 @@ module Cocina
8
8
  # Download access level.
9
9
  attribute :download, Types::Strict::String.enum('none')
10
10
  # Not used for this access type, must be null.
11
- attribute :location, Types::Strict::String.optional.enum('').meta(omittable: true)
11
+ attribute? :location, Types::Strict::String.optional.enum('')
12
12
  # Available for controlled digital lending.
13
- attribute :controlledDigitalLending, Types::Strict::Bool.default(false)
13
+ attribute? :controlledDigitalLending, Types::Strict::Bool.default(false)
14
14
  end
15
15
  end
16
16
  end
@@ -4,12 +4,12 @@ module Cocina
4
4
  module Models
5
5
  class DarkAccess < Struct
6
6
  # Access level.
7
- attribute :view, Types::Strict::String.default('dark').enum('dark').meta(omittable: true)
7
+ attribute? :view, Types::Strict::String.default('dark').enum('dark')
8
8
  # Download access level.
9
- attribute :download, Types::Strict::String.default('none').enum('none').meta(omittable: true)
9
+ attribute? :download, Types::Strict::String.default('none').enum('none')
10
10
  # Not used for this access type, must be null.
11
- attribute :location, Types::Strict::String.optional.enum('').meta(omittable: true)
12
- attribute :controlledDigitalLending, Types::Strict::Bool.enum(false).meta(omittable: true)
11
+ attribute? :location, Types::Strict::String.optional.enum('')
12
+ attribute? :controlledDigitalLending, Types::Strict::Bool.default(false).enum(false)
13
13
  end
14
14
  end
15
15
  end
@@ -14,12 +14,12 @@ module Cocina
14
14
  attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
15
15
  attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
16
16
  attribute :subject, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
17
- attribute :access, DescriptiveAccessMetadata.optional.meta(omittable: true)
17
+ attribute? :access, DescriptiveAccessMetadata.optional
18
18
  attribute :relatedResource, Types::Strict::Array.of(RelatedResource).default([].freeze)
19
19
  attribute :marcEncodedData, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
20
- attribute :adminMetadata, DescriptiveAdminMetadata.optional.meta(omittable: true)
20
+ attribute? :adminMetadata, DescriptiveAdminMetadata.optional
21
21
  # URL or other pointer to the location of the resource description.
22
- attribute :valueAt, Types::Strict::String.meta(omittable: true)
22
+ attribute? :valueAt, Types::Strict::String
23
23
  # Stanford persistent URL associated with the related resource. Note this is http, not https.
24
24
  attribute :purl, Types::Strict::String
25
25
  end
@@ -7,27 +7,27 @@ module Cocina
7
7
  attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
8
8
  attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
9
9
  # String or integer value of the descriptive element.
10
- attribute :value, Types::Nominal::Any.meta(omittable: true)
11
- # Type of value provided by the descriptive element.
12
- attribute :type, Types::Strict::String.meta(omittable: true)
10
+ attribute? :value, Types::Nominal::Any
11
+ # Type of value provided by the descriptive element. See https://github.com/sul-dlss/cocina-models/blob/main/docs/description_types.md for valid types.
12
+ attribute? :type, Types::Strict::String
13
13
  # Status of the descriptive element value relative to other instances of the element.
14
- attribute :status, Types::Strict::String.meta(omittable: true)
14
+ attribute? :status, Types::Strict::String
15
15
  # Code value of the descriptive element.
16
- attribute :code, Types::Strict::String.meta(omittable: true)
16
+ attribute? :code, Types::Strict::String
17
17
  # URI value of the descriptive element.
18
- attribute :uri, Types::Strict::String.meta(omittable: true)
19
- attribute :standard, Standard.optional.meta(omittable: true)
20
- attribute :encoding, Standard.optional.meta(omittable: true)
18
+ attribute? :uri, Types::Strict::String
19
+ attribute? :standard, Standard.optional
20
+ attribute? :encoding, Standard.optional
21
21
  attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
22
- attribute :source, Source.optional.meta(omittable: true)
22
+ attribute? :source, Source.optional
23
23
  # The preferred display label to use for the descriptive element in access systems.
24
- attribute :displayLabel, Types::Strict::String.meta(omittable: true)
24
+ attribute? :displayLabel, Types::Strict::String
25
25
  # A term providing information about the circumstances of the statement (e.g., approximate dates).
26
- attribute :qualifier, Types::Strict::String.meta(omittable: true)
26
+ attribute? :qualifier, Types::Strict::String
27
27
  attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
28
- attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)
28
+ attribute? :valueLanguage, DescriptiveValueLanguage.optional
29
29
  # URL or other pointer to the location of the value of the descriptive element.
30
- attribute :valueAt, Types::Strict::String.meta(omittable: true)
30
+ attribute? :valueAt, Types::Strict::String
31
31
  end
32
32
  end
33
33
  end
@@ -4,16 +4,16 @@ module Cocina
4
4
  module Models
5
5
  class DescriptiveParallelContributor < Struct
6
6
  attribute :name, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
- # Entity type of the contributor (person, organization, etc.).
8
- attribute :type, Types::Strict::String.meta(omittable: true)
7
+ # Entity type of the contributor (person, organization, etc.). See https://github.com/sul-dlss/cocina-models/blob/main/docs/description_types.md for valid types.
8
+ attribute? :type, Types::Strict::String
9
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)
10
+ attribute? :status, Types::Strict::String
11
11
  attribute :role, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
12
12
  attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
13
13
  attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
14
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)
15
+ attribute? :valueAt, Types::Strict::String
16
+ attribute? :valueLanguage, DescriptiveValueLanguage.optional
17
17
  end
18
18
  end
19
19
  end
@@ -5,15 +5,15 @@ module Cocina
5
5
  class DescriptiveParallelEvent < Struct
6
6
  attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
7
  # Description of the event (creation, publication, etc.).
8
- attribute :type, Types::Strict::String.meta(omittable: true)
8
+ attribute? :type, Types::Strict::String
9
9
  # The preferred display label to use for the event in access systems.
10
- attribute :displayLabel, Types::Strict::String.meta(omittable: true)
10
+ attribute? :displayLabel, Types::Strict::String
11
11
  attribute :date, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
12
12
  attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
13
13
  attribute :location, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
14
14
  attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
15
15
  attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
16
- attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)
16
+ attribute? :valueLanguage, DescriptiveValueLanguage.optional
17
17
  end
18
18
  end
19
19
  end
@@ -7,27 +7,27 @@ module Cocina
7
7
  attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
8
8
  attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
9
9
  # String or integer value of the descriptive element.
10
- attribute :value, Types::Nominal::Any.meta(omittable: true)
11
- # Type of value provided by the descriptive element.
12
- attribute :type, Types::Strict::String.meta(omittable: true)
10
+ attribute? :value, Types::Nominal::Any
11
+ # Type of value provided by the descriptive element. See https://github.com/sul-dlss/cocina-models/blob/main/docs/description_types.md for valid types.
12
+ attribute? :type, Types::Strict::String
13
13
  # Status of the descriptive element value relative to other instances of the element.
14
- attribute :status, Types::Strict::String.meta(omittable: true)
14
+ attribute? :status, Types::Strict::String
15
15
  # Code value of the descriptive element.
16
- attribute :code, Types::Strict::String.meta(omittable: true)
16
+ attribute? :code, Types::Strict::String
17
17
  # URI value of the descriptive element.
18
- attribute :uri, Types::Strict::String.meta(omittable: true)
19
- attribute :standard, Standard.optional.meta(omittable: true)
20
- attribute :encoding, Standard.optional.meta(omittable: true)
18
+ attribute? :uri, Types::Strict::String
19
+ attribute? :standard, Standard.optional
20
+ attribute? :encoding, Standard.optional
21
21
  attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
22
- attribute :source, Source.optional.meta(omittable: true)
22
+ attribute? :source, Source.optional
23
23
  # The preferred display label to use for the descriptive element in access systems.
24
- attribute :displayLabel, Types::Strict::String.meta(omittable: true)
24
+ attribute? :displayLabel, Types::Strict::String
25
25
  # A term providing information about the circumstances of the statement (e.g., approximate dates).
26
- attribute :qualifier, Types::Strict::String.meta(omittable: true)
26
+ attribute? :qualifier, Types::Strict::String
27
27
  attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
28
- attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)
28
+ attribute? :valueLanguage, DescriptiveValueLanguage.optional
29
29
  # URL or other pointer to the location of the value of the descriptive element.
30
- attribute :valueAt, Types::Strict::String.meta(omittable: true)
30
+ attribute? :valueAt, Types::Strict::String
31
31
  attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).default([].freeze)
32
32
  end
33
33
  end
@@ -4,16 +4,16 @@ module Cocina
4
4
  module Models
5
5
  class DescriptiveValueLanguage < Struct
6
6
  # Code representing the standard or encoding.
7
- attribute :code, Types::Strict::String.meta(omittable: true)
7
+ attribute? :code, Types::Strict::String
8
8
  # URI for the standard or encoding.
9
- attribute :uri, Types::Strict::String.meta(omittable: true)
9
+ attribute? :uri, Types::Strict::String
10
10
  # String describing the standard or encoding.
11
- attribute :value, Types::Strict::String.meta(omittable: true)
11
+ attribute? :value, Types::Strict::String
12
12
  attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
13
13
  # The version of the standard or encoding.
14
- attribute :version, Types::Strict::String.meta(omittable: true)
15
- attribute :source, Source.optional.meta(omittable: true)
16
- attribute :valueScript, Standard.optional.meta(omittable: true)
14
+ attribute? :version, Types::Strict::String
15
+ attribute? :source, Source.optional
16
+ attribute? :valueScript, Standard.optional
17
17
  end
18
18
  end
19
19
  end
@@ -39,7 +39,7 @@ module Cocina
39
39
  attribute(:description, Description.default { Description.new })
40
40
  attribute(:identification, Identification.default { Identification.new })
41
41
  attribute(:structural, DROStructural.default { DROStructural.new })
42
- attribute :geographic, Geographic.optional.meta(omittable: true)
42
+ attribute? :geographic, Geographic.optional
43
43
  end
44
44
  end
45
45
  end
@@ -5,24 +5,24 @@ module Cocina
5
5
  class DROAccess < Struct
6
6
  # Access level.
7
7
  # Validation of this property is relaxed. See the openapi for full validation.
8
- attribute :view, Types::Strict::String.optional.default('dark').meta(omittable: true)
8
+ attribute? :view, Types::Strict::String.optional.default('dark')
9
9
  # Download access level.
10
10
  # Validation of this property is relaxed. See the openapi for full validation.
11
- attribute :download, Types::Strict::String.optional.default('none').meta(omittable: true)
11
+ attribute? :download, Types::Strict::String.optional.default('none')
12
12
  # Not used for this access type, must be null.
13
13
  # Validation of this property is relaxed. See the openapi for full validation.
14
- attribute :location, Types::Strict::String.optional.meta(omittable: true)
14
+ attribute? :location, Types::Strict::String.optional
15
15
  # Validation of this property is relaxed. See the openapi for full validation.
16
- attribute :controlledDigitalLending, Types::Strict::Bool.optional.meta(omittable: true)
16
+ attribute? :controlledDigitalLending, Types::Strict::Bool.optional.default(false)
17
17
  # The human readable copyright statement that applies
18
18
  # example: Copyright World Trade Organization
19
- attribute :copyright, Types::Strict::String.optional.meta(omittable: true)
20
- attribute :embargo, Embargo.optional.meta(omittable: true)
19
+ attribute? :copyright, Types::Strict::String.optional
20
+ attribute? :embargo, Embargo.optional
21
21
  # The human readable use and reproduction statement that applies
22
22
  # example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
23
- attribute :useAndReproductionStatement, Types::Strict::String.optional.meta(omittable: true)
23
+ attribute? :useAndReproductionStatement, Types::Strict::String.optional
24
24
  # The license governing reuse of the DRO. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
25
- attribute :license, Types::Strict::String.optional.enum('https://www.gnu.org/licenses/agpl.txt', 'https://www.apache.org/licenses/LICENSE-2.0', 'https://opensource.org/licenses/BSD-2-Clause', 'https://opensource.org/licenses/BSD-3-Clause', 'https://creativecommons.org/licenses/by/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode', 'https://creativecommons.org/licenses/by-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-sa/4.0/legalcode', 'https://creativecommons.org/publicdomain/zero/1.0/legalcode', 'https://opensource.org/licenses/cddl1', 'https://www.eclipse.org/legal/epl-2.0', 'https://www.gnu.org/licenses/gpl-3.0-standalone.html', 'https://www.isc.org/downloads/software-support-policy/isc-license/', 'https://www.gnu.org/licenses/lgpl-3.0-standalone.html', 'https://opensource.org/licenses/MIT', 'https://www.mozilla.org/MPL/2.0/', 'https://opendatacommons.org/licenses/by/1-0/', 'http://opendatacommons.org/licenses/odbl/1.0/', 'https://opendatacommons.org/licenses/odbl/1-0/', 'https://creativecommons.org/publicdomain/mark/1.0/', 'https://opendatacommons.org/licenses/pddl/1-0/', 'https://creativecommons.org/licenses/by/3.0/legalcode', 'https://creativecommons.org/licenses/by-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nd/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/3.0/legalcode', 'https://cocina.sul.stanford.edu/licenses/none').meta(omittable: true)
25
+ attribute? :license, Types::Strict::String.optional.enum('https://www.gnu.org/licenses/agpl.txt', 'https://www.apache.org/licenses/LICENSE-2.0', 'https://opensource.org/licenses/BSD-2-Clause', 'https://opensource.org/licenses/BSD-3-Clause', 'https://creativecommons.org/licenses/by/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode', 'https://creativecommons.org/licenses/by-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-sa/4.0/legalcode', 'https://creativecommons.org/publicdomain/zero/1.0/legalcode', 'https://opensource.org/licenses/cddl1', 'https://www.eclipse.org/legal/epl-2.0', 'https://www.gnu.org/licenses/gpl-3.0-standalone.html', 'https://www.isc.org/downloads/software-support-policy/isc-license/', 'https://www.gnu.org/licenses/lgpl-3.0-standalone.html', 'https://opensource.org/licenses/MIT', 'https://www.mozilla.org/MPL/2.0/', 'https://opendatacommons.org/licenses/by/1-0/', 'http://opendatacommons.org/licenses/odbl/1.0/', 'https://opendatacommons.org/licenses/odbl/1-0/', 'https://creativecommons.org/publicdomain/mark/1.0/', 'https://opendatacommons.org/licenses/pddl/1-0/', 'https://creativecommons.org/licenses/by/3.0/legalcode', 'https://creativecommons.org/licenses/by-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nd/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/3.0/legalcode', 'https://cocina.sul.stanford.edu/licenses/none')
26
26
  end
27
27
  end
28
28
  end
@@ -39,11 +39,11 @@ module Cocina
39
39
  attribute(:description, Description.default { Description.new })
40
40
  attribute(:identification, Identification.default { Identification.new })
41
41
  attribute(:structural, DROStructural.default { DROStructural.new })
42
- attribute :geographic, Geographic.optional.meta(omittable: true)
42
+ attribute? :geographic, Geographic.optional
43
43
  # When the object was created.
44
- attribute :created, Types::Params::DateTime.meta(omittable: true)
44
+ attribute? :created, Types::Params::DateTime
45
45
  # When the object was modified.
46
- attribute :modified, Types::Params::DateTime.meta(omittable: true)
46
+ attribute? :modified, Types::Params::DateTime
47
47
  # Key for optimistic locking. The contents of the key is not specified.
48
48
  attribute :lock, Types::Strict::String
49
49
  end
@@ -5,21 +5,21 @@ module Cocina
5
5
  class Embargo < Struct
6
6
  # Access level.
7
7
  # Validation of this property is relaxed. See the openapi for full validation.
8
- attribute :view, Types::Strict::String.optional.default('dark').meta(omittable: true)
8
+ attribute? :view, Types::Strict::String.optional.default('dark')
9
9
  # Download access level.
10
10
  # Validation of this property is relaxed. See the openapi for full validation.
11
- attribute :download, Types::Strict::String.optional.default('none').meta(omittable: true)
11
+ attribute? :download, Types::Strict::String.optional.default('none')
12
12
  # Not used for this access type, must be null.
13
13
  # Validation of this property is relaxed. See the openapi for full validation.
14
- attribute :location, Types::Strict::String.optional.meta(omittable: true)
14
+ attribute? :location, Types::Strict::String.optional
15
15
  # Validation of this property is relaxed. See the openapi for full validation.
16
- attribute :controlledDigitalLending, Types::Strict::Bool.optional.meta(omittable: true)
16
+ attribute? :controlledDigitalLending, Types::Strict::Bool.optional.default(false)
17
17
  # Date when the Collection is released from an embargo.
18
18
  # example: 2029-06-22T07:00:00.000+00:00
19
19
  attribute :releaseDate, Types::Params::DateTime
20
20
  # The human readable use and reproduction statement that applies when the embargo expires.
21
21
  # example: These materials are in the public domain.
22
- attribute :useAndReproductionStatement, Types::Strict::String.optional.meta(omittable: true)
22
+ attribute? :useAndReproductionStatement, Types::Strict::String.optional
23
23
  end
24
24
  end
25
25
  end
@@ -5,15 +5,15 @@ module Cocina
5
5
  class Event < Struct
6
6
  attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
7
  # Description of the event (creation, publication, etc.).
8
- attribute :type, Types::Strict::String.meta(omittable: true)
8
+ attribute? :type, Types::Strict::String
9
9
  # The preferred display label to use for the event in access systems.
10
- attribute :displayLabel, Types::Strict::String.meta(omittable: true)
10
+ attribute? :displayLabel, Types::Strict::String
11
11
  attribute :date, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
12
12
  attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
13
13
  attribute :location, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
14
14
  attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
15
15
  attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
16
- attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)
16
+ attribute? :valueLanguage, DescriptiveValueLanguage.optional
17
17
  attribute :parallelEvent, Types::Strict::Array.of(DescriptiveParallelEvent).default([].freeze)
18
18
  end
19
19
  end
@@ -16,17 +16,17 @@ module Cocina
16
16
  # Filename for a file. Can be same as label.
17
17
  attribute :filename, Types::Strict::String
18
18
  # Size of the File (binary) in bytes.
19
- attribute :size, Types::Strict::Integer.meta(omittable: true)
19
+ attribute? :size, Types::Strict::Integer
20
20
  # Version for the File within SDR.
21
21
  attribute :version, Types::Strict::Integer
22
22
  # MIME Type of the File.
23
- attribute :hasMimeType, Types::Strict::String.meta(omittable: true)
23
+ attribute? :hasMimeType, Types::Strict::String
24
24
  # Use for the File.
25
- attribute :use, Types::Strict::String.meta(omittable: true)
25
+ attribute? :use, Types::Strict::String
26
26
  attribute :hasMessageDigests, Types::Strict::Array.of(MessageDigest).default([].freeze)
27
27
  attribute(:access, FileAccess.default { FileAccess.new })
28
28
  attribute(:administrative, FileAdministrative.default { FileAdministrative.new })
29
- attribute :presentation, Presentation.optional.meta(omittable: true)
29
+ attribute? :presentation, Presentation.optional
30
30
  end
31
31
  end
32
32
  end