cocina-models 0.29.0 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -3
  3. data/README.md +11 -0
  4. data/cocina-models.gemspec +5 -0
  5. data/exe/generator +9 -0
  6. data/lib/cocina/generator.rb +18 -0
  7. data/lib/cocina/generator/generator.rb +80 -0
  8. data/lib/cocina/generator/schema.rb +84 -0
  9. data/lib/cocina/generator/schema_array.rb +20 -0
  10. data/lib/cocina/generator/schema_base.rb +49 -0
  11. data/lib/cocina/generator/schema_ref.rb +16 -0
  12. data/lib/cocina/generator/schema_value.rb +60 -0
  13. data/lib/cocina/generator/vocab.rb +63 -0
  14. data/lib/cocina/models.rb +51 -25
  15. data/lib/cocina/models/access.rb +10 -0
  16. data/lib/cocina/models/admin_policy.rb +13 -56
  17. data/lib/cocina/models/admin_policy_administrative.rb +11 -0
  18. data/lib/cocina/models/administrative.rb +14 -0
  19. data/lib/cocina/models/catalog_link.rb +4 -1
  20. data/lib/cocina/models/collection.rb +21 -31
  21. data/lib/cocina/models/collection_identification.rb +9 -0
  22. data/lib/cocina/models/description.rb +1 -8
  23. data/lib/cocina/models/dro.rb +34 -70
  24. data/lib/cocina/models/dro_access.rb +16 -0
  25. data/lib/cocina/models/dro_structural.rb +14 -0
  26. data/lib/cocina/models/embargo.rb +16 -0
  27. data/lib/cocina/models/file.rb +20 -36
  28. data/lib/cocina/models/file_administrative.rb +10 -0
  29. data/lib/cocina/models/file_set.rb +8 -15
  30. data/lib/cocina/models/file_set_structural.rb +9 -0
  31. data/lib/cocina/models/geographic.rb +10 -0
  32. data/lib/cocina/models/identification.rb +11 -0
  33. data/lib/cocina/models/message_digest.rb +17 -0
  34. data/lib/cocina/models/presentation.rb +12 -0
  35. data/lib/cocina/models/release_tag.rb +12 -7
  36. data/lib/cocina/models/request_admin_policy.rb +15 -3
  37. data/lib/cocina/models/request_collection.rb +21 -4
  38. data/lib/cocina/models/request_dro.rb +32 -11
  39. data/lib/cocina/models/request_dro_structural.rb +13 -0
  40. data/lib/cocina/models/request_file.rb +15 -6
  41. data/lib/cocina/models/request_file_set.rb +7 -9
  42. data/lib/cocina/models/request_file_set_structural.rb +9 -0
  43. data/lib/cocina/models/sequence.rb +2 -5
  44. data/lib/cocina/models/title.rb +12 -0
  45. data/lib/cocina/models/validator.rb +22 -0
  46. data/lib/cocina/models/version.rb +1 -1
  47. data/lib/cocina/models/vocab.rb +45 -60
  48. data/openapi.yml +695 -0
  49. metadata +101 -9
  50. data/lib/cocina/models/admin_policy_attributes.rb +0 -21
  51. data/lib/cocina/models/collection_attributes.rb +0 -22
  52. data/lib/cocina/models/dro_attributes.rb +0 -22
  53. data/lib/cocina/models/file_attributes.rb +0 -25
  54. data/lib/cocina/models/file_set_attributes.rb +0 -16
  55. data/lib/cocina/models/types.rb +0 -10
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class DROAccess < Struct
6
+ attribute :access, Types::Strict::String.default('dark').enum('world', 'stanford', 'location-based', 'citation-only', 'dark').meta(omittable: true)
7
+ # The human readable copyright statement that applies
8
+ # example: Copyright World Trade Organization
9
+ attribute :copyright, Types::Strict::String.meta(omittable: true)
10
+ # The human readable use and reproduction statement that applies
11
+ # 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).
12
+ attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
13
+ attribute :embargo, Embargo.optional.meta(omittable: true)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class DROStructural < Struct
6
+ attribute :contains, Types::Strict::Array.of(FileSet).meta(omittable: true)
7
+ attribute :hasMemberOrders, Types::Strict::Array.of(Sequence).meta(omittable: true)
8
+ # example: druid:bc123df4567
9
+ attribute :isMemberOf, Types::Strict::String.meta(omittable: true)
10
+ # Agreement that covers the deposit of the DRO into SDR.
11
+ attribute :hasAgreement, Types::Strict::String.meta(omittable: true)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class Embargo < Struct
6
+ # Date when the Collection is released from an embargo.
7
+ # example: 2029-06-22T07:00:00.000+00:00
8
+ attribute :releaseDate, Types::Params::DateTime
9
+ # Access level that applies when embargo expires.
10
+ attribute :access, Types::Strict::String.enum('world', 'stanford', 'location-based', 'citation-only', 'dark')
11
+ # The human readable use and reproduction statement that applies when the embargo expires.
12
+ # example: These materials are in the public domain.
13
+ attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
14
+ end
15
+ end
16
+ end
@@ -2,47 +2,31 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # Metadata for a file.
6
- # See http://sul-dlss.github.io/cocina-models/maps/File.json
7
5
  class File < Struct
8
6
  include Checkable
9
7
 
10
- TYPES = [
11
- Vocab.file
12
- ].freeze
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/file.jsonld'].freeze
13
9
 
14
- # Represents access controls on the file
15
- class Access < Struct
16
- attribute :access, Types::String.default('dark')
17
- .enum('world', 'stanford', 'location-based', 'citation-only', 'dark')
18
- end
19
-
20
- # Represents the administration of the file
21
- class Administrative < Struct
22
- attribute :sdrPreserve, Types::Strict::Bool.optional.default(true)
23
- attribute :shelve, Types::Strict::Bool.optional.default(false)
24
- end
25
-
26
- # Represents a digest (checksum) value for a file
27
- class Fixity < Struct
28
- attribute :type, Types::String.enum('md5', 'sha1')
29
- attribute :digest, Types::Strict::String
30
- end
31
-
32
- class Identification < Struct
33
- end
34
-
35
- # Represents some technical aspect of the file
36
- class Presentation < Struct
37
- attribute :height, Types::Strict::Integer.optional.default(nil)
38
- attribute :width, Types::Strict::Integer.optional.default(nil)
39
- end
40
-
41
- class Structural < Struct
42
- end
43
-
44
- include FileAttributes
10
+ # The content type of the File.
11
+ attribute :type, Types::Strict::String.enum(*File::TYPES)
12
+ # Identifier for the resource within the SDR architecture but outside of the repository. UUID. Constant across resource versions. What clients will use calling the repository.
45
13
  attribute :externalIdentifier, Types::Strict::String
14
+ # Primary processing label (can be same as title) for a File.
15
+ attribute :label, Types::Strict::String
16
+ # Filename for a file. Can be same as label.
17
+ attribute :filename, Types::Strict::String.meta(omittable: true)
18
+ # Size of the File (binary) in bytes.
19
+ attribute :size, Types::Strict::Integer.meta(omittable: true)
20
+ # Version for the File within SDR.
21
+ attribute :version, Types::Strict::Integer
22
+ # MIME Type of the File.
23
+ attribute :hasMimeType, Types::Strict::String.meta(omittable: true)
24
+ # Use for the File.
25
+ attribute :use, Types::Strict::String.meta(omittable: true)
26
+ attribute :hasMessageDigests, Types::Strict::Array.of(MessageDigest).default([].freeze)
27
+ attribute(:access, Access.default { Access.new })
28
+ attribute(:administrative, FileAdministrative.default { FileAdministrative.new })
29
+ attribute :presentation, Presentation.optional.meta(omittable: true)
46
30
  end
47
31
  end
48
32
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class FileAdministrative < Struct
6
+ attribute :sdrPreserve, Types::Strict::Bool.default(true)
7
+ attribute :shelve, Types::Strict::Bool.default(false)
8
+ end
9
+ end
10
+ end
@@ -2,26 +2,19 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # Metadata for a file set.
6
- # See http://sul-dlss.github.io/cocina-models/maps/Fileset.json
7
5
  class FileSet < Struct
8
6
  include Checkable
9
7
 
10
- TYPES = [
11
- Vocab.fileset
12
- ].freeze
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/fileset.jsonld'].freeze
13
9
 
14
- class Identification < Struct
15
- end
16
-
17
- # Structural sub-schema that contains File (unlike the one in RequestFileSet which contains RequestFile)
18
- class Structural < Struct
19
- attribute :contains, Types::Strict::Array.of(Cocina::Models::File).meta(omittable: true)
20
- end
21
-
22
- include FileSetAttributes
10
+ # The content type of the Fileset.
11
+ attribute :type, Types::Strict::String.enum(*FileSet::TYPES)
23
12
  attribute :externalIdentifier, Types::Strict::String
24
- attribute(:structural, Structural.default { Structural.new })
13
+ # Primary processing label for a Fileset.
14
+ attribute :label, Types::Strict::String
15
+ # Version for the Fileset within SDR.
16
+ attribute :version, Types::Strict::Integer
17
+ attribute :structural, FileSetStructural.optional.meta(omittable: true)
25
18
  end
26
19
  end
27
20
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class FileSetStructural < Struct
6
+ attribute :contains, Types::Strict::Array.of(File).meta(omittable: true)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class Geographic < Struct
6
+ # Geographic ISO 19139 XML metadata
7
+ attribute :iso19139, Types::Strict::String
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class Identification < Struct
6
+ # example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
7
+ attribute :sourceId, Types::Strict::String.meta(omittable: true)
8
+ attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).meta(omittable: true)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class MessageDigest < Struct
6
+ include Checkable
7
+
8
+ TYPES = %w[md5
9
+ sha1].freeze
10
+
11
+ # The algorithm that was used
12
+ attribute :type, Types::Strict::String.enum(*MessageDigest::TYPES)
13
+ # The digest value Base64 encoded
14
+ attribute :digest, Types::Strict::String
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class Presentation < Struct
6
+ # Height in pixels
7
+ attribute :height, Types::Strict::Integer.meta(omittable: true)
8
+ # Width in pixels
9
+ attribute :width, Types::Strict::Integer.meta(omittable: true)
10
+ end
11
+ end
12
+ end
@@ -2,14 +2,19 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # Subschema for release tags
6
5
  class ReleaseTag < Struct
7
- attribute :to, Types::Strict::String.enum('Searchworks', 'Earthworks')
8
- attribute :what, Types::Strict::String.enum('self', 'collection')
9
- # we use 'when' other places, but that's reserved word, so 'date' it is!
10
- attribute :date, Types::Params::DateTime
11
- attribute :who, Types::Strict::String
12
- attribute :release, Types::Strict::Bool
6
+ # Who did this release
7
+ # example: petucket
8
+ attribute :who, Types::Strict::String.meta(omittable: true)
9
+ # What is being released. This item or the whole collection.
10
+ # example: self
11
+ attribute :what, Types::Strict::String.enum('self', 'collection').meta(omittable: true)
12
+ # When did this action happen
13
+ attribute :date, Types::Params::DateTime.meta(omittable: true)
14
+ # What platform is it released to
15
+ # example: Searchworks
16
+ attribute :to, Types::Strict::String.meta(omittable: true)
17
+ attribute :release, Types::Strict::Bool.default(false)
13
18
  end
14
19
  end
15
20
  end
@@ -2,10 +2,22 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # A request to create an AdminPolicy object.
6
- # This is the same as an AdminPolicy, but without externalIdentifier (as that wouldn't have been created yet).
7
5
  class RequestAdminPolicy < Struct
8
- include AdminPolicyAttributes
6
+ include Checkable
7
+
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/admin_policy.jsonld'].freeze
9
+
10
+ # example: item
11
+ attribute :type, Types::Strict::String.enum(*RequestAdminPolicy::TYPES)
12
+ attribute :label, Types::Strict::String
13
+ attribute :version, Types::Strict::Integer
14
+ attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
15
+ attribute :description, Description.optional.meta(omittable: true)
16
+
17
+ def self.new(attributes = default_attributes, safe = false, validate = true, &block)
18
+ Validator.validate(self, attributes.with_indifferent_access) if validate
19
+ super(attributes, safe, &block)
20
+ end
9
21
  end
10
22
  end
11
23
  end
@@ -2,11 +2,28 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # A request to create a digital repository collection.
6
- # This is the same as a Collection, but without externalIdentifier (as that wouldn't have been created yet).
7
- # See http://sul-dlss.github.io/cocina-models/maps/Collection.json
8
5
  class RequestCollection < Struct
9
- include CollectionAttributes
6
+ include Checkable
7
+
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/collection.jsonld',
9
+ 'http://cocina.sul.stanford.edu/models/curated-collection.jsonld',
10
+ 'http://cocina.sul.stanford.edu/models/user-collection.jsonld',
11
+ 'http://cocina.sul.stanford.edu/models/exhibit.jsonld',
12
+ 'http://cocina.sul.stanford.edu/models/series.jsonld'].freeze
13
+
14
+ # example: item
15
+ attribute :type, Types::Strict::String.enum(*RequestCollection::TYPES)
16
+ attribute :label, Types::Strict::String
17
+ attribute :version, Types::Strict::Integer
18
+ attribute(:access, Access.default { Access.new })
19
+ attribute :administrative, Administrative.optional.meta(omittable: true)
20
+ attribute :description, Description.optional.meta(omittable: true)
21
+ attribute :identification, CollectionIdentification.optional.meta(omittable: true)
22
+
23
+ def self.new(attributes = default_attributes, safe = false, validate = true, &block)
24
+ Validator.validate(self, attributes.with_indifferent_access) if validate
25
+ super(attributes, safe, &block)
26
+ end
10
27
  end
11
28
  end
12
29
  end
@@ -2,19 +2,40 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # A request to create a digital repository object.
6
- # This is the same as a DRO, but without externalIdentifier (as that wouldn't have been created yet)
7
- # See http://sul-dlss.github.io/cocina-models/maps/DRO.json
8
5
  class RequestDRO < Struct
9
- # Structural sub-schema that contains RequestFileSet (unlike the DRO which contains FileSet)
10
- class Structural < Struct
11
- attribute :contains, Types::Strict::Array.of(RequestFileSet).meta(omittable: true)
12
- attribute :isMemberOf, Types::Strict::String.meta(omittable: true)
13
- attribute :hasMemberOrders, Types::Strict::Array.of(Sequence).meta(omittable: true)
14
- end
6
+ include Checkable
7
+
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/object.jsonld',
9
+ 'http://cocina.sul.stanford.edu/models/3d.jsonld',
10
+ 'http://cocina.sul.stanford.edu/models/agreement.jsonld',
11
+ 'http://cocina.sul.stanford.edu/models/book.jsonld',
12
+ 'http://cocina.sul.stanford.edu/models/document.jsonld',
13
+ 'http://cocina.sul.stanford.edu/models/geo.jsonld',
14
+ 'http://cocina.sul.stanford.edu/models/image.jsonld',
15
+ 'http://cocina.sul.stanford.edu/models/page.jsonld',
16
+ 'http://cocina.sul.stanford.edu/models/photograph.jsonld',
17
+ 'http://cocina.sul.stanford.edu/models/manuscript.jsonld',
18
+ 'http://cocina.sul.stanford.edu/models/map.jsonld',
19
+ 'http://cocina.sul.stanford.edu/models/media.jsonld',
20
+ 'http://cocina.sul.stanford.edu/models/track.jsonld',
21
+ 'http://cocina.sul.stanford.edu/models/webarchive-binary.jsonld',
22
+ 'http://cocina.sul.stanford.edu/models/webarchive-seed.jsonld'].freeze
15
23
 
16
- include DroAttributes
17
- attribute(:structural, Structural.default { Structural.new })
24
+ # example: item
25
+ attribute :type, Types::Strict::String.enum(*RequestDRO::TYPES)
26
+ attribute :label, Types::Strict::String
27
+ attribute :version, Types::Strict::Integer
28
+ attribute :access, DROAccess.optional.meta(omittable: true)
29
+ attribute :administrative, Administrative.optional.meta(omittable: true)
30
+ attribute :description, Description.optional.meta(omittable: true)
31
+ attribute :identification, Identification.optional.meta(omittable: true)
32
+ attribute :structural, RequestDROStructural.optional.meta(omittable: true)
33
+ attribute :geographic, Geographic.optional.meta(omittable: true)
34
+
35
+ def self.new(attributes = default_attributes, safe = false, validate = true, &block)
36
+ Validator.validate(self, attributes.with_indifferent_access) if validate
37
+ super(attributes, safe, &block)
38
+ end
18
39
  end
19
40
  end
20
41
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class RequestDROStructural < Struct
6
+ attribute :contains, Types::Strict::Array.of(RequestFileSet).meta(omittable: true)
7
+ attribute :hasMemberOrders, Types::Strict::Array.of(Sequence).meta(omittable: true)
8
+ # example: druid:bc123df4567
9
+ attribute :isMemberOf, Types::Strict::String.meta(omittable: true)
10
+ attribute :hasAgreement, Types::Strict::String.meta(omittable: true)
11
+ end
12
+ end
13
+ end
@@ -2,14 +2,23 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # a request to create a File object.
6
- # This is the same as a File, but without externalIdentifier (as that wouldn't have been created yet)
7
- # See http://sul-dlss.github.io/cocina-models/maps/File.json
8
5
  class RequestFile < Struct
9
- include FileAttributes
10
- # externalIdentifier is used when submitting files to the SDR API to identify the file so that the
11
- # uploaded files can be associated with the DRO.
6
+ include Checkable
7
+
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/file.jsonld'].freeze
9
+
10
+ attribute :type, Types::Strict::String.enum(*RequestFile::TYPES)
11
+ attribute :label, Types::Strict::String
12
+ attribute :filename, Types::Strict::String
13
+ attribute :size, Types::Strict::Integer.meta(omittable: true)
14
+ attribute :version, Types::Strict::Integer
15
+ attribute :hasMimeType, Types::Strict::String.meta(omittable: true)
12
16
  attribute :externalIdentifier, Types::Strict::String.meta(omittable: true)
17
+ attribute :use, Types::Strict::String.meta(omittable: true)
18
+ attribute :hasMessageDigests, Types::Strict::Array.of(MessageDigest).default([].freeze)
19
+ attribute(:access, Access.default { Access.new })
20
+ attribute(:administrative, FileAdministrative.default { FileAdministrative.new })
21
+ attribute :presentation, Presentation.optional.meta(omittable: true)
13
22
  end
14
23
  end
15
24
  end
@@ -2,17 +2,15 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # A request to create a FileSet object.
6
- # This is the same as a FileSet, but without externalIdentifier (as that wouldn't have been created yet)
7
- # See http://sul-dlss.github.io/cocina-models/maps/FileSet.json
8
5
  class RequestFileSet < Struct
9
- # Structural sub-schema that contains RequestFile (unlike the one in FileSet which contains File)
10
- class Structural < Struct
11
- attribute :contains, Types::Strict::Array.of(RequestFile).meta(omittable: true)
12
- end
6
+ include Checkable
13
7
 
14
- include FileSetAttributes
15
- attribute(:structural, Structural.default { Structural.new })
8
+ TYPES = ['http://cocina.sul.stanford.edu/models/fileset.jsonld'].freeze
9
+
10
+ attribute :type, Types::Strict::String.enum(*RequestFileSet::TYPES)
11
+ attribute :label, Types::Strict::String
12
+ attribute :version, Types::Strict::Integer
13
+ attribute(:structural, RequestFileSetStructural.default { RequestFileSetStructural.new })
16
14
  end
17
15
  end
18
16
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class RequestFileSetStructural < Struct
6
+ attribute :contains, Types::Strict::Array.of(RequestFile).meta(omittable: true)
7
+ end
8
+ end
9
+ end