hydra-works 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -8
  3. data/README.md +9 -9
  4. data/hydra-works.gemspec +3 -4
  5. data/lib/hydra/works.rb +22 -13
  6. data/lib/hydra/works/characterization.rb +31 -0
  7. data/lib/hydra/works/characterization/schema/audio_schema.rb +12 -0
  8. data/lib/hydra/works/characterization/schema/base_schema.rb +17 -0
  9. data/lib/hydra/works/characterization/schema/document_schema.rb +18 -0
  10. data/lib/hydra/works/characterization/schema/image_schema.rb +22 -0
  11. data/lib/hydra/works/characterization/schema/video_schema.rb +9 -0
  12. data/lib/hydra/works/models/characterization/already_there_strategy.rb +12 -0
  13. data/lib/hydra/works/models/characterization/fits_datastream.rb +162 -0
  14. data/lib/hydra/works/models/concerns/collection_behavior.rb +42 -34
  15. data/lib/hydra/works/models/concerns/file_set/characterization/audio.rb +14 -0
  16. data/lib/hydra/works/models/concerns/file_set/characterization/base.rb +23 -0
  17. data/lib/hydra/works/models/concerns/file_set/characterization/document.rb +10 -0
  18. data/lib/hydra/works/models/concerns/file_set/characterization/image.rb +10 -0
  19. data/lib/hydra/works/models/concerns/file_set/characterization/video.rb +17 -0
  20. data/lib/hydra/works/models/concerns/{generic_file → file_set}/contained_files.rb +1 -1
  21. data/lib/hydra/works/models/concerns/file_set/derivatives.rb +27 -0
  22. data/lib/hydra/works/models/concerns/{generic_file → file_set}/mime_types.rb +1 -1
  23. data/lib/hydra/works/models/concerns/{generic_file → file_set}/versioned_content.rb +2 -2
  24. data/lib/hydra/works/models/concerns/{generic_file → file_set}/virus_check.rb +1 -1
  25. data/lib/hydra/works/models/concerns/file_set_behavior.rb +67 -0
  26. data/lib/hydra/works/models/concerns/generic_file_behavior.rb +4 -50
  27. data/lib/hydra/works/models/concerns/generic_work_behavior.rb +5 -77
  28. data/lib/hydra/works/models/concerns/work_behavior.rb +118 -0
  29. data/lib/hydra/works/models/file_set.rb +7 -0
  30. data/lib/hydra/works/models/generic_file.rb +8 -8
  31. data/lib/hydra/works/models/generic_work.rb +15 -4
  32. data/lib/hydra/works/models/work.rb +6 -0
  33. data/lib/hydra/works/services/{generic_file/add_file_to_generic_file.rb → add_file_to_file_set.rb} +20 -20
  34. data/lib/hydra/works/services/add_file_to_generic_file.rb +8 -0
  35. data/lib/hydra/works/services/characterization_service.rb +118 -0
  36. data/lib/hydra/works/services/persist_derivative.rb +35 -0
  37. data/lib/hydra/works/services/{generic_file/upload_file_to_generic_file.rb → upload_file_to_file_set.rb} +3 -3
  38. data/lib/hydra/works/services/upload_file_to_generic_file.rb +8 -0
  39. data/lib/hydra/works/version.rb +1 -1
  40. data/lib/hydra/works/vocab/works_terms.rb +2 -2
  41. data/spec/fixtures/fits_0.6.2_avi.xml +29 -0
  42. data/spec/fixtures/fits_0.6.2_jp2.xml +36 -0
  43. data/spec/fixtures/fits_0.6.2_jpg.xml +43 -0
  44. data/spec/fixtures/fits_0.6.2_pdf.xml +42 -0
  45. data/spec/fixtures/fits_0.8.5_avi.xml +50 -0
  46. data/spec/fixtures/fits_0.8.5_docx.xml +41 -0
  47. data/spec/fixtures/fits_0.8.5_jp2.xml +51 -0
  48. data/spec/fixtures/fits_0.8.5_mp3.xml +47 -0
  49. data/spec/fixtures/fits_0.8.5_mp4.xml +47 -0
  50. data/spec/fixtures/fits_0.8.5_pdf.xml +54 -0
  51. data/spec/fixtures/pdf_fits.xml +54 -0
  52. data/spec/hydra/works/models/collection_spec.rb +58 -326
  53. data/spec/hydra/works/models/concerns/{generic_file → file_set}/contained_files_spec.rb +16 -16
  54. data/spec/hydra/works/models/concerns/{generic_file → file_set}/mime_types_spec.rb +2 -2
  55. data/spec/hydra/works/models/concerns/file_set/versioned_content_spec.rb +32 -0
  56. data/spec/hydra/works/models/concerns/{generic_file → file_set}/virus_check_spec.rb +3 -3
  57. data/spec/hydra/works/models/concerns/file_set_behavior_spec.rb +12 -0
  58. data/spec/hydra/works/models/generic_file_spec.rb +16 -13
  59. data/spec/hydra/works/models/generic_work_spec.rb +148 -318
  60. data/spec/hydra/works/services/{generic_file/add_file_to_generic_file_spec.rb → add_file_to_file_set_spec.rb} +4 -4
  61. data/spec/hydra/works/services/characterization_service_spec.rb +199 -0
  62. data/spec/hydra/works/services/persist_derivatives_spec.rb +57 -29
  63. data/spec/hydra/works/services/{generic_file/upload_file_spec.rb → upload_file_spec.rb} +7 -17
  64. data/spec/hydra/works_spec.rb +23 -59
  65. data/spec/spec_helper.rb +4 -2
  66. data/spec/support/file_set_helper.rb +14 -0
  67. metadata +84 -55
  68. data/lib/hydra/works/errors/full_text_extraction_error.rb +0 -5
  69. data/lib/hydra/works/models/concerns/block_child_objects.rb +0 -22
  70. data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +0 -26
  71. data/lib/hydra/works/services/generic_file/full_text_extraction_service.rb +0 -57
  72. data/lib/hydra/works/services/generic_file/generate_thumbnail.rb +0 -13
  73. data/lib/hydra/works/services/generic_file/persist_derivative.rb +0 -20
  74. data/spec/hydra/works/models/concerns/block_child_objects_spec.rb +0 -17
  75. data/spec/hydra/works/models/concerns/generic_file/versioned_content_spec.rb +0 -32
  76. data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +0 -12
  77. data/spec/hydra/works/services/full_text_extraction_service_spec.rb +0 -89
  78. data/spec/hydra/works/services/generic_file/generate/thumbnail_spec.rb +0 -19
@@ -3,10 +3,10 @@ module Hydra::Works
3
3
  #
4
4
  # behavior:
5
5
  # 1) Hydra::Works::Collection can aggregate Hydra::Works::Collection
6
- # 2) Hydra::Works::Collection can aggregate Hydra::Works::GenericWork
6
+ # 2) Hydra::Works::Collection can aggregate Hydra::Works::Work
7
7
 
8
8
  # 3) Hydra::Works::Collection can NOT aggregate Hydra::PCDM::Collection unless it is also a Hydra::Works::Collection
9
- # 4) Hydra::Works::Collection can NOT aggregate Hydra::Works::GenericFile
9
+ # 4) Hydra::Works::Collection can NOT aggregate Hydra::Works::FileSet
10
10
  # 5) Hydra::Works::Collection can NOT aggregate non-PCDM object
11
11
  # 6) Hydra::Works::Collection can NOT contain Hydra::PCDM::File
12
12
  # 7) Hydra::Works::Collection can NOT contain
@@ -15,77 +15,85 @@ module Hydra::Works
15
15
  # 9) Hydra::Works::Collection can have access metadata
16
16
  module CollectionBehavior
17
17
  extend ActiveSupport::Concern
18
+ extend Deprecation
19
+ self.deprecation_horizon = "Hydra::Works 0.4.0"
18
20
  include Hydra::PCDM::CollectionBehavior
19
21
 
20
22
  included do
21
23
  type [Hydra::PCDM::Vocab::PCDMTerms.Collection, Vocab::WorksTerms.Collection]
22
- include Hydra::Works::BlockChildObjects
23
24
 
24
- filters_association :members, as: :collections, condition: :works_collection?
25
- filters_association :members, as: :generic_works, condition: :works_generic_work?
25
+ alias_method :generic_works, :works
26
+ deprecation_deprecate :generic_works
27
+ end
28
+
29
+ def ordered_works
30
+ ordered_members.to_a.select(&:work?)
31
+ end
32
+
33
+ def ordered_work_ids
34
+ ordered_works.map(&:id)
35
+ end
36
+
37
+ def works
38
+ members.select(&:work?)
39
+ end
40
+
41
+ def work_ids
42
+ works.map(&:id)
26
43
  end
27
44
 
28
45
  # @return [Boolean] whether this instance is a Hydra::Works Collection.
29
- def works_collection?
46
+ def collection?
30
47
  true
31
48
  end
32
49
 
50
+ alias_method :works_collection?, :collection?
51
+ deprecation_deprecate :works_collection?
52
+
33
53
  # @return [Boolean] whether this instance is a Hydra::Works Generic Work.
34
- def works_generic_work?
54
+ def work?
35
55
  false
36
56
  end
37
57
 
38
- # @return [Boolean] whether this instance is a Hydra::Works Generic File.
39
- def works_generic_file?
58
+ alias_method :works_generic_work?, :work?
59
+ deprecation_deprecate :works_generic_work?
60
+
61
+ # @return [Boolean] whether this instance is a Hydra::Works::FileSet.
62
+ def file_set?
40
63
  false
41
64
  end
42
65
 
43
- def member_of
44
- aggregated_by
45
- end
66
+ alias_method :works_generic_file?, :file_set?
67
+ deprecation_deprecate :works_generic_file?
46
68
 
47
69
  def parents
48
- warn '[DEPRECATION] `parents` is deprecated in Hydra::Works. Please use `member_of` instead. This has a target date for removal of 10-31-2015'
70
+ Deprecation.warn CollectionBehavior, '`parents` is deprecated in Hydra::Works. Please use `member_of` instead. This has a target date for removal of 10-31-2015'
49
71
  member_of
50
72
  end
51
73
 
52
- def in_collections
53
- aggregated_by.select { |parent| parent.class.included_modules.include?(Hydra::Works::CollectionBehavior) }
54
- end
55
-
56
74
  def parent_collections
57
- warn '[DEPRECATION] `parent_collections` is deprecated in Hydra::Works. Please use `in_collections` instead. This has a target date for removal of 10-31-2015'
75
+ Deprecation.warn CollectionBehavior, '`parent_collections` is deprecated in Hydra::Works. Please use `in_collections` instead. This has a target date for removal of 10-31-2015'
58
76
  in_collections
59
77
  end
60
78
 
61
79
  def child_collections
62
- warn '[DEPRECATION] `child_collections` is deprecated in Hydra::Works. Please use `collections` instead. This has a target date for removal of 10-31-2015'
80
+ Deprecation.warn CollectionBehavior, '`child_collections` is deprecated in Hydra::Works. Please use `collections` instead. This has a target date for removal of 10-31-2015'
63
81
  collections
64
82
  end
65
83
 
66
- def child_collections=(new_collections)
67
- warn '[DEPRECATION] `child_collections=` is deprecated in Hydra::Works. Please use `collections=` instead. This has a target date for removal of 10-31-2015'
68
- self.collections = new_collections
69
- end
70
-
71
84
  def child_collection_ids
72
- warn '[DEPRECATION] `child_collection_ids` is deprecated in Hydra::Works. Please use `collection_ids` instead. This has a target date for removal of 10-31-2015'
85
+ Deprecation.warn CollectionBehavior, '`child_collection_ids` is deprecated in Hydra::Works. Please use `collection_ids` instead. This has a target date for removal of 10-31-2015'
73
86
  collection_ids
74
87
  end
75
88
 
76
89
  def child_generic_works
77
- warn '[DEPRECATION] `child_generic_works` is deprecated in Hydra::Works. Please use `generic_works` instead. This has a target date for removal of 10-31-2015'
78
- generic_works
79
- end
80
-
81
- def child_generic_works=(new_generic_works)
82
- warn '[DEPRECATION] `child_generic_works=` is deprecated in Hydra::Works. Please use `generic_works=` instead. This has a target date for removal of 10-31-2015'
83
- self.generic_works = new_generic_works
90
+ Deprecation.warn CollectionBehavior, '`child_generic_works` is deprecated in Hydra::Works. Please use `works` instead. This has a target date for removal of 10-31-2015'
91
+ works
84
92
  end
85
93
 
86
94
  def child_generic_work_ids
87
- warn '[DEPRECATION] `child_generic_work_ids` is deprecated in Hydra::Works. Please use `generic_work_ids` instead. This has a target date for removal of 10-31-2015'
88
- generic_work_ids
95
+ Deprecation.warn CollectionBehavior, '`child_generic_work_ids` is deprecated in Hydra::Works. Please use `work_ids` instead. This has a target date for removal of 10-31-2015'
96
+ work_ids
89
97
  end
90
98
  end
91
99
  end
@@ -0,0 +1,14 @@
1
+ module Hydra::Works::Characterization
2
+ module Audio
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # Apply the audio schema. This will add properties defined in the schema.
7
+ apply_schema AudioSchema, AlreadyThereStrategy
8
+
9
+ # Update the configuration to map the parsed terms to the correct property.
10
+ parser_mapping.merge!(audio_sample_rate: :sample_rate,
11
+ audio_duration: :duration)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ module Hydra::Works::Characterization
2
+ module Base
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # Apply the base schema. This will add properties defined in the schema.
7
+ apply_schema BaseSchema, AlreadyThereStrategy
8
+
9
+ # Parser config is :term => :property.
10
+ # Use this config to override the default behavior of value assignment which is:
11
+ # value is assigned to the property with the same name as the characterization term.
12
+ # use parser_config.merge! for subsequent modules.
13
+ class_attribute :parser_mapping
14
+ self.parser_mapping = { exif_tool_version: :exif_version,
15
+ file_mime_type: :mime_type }
16
+
17
+ # Parser class is an OM terminology.
18
+ # It maps the characterization tool's output xml to terms and values.
19
+ class_attribute :parser_class
20
+ self.parser_class = FitsDatastream
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ module Hydra::Works::Characterization
2
+ module Document
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # Apply the document schema. This will add properties defined in the schema.
7
+ apply_schema DocumentSchema, AlreadyThereStrategy
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Hydra::Works::Characterization
2
+ module Image
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # Apply the image schema. This will add properties defined in the schema.
7
+ apply_schema ImageSchema, AlreadyThereStrategy
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module Hydra::Works::Characterization
2
+ module Video
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # Apply the module schema. This will add properties defined in the schema.
7
+ apply_schema VideoSchema, AlreadyThereStrategy
8
+
9
+ # Update the configuration to map the parsed terms to the correct property.
10
+ parser_mapping.merge!(video_sample_rate: :sample_rate,
11
+ video_audio_sample_rate: :sample_rate,
12
+ video_duration: :duration,
13
+ video_width: :width,
14
+ video_height: :height)
15
+ end
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
- module Hydra::Works::GenericFile::ContainedFiles
1
+ module Hydra::Works::ContainedFiles
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  # HydraWorks supports only one each of original_file, thumbnail, and extracted_text. However
@@ -0,0 +1,27 @@
1
+ module Hydra::Works
2
+ module Derivatives
3
+ extend ActiveSupport::Concern
4
+ include Hydra::Derivatives
5
+
6
+ included do
7
+ # Sets output_file_service to PersistDerivative instead of default Hydra::Derivatives::PersistBasicContainedOutputFileService
8
+ Hydra::Derivatives.output_file_service = Hydra::Works::PersistDerivative
9
+ end
10
+
11
+ # Note, these derivatives are being fetched from Fedora, so there may be more
12
+ # network traffic than necessary. If you want to avoid this, set up a
13
+ # source_file_service that fetches the files locally, as is done in CurationConcerns.
14
+ def create_derivatives
15
+ case original_file.mime_type
16
+ when *self.class.pdf_mime_types
17
+ Hydra::Derivatives::PdfDerivatives.create(self, source: :original_file, outputs: [{ label: :thumbnail, format: 'jpg', size: '338x493', object: self }])
18
+ when *self.class.office_document_mime_types
19
+ Hydra::Derivatives::DocumentDerivatives.create(self, source: :original_file, outputs: [{ label: :thumbnail, format: 'jpg', size: '200x150>', object: self }])
20
+ when *self.class.video_mime_types
21
+ Hydra::Derivatives::VideoDerivatives.create(self, source: :original_file, outputs: [{ label: :thumbnail, format: 'jpg', object: self }])
22
+ when *self.class.image_mime_types
23
+ Hydra::Derivatives::ImageDerivatives.create(self, source: :original_file, outputs: [{ label: :thumbnail, format: 'jpg', size: '200x150>', object: self }])
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # This was taken directly from Sufia's GenericFile::MimeTypes
2
- module Hydra::Works::GenericFile
2
+ module Hydra::Works
3
3
  module MimeTypes
4
4
  extend ActiveSupport::Concern
5
5
 
@@ -1,5 +1,5 @@
1
- module Hydra::Works::GenericFile
2
- # Allows a GenericFile to treat the version history of the original_file as the GenericFile's version history
1
+ module Hydra::Works
2
+ # Allows a FileSet to treat the version history of the original_file as the FileSet's version history
3
3
  module VersionedContent
4
4
  def content_versions
5
5
  original_file.versions.all
@@ -1,4 +1,4 @@
1
- module Hydra::Works::GenericFile
1
+ module Hydra::Works
2
2
  module VirusCheck
3
3
  extend ActiveSupport::Concern
4
4
 
@@ -0,0 +1,67 @@
1
+ module Hydra::Works
2
+ # This module provides all of the Behaviors of a Hydra::Works::GenericFile
3
+ #
4
+ # behavior:
5
+ # 1) Hydra::Works::FileSet can contain (pcdm:hasFile) Hydra::PCDM::File (inherits from Hydra::PCDM::Object)
6
+ # 2) Hydra::Works::FileSet can contain (pcdm:hasRelatedFile) Hydra::PCDM::File (inherits from Hydra::PCDM::Object)
7
+ # 3) Hydra::Works::FileSet can aggregate (pcdm:hasMember) Hydra::Works::FileSet
8
+ # 4) Hydra::Works::FileSet can NOT aggregate anything other than Hydra::Works::FileSets
9
+ # 5) Hydra::Works::FileSet can have descriptive metadata
10
+ # 6) Hydra::Works::FileSet can have access metadata
11
+ module FileSetBehavior
12
+ extend ActiveSupport::Concern
13
+ extend Deprecation
14
+ self.deprecation_horizon = "Hydra::Works 0.4.0"
15
+ include Hydra::PCDM::ObjectBehavior
16
+
17
+ included do
18
+ type [Hydra::PCDM::Vocab::PCDMTerms.Object, Vocab::WorksTerms.FileSet]
19
+
20
+ include Hydra::Works::ContainedFiles
21
+ include Hydra::Works::Derivatives
22
+ include Hydra::Works::MimeTypes
23
+ include Hydra::Works::VersionedContent
24
+ end
25
+
26
+ # @return [Boolean] whether this instance is a Hydra::Works Collection.
27
+ def collection?
28
+ false
29
+ end
30
+
31
+ alias_method :works_collection?, :collection?
32
+ deprecation_deprecate :works_collection?
33
+
34
+ # @return [Boolean] whether this instance is a Hydra::Works Generic Work.
35
+ def work?
36
+ false
37
+ end
38
+
39
+ alias_method :works_generic_work?, :work?
40
+ deprecation_deprecate :works_generic_work?
41
+
42
+ # @return [Boolean] whether this instance is a Hydra::Works::FileSet.
43
+ def file_set?
44
+ true
45
+ end
46
+
47
+ alias_method :works_generic_file?, :file_set?
48
+ deprecation_deprecate :works_generic_file?
49
+
50
+ def parents
51
+ Deprecation.warn GenericFileBehavior, '`parents` is deprecated in Hydra::Works. Please use `member_of` instead. This has a target date for removal of 10-31-2015'
52
+ member_of
53
+ end
54
+
55
+ def in_works
56
+ ordered_by.select { |parent| parent.class.included_modules.include?(Hydra::Works::WorkBehavior) }.to_a
57
+ end
58
+
59
+ alias_method :in_generic_works, :in_works
60
+ deprecation_deprecate :in_generic_works
61
+
62
+ def generic_works
63
+ Deprecation.warn GenericFileBehavior, '`generic_works` is deprecated in Hydra::Works. Please use `in_works` instead. This has a target date for removal of 10-31-2015'
64
+ in_works
65
+ end
66
+ end
67
+ end
@@ -1,58 +1,12 @@
1
1
  module Hydra::Works
2
- # This module provides all of the Behaviors of a Hydra::Works::GenericFile
3
- #
4
- # behavior:
5
- # 1) Hydra::Works::GenericFile can contain (pcdm:hasFile) Hydra::PCDM::File (inherits from Hydra::PCDM::Object)
6
- # 2) Hydra::Works::GenericFile can contain (pcdm:hasRelatedFile) Hydra::PCDM::File (inherits from Hydra::PCDM::Object)
7
- # 3) Hydra::Works::GenericFile can aggregate (pcdm:hasMember) Hydra::Works::GenericFile
8
- # 4) Hydra::Works::GenericFile can NOT aggregate anything other than Hydra::Works::GenericFiles
9
- # 5) Hydra::Works::GenericFile can have descriptive metadata
10
- # 6) Hydra::Works::GenericFile can have access metadata
2
+ # @deprecated use FileSetBehavior instead
11
3
  module GenericFileBehavior
12
4
  extend ActiveSupport::Concern
13
- include Hydra::PCDM::ObjectBehavior
5
+ extend Deprecation
14
6
 
15
7
  included do
16
- type [Hydra::PCDM::Vocab::PCDMTerms.Object, Vocab::WorksTerms.GenericFile]
17
-
18
- include Hydra::Works::GenericFile::ContainedFiles
19
- include Hydra::Works::GenericFile::Derivatives
20
- include Hydra::Works::GenericFile::MimeTypes
21
- include Hydra::Works::GenericFile::VersionedContent
22
- include Hydra::Works::BlockChildObjects
23
- end
24
-
25
- # @return [Boolean] whether this instance is a Hydra::Works Collection.
26
- def works_collection?
27
- false
28
- end
29
-
30
- # @return [Boolean] whether this instance is a Hydra::Works Generic Work.
31
- def works_generic_work?
32
- false
33
- end
34
-
35
- # @return [Boolean] whether this instance is a Hydra::Works Generic File.
36
- def works_generic_file?
37
- true
38
- end
39
-
40
- def member_of
41
- aggregated_by
42
- end
43
-
44
- def parents
45
- warn '[DEPRECATION] `parents` is deprecated in Hydra::Works. Please use `member_of` instead. This has a target date for removal of 10-31-2015'
46
- member_of
47
- end
48
-
49
- def in_generic_works
50
- aggregated_by.select { |parent| parent.class.included_modules.include?(Hydra::Works::GenericWorkBehavior) }
51
- end
52
-
53
- def generic_works
54
- warn '[DEPRECATION] `generic_works` is deprecated in Hydra::Works. Please use `in_generic_works` instead. This has a target date for removal of 10-31-2015'
55
- in_generic_works
8
+ Deprecation.warn GenericFileBehavior, "GenericFileBehavior is deprecated. Use FileSetBehavior instead. This will be removed in Hydra::Works 0.4.0"
9
+ include FileSetBehavior
56
10
  end
57
11
  end
58
12
  end
@@ -1,84 +1,12 @@
1
1
  module Hydra::Works
2
- # This module provides all of the Behaviors of a Hydra::Works::GenericWork
3
- #
4
- # behavior:
5
- # 1) Hydra::Works::GenericWork can aggregate Hydra::Works::GenericWork
6
- # 2) Hydra::Works::GenericWork can aggregate Hydra::Works::GenericFile
7
- # 3) Hydra::Works::GenericWork can NOT aggregate Hydra::PCDM::Collection
8
- # 4) Hydra::Works::GenericWork can NOT aggregate Hydra::Works::Collection
9
- # 5) Hydra::Works::GenericWork can NOT aggregate Works::Object unless it is also a Hydra::Works::GenericFile
10
- # 6) Hydra::Works::GenericWork can NOT contain PCDM::File
11
- # 7) Hydra::Works::GenericWork can NOT aggregate non-PCDM object
12
- # 8) Hydra::Works::GenericWork can NOT contain Hydra::Works::GenericFile
13
- # 9) Hydra::Works::GenericWork can have descriptive metadata
14
- # 10) Hydra::Works::GenericWork can have access metadata
2
+ # @deprecated use Hydra::Works::WorkBehavior instead
15
3
  module GenericWorkBehavior
16
4
  extend ActiveSupport::Concern
17
- include Hydra::PCDM::ObjectBehavior
18
-
5
+ extend Deprecation
6
+ self.deprecation_horizon = "Hydra::Works 0.4.0"
19
7
  included do
20
- type [Hydra::PCDM::Vocab::PCDMTerms.Object, Vocab::WorksTerms.GenericWork]
21
- include Hydra::Works::BlockChildObjects
22
-
23
- filters_association :members, as: :generic_works, condition: :works_generic_work?
24
- filters_association :members, as: :generic_files, condition: :works_generic_file?
25
- end
26
-
27
- # @return [Boolean] whether this instance is a Hydra::Works Collection.
28
- def works_collection?
29
- false
30
- end
31
-
32
- # @return [Boolean] whether this instance is a Hydra::Works Generic Work.
33
- def works_generic_work?
34
- true
35
- end
36
-
37
- # @return [Boolean] whether this instance is a Hydra::Works Generic File.
38
- def works_generic_file?
39
- false
40
- end
41
-
42
- def member_of
43
- aggregated_by
44
- end
45
-
46
- def parents
47
- warn '[DEPRECATION] `parents` is deprecated in Hydra::Works. Please use `member_of` instead. This has a target date for removal of 10-31-2015'
48
- member_of
49
- end
50
-
51
- def in_generic_works
52
- aggregated_by.select { |parent| parent.class.included_modules.include?(Hydra::Works::GenericWorkBehavior) }
53
- end
54
-
55
- def parent_generic_works
56
- warn '[DEPRECATION] `parent_generic_works` is deprecated in Hydra::Works. Please use `in_generic_works` instead. This has a target date for removal of 10-31-2015'
57
- in_generic_works
58
- end
59
-
60
- def in_collections
61
- aggregated_by.select { |parent| parent.class.included_modules.include?(Hydra::Works::CollectionBehavior) }
62
- end
63
-
64
- def parent_collections
65
- warn '[DEPRECATION] `parent_collections` is deprecated in Hydra::Works. Please use `in_collections` instead. This has a target date for removal of 10-31-2015'
66
- in_collections
67
- end
68
-
69
- def child_generic_works
70
- warn '[DEPRECATION] `child_generic_works` is deprecated in Hydra::Works. Please use `generic_works` instead. This has a target date for removal of 10-31-2015'
71
- generic_works
72
- end
73
-
74
- def child_generic_works=(new_generic_works)
75
- warn '[DEPRECATION] `child_generic_works=` is deprecated in Hydra::Works. Please use `generic_works=` instead. This has a target date for removal of 10-31-2015'
76
- self.generic_works = new_generic_works
77
- end
78
-
79
- def child_generic_work_ids
80
- warn '[DEPRECATION] `child_generic_work_ids` is deprecated in Hydra::Works. Please use `generic_work_ids` instead. This has a target date for removal of 10-31-2015'
81
- generic_work_ids
8
+ Deprecation.warn self, "GenericWorkBehavior is deprecated. Use WorkBehavior instead. This module will be removed in Hydra::Works 0.4.0"
9
+ include Hydra::Works::WorkBehavior
82
10
  end
83
11
  end
84
12
  end