hydra-works 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.travis.yml +2 -5
  4. data/Gemfile +1 -3
  5. data/README.md +28 -13
  6. data/hydra-works.gemspec +4 -3
  7. data/lib/hydra/works.rb +7 -57
  8. data/lib/hydra/works/models/concerns/block_child_objects.rb +16 -0
  9. data/lib/hydra/works/models/concerns/collection_behavior.rb +27 -2
  10. data/lib/hydra/works/models/concerns/generic_file/contained_files.rb +5 -13
  11. data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +9 -13
  12. data/lib/hydra/works/models/concerns/generic_file/mime_types.rb +14 -9
  13. data/lib/hydra/works/models/concerns/generic_file/versioned_content.rb +18 -0
  14. data/lib/hydra/works/models/concerns/generic_file/virus_check.rb +48 -0
  15. data/lib/hydra/works/models/concerns/generic_file_behavior.rb +24 -1
  16. data/lib/hydra/works/models/concerns/generic_work_behavior.rb +32 -3
  17. data/lib/hydra/works/models/generic_file.rb +3 -0
  18. data/lib/hydra/works/services/generic_file/add_file_to_generic_file.rb +127 -0
  19. data/lib/hydra/works/services/generic_file/generate/thumbnail.rb +1 -2
  20. data/lib/hydra/works/services/generic_file/persist_derivative.rb +22 -0
  21. data/lib/hydra/works/services/generic_file/upload_file.rb +11 -19
  22. data/lib/hydra/works/version.rb +1 -1
  23. data/lib/hydra/works/vocab/works_terms.rb +1 -1
  24. data/spec/fixtures/Example.ogg +0 -0
  25. data/spec/fixtures/charter.docx +0 -0
  26. data/spec/fixtures/countdown.avi +0 -0
  27. data/spec/fixtures/image.jp2 +0 -0
  28. data/spec/fixtures/piano_note.wav +0 -0
  29. data/spec/fixtures/test5.mp3 +0 -0
  30. data/spec/fixtures/world.png +0 -0
  31. data/spec/hydra/works/models/collection_spec.rb +499 -16
  32. data/spec/hydra/works/models/concerns/block_child_objects_spec.rb +19 -0
  33. data/spec/hydra/works/models/concerns/{file → generic_file}/contained_files_spec.rb +20 -17
  34. data/spec/hydra/works/models/concerns/generic_file/mime_types_spec.rb +76 -0
  35. data/spec/hydra/works/models/concerns/generic_file/versioned_content_spec.rb +32 -0
  36. data/spec/hydra/works/models/concerns/generic_file/virus_check_spec.rb +50 -0
  37. data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +1 -1
  38. data/spec/hydra/works/models/generic_file_spec.rb +201 -14
  39. data/spec/hydra/works/models/generic_work_spec.rb +530 -14
  40. data/spec/hydra/works/services/generic_file/add_file_to_generic_file_spec.rb +110 -0
  41. data/spec/hydra/works/services/generic_file/upload_file_spec.rb +45 -28
  42. data/spec/hydra/works/services/persist_derivatives_spec.rb +93 -0
  43. data/spec/hydra/works_spec.rb +35 -35
  44. data/spec/spec_helper.rb +6 -0
  45. metadata +56 -95
  46. data/lib/hydra/works/models/concerns/aggregates_collections.rb +0 -16
  47. data/lib/hydra/works/models/concerns/aggregates_generic_files.rb +0 -20
  48. data/lib/hydra/works/models/concerns/aggregates_generic_works.rb +0 -20
  49. data/lib/hydra/works/processor.rb +0 -9
  50. data/lib/hydra/works/services/collection/add_collection.rb +0 -19
  51. data/lib/hydra/works/services/collection/add_generic_work.rb +0 -19
  52. data/lib/hydra/works/services/collection/add_related_object.rb +0 -19
  53. data/lib/hydra/works/services/collection/get_collections.rb +0 -17
  54. data/lib/hydra/works/services/collection/get_generic_works.rb +0 -17
  55. data/lib/hydra/works/services/collection/get_related_objects.rb +0 -17
  56. data/lib/hydra/works/services/collection/remove_collection.rb +0 -19
  57. data/lib/hydra/works/services/collection/remove_generic_work.rb +0 -20
  58. data/lib/hydra/works/services/collection/remove_related_object.rb +0 -19
  59. data/lib/hydra/works/services/generic_file/add_file.rb +0 -55
  60. data/lib/hydra/works/services/generic_file/add_generic_file.rb +0 -19
  61. data/lib/hydra/works/services/generic_file/add_original_file.rb +0 -11
  62. data/lib/hydra/works/services/generic_file/add_related_object.rb +0 -19
  63. data/lib/hydra/works/services/generic_file/add_versioned_original_file.rb +0 -10
  64. data/lib/hydra/works/services/generic_file/get_generic_files.rb +0 -17
  65. data/lib/hydra/works/services/generic_file/get_related_objects.rb +0 -17
  66. data/lib/hydra/works/services/generic_file/remove_generic_file.rb +0 -20
  67. data/lib/hydra/works/services/generic_file/remove_related_object.rb +0 -19
  68. data/lib/hydra/works/services/generic_work/add_generic_file.rb +0 -19
  69. data/lib/hydra/works/services/generic_work/add_generic_work.rb +0 -19
  70. data/lib/hydra/works/services/generic_work/add_related_object.rb +0 -19
  71. data/lib/hydra/works/services/generic_work/get_generic_files.rb +0 -17
  72. data/lib/hydra/works/services/generic_work/get_generic_works.rb +0 -17
  73. data/lib/hydra/works/services/generic_work/get_related_objects.rb +0 -17
  74. data/lib/hydra/works/services/generic_work/move_generic_file.rb +0 -19
  75. data/lib/hydra/works/services/generic_work/remove_generic_file.rb +0 -20
  76. data/lib/hydra/works/services/generic_work/remove_generic_work.rb +0 -20
  77. data/lib/hydra/works/services/generic_work/remove_related_object.rb +0 -19
  78. data/spec/hydra/works/services/collection/add_collection_spec.rb +0 -166
  79. data/spec/hydra/works/services/collection/add_generic_work_spec.rb +0 -155
  80. data/spec/hydra/works/services/collection/add_related_object_spec.rb +0 -149
  81. data/spec/hydra/works/services/collection/get_collections_spec.rb +0 -35
  82. data/spec/hydra/works/services/collection/get_generic_works_spec.rb +0 -35
  83. data/spec/hydra/works/services/collection/get_related_objects_spec.rb +0 -49
  84. data/spec/hydra/works/services/collection/remove_collection_spec.rb +0 -133
  85. data/spec/hydra/works/services/collection/remove_generic_work_spec.rb +0 -133
  86. data/spec/hydra/works/services/collection/remove_related_object_spec.rb +0 -128
  87. data/spec/hydra/works/services/generic_file/add_file_spec.rb +0 -28
  88. data/spec/hydra/works/services/generic_file/add_generic_file_spec.rb +0 -174
  89. data/spec/hydra/works/services/generic_file/add_related_object_spec.rb +0 -150
  90. data/spec/hydra/works/services/generic_file/get_generic_files_spec.rb +0 -19
  91. data/spec/hydra/works/services/generic_file/get_related_objects_spec.rb +0 -45
  92. data/spec/hydra/works/services/generic_file/remove_generic_file_spec.rb +0 -124
  93. data/spec/hydra/works/services/generic_file/remove_related_object_spec.rb +0 -123
  94. data/spec/hydra/works/services/generic_work/add_generic_file_spec.rb +0 -156
  95. data/spec/hydra/works/services/generic_work/add_generic_work_spec.rb +0 -157
  96. data/spec/hydra/works/services/generic_work/add_related_object_spec.rb +0 -148
  97. data/spec/hydra/works/services/generic_work/get_generic_files_spec.rb +0 -35
  98. data/spec/hydra/works/services/generic_work/get_generic_works_spec.rb +0 -35
  99. data/spec/hydra/works/services/generic_work/get_related_objects_spec.rb +0 -46
  100. data/spec/hydra/works/services/generic_work/move_generic_file_spec.rb +0 -21
  101. data/spec/hydra/works/services/generic_work/remove_generic_file_spec.rb +0 -132
  102. data/spec/hydra/works/services/generic_work/remove_generic_work_spec.rb +0 -133
  103. data/spec/hydra/works/services/generic_work/remove_related_object_spec.rb +0 -128
@@ -1,20 +0,0 @@
1
- module Hydra::Works
2
- class RemoveGenericWorkFromCollection
3
-
4
- ##
5
- # Remove a generic_work from a collection.
6
- #
7
- # @param [Hydra::Works::Collection] :parent_collection from which to remove generic_work
8
- # @param [Hydra::Works::GenericWork::Base] :child_generic_work being removed
9
- # @param [Fixnum] :nth_occurrence remove nth occurrence of this generic_work in the list (default=1)
10
- #
11
- # @return [Hydra::Works::Collection] the updated hydra works collection
12
-
13
- def self.call( parent_collection, child_generic_work, nth_occurrence=1 )
14
- raise ArgumentError, 'parent_collection must be a hydra-works collection' unless Hydra::Works.collection? parent_collection
15
- raise ArgumentError, 'child_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? child_generic_work
16
- Hydra::PCDM::RemoveObjectFromCollection.call( parent_collection, child_generic_work, nth_occurrence )
17
- end
18
-
19
- end
20
- end
@@ -1,19 +0,0 @@
1
- module Hydra::Works
2
- class RemoveRelatedObjectFromCollection
3
-
4
- ##
5
- # Remove a related object from a collection.
6
- #
7
- # @param [Hydra::Works::Collection] :parent_collection from which to remove the related object
8
- # @param [Hydra::PCDM::Object] :child_related_object being removed
9
- #
10
- # @return [Hydra::Works::Collection] the updated hydra works collection
11
-
12
- def self.call( parent_collection, child_related_object )
13
- raise ArgumentError, 'parent_collection must be a hydra-works collection' unless Hydra::Works.collection? parent_collection
14
- raise ArgumentError, 'child_related_object must be a pcdm object' unless Hydra::PCDM.object? child_related_object
15
- Hydra::PCDM::RemoveRelatedObjectFromCollection.call( parent_collection, child_related_object )
16
- end
17
-
18
- end
19
- end
@@ -1,55 +0,0 @@
1
- module Hydra::Works
2
- class AddFileToGenericFile
3
-
4
- # Adds the original file to the work
5
-
6
- def self.call(object, path, type, replace=false)
7
- raise ArgumentError, "supplied object must be a generic file" unless Hydra::Works.generic_file?(object)
8
- raise ArgumentError, "supplied path must be a string" unless path.is_a?(String)
9
- raise ArgumentError, "supplied path to file does not exist" unless ::File.exists?(path)
10
-
11
- if replace
12
- current_file = object.filter_files_by_type(self.type_to_uri(type)).first
13
- else
14
- object.files.build
15
- current_file = object.files.last
16
- end
17
-
18
- current_file.content = ::File.open(path)
19
- current_file.original_name = ::File.basename(path)
20
- current_file.mime_type = Hydra::PCDM::GetMimeTypeForFile.call(path)
21
- Hydra::PCDM::AddTypeToFile.call(current_file, self.type_to_uri(type))
22
- current_file.save if replace
23
- object.save
24
- object
25
- end
26
-
27
- private
28
-
29
- # Returns appropriate URI for the requested type
30
- # * Converts supported symbols to corresponding URIs
31
- # * Converts URI strings to RDF::URI
32
- # * Returns RDF::URI objects as-is
33
- def self.type_to_uri(type)
34
- if type.instance_of?(::RDF::URI)
35
- return type
36
- elsif type.instance_of?(Symbol)
37
- case type
38
- when :original_file
39
- return ::RDF::URI("http://pcdm.org/OriginalFile")
40
- when :thumbnail
41
- return ::RDF::URI("http://pcdm.org/ThumbnailImage")
42
- when :extracted_text
43
- return ::RDF::URI("http://pcdm.org/ExtractedText")
44
- else
45
- raise ArgumentError, "Invalid file type. The only valid symbols for file types are :original_file, :thumbnail, and :extracted_text. You submitted #{type}. To avoid this error, use one of those symbols or submit a URI instead of a symbol."
46
- end
47
- elsif type.instance_of?(String)
48
- return ::RDF::URI(type)
49
- else
50
- raise ArgumentError, "Invalid file type. You must submit a URI or a symbol."
51
- end
52
- end
53
-
54
- end
55
- end
@@ -1,19 +0,0 @@
1
- module Hydra::Works
2
- class AddGenericFileToGenericFile
3
-
4
- ##
5
- # Add a generic_file to a generic_file.
6
- #
7
- # @param [Hydra::Works::GenericFile::Base] :parent_generic_file to which to add generic_file
8
- # @param [Hydra::Works::GenericFile::Base] :child_generic_file being added
9
- #
10
- # @return [Hydra::Works::GenericFile::Base] the updated hydra works generic file
11
-
12
- def self.call( parent_generic_file, child_generic_file )
13
- raise ArgumentError, 'parent_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? parent_generic_file
14
- raise ArgumentError, 'child_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? child_generic_file
15
- Hydra::PCDM::AddObjectToObject.call( parent_generic_file, child_generic_file )
16
- end
17
-
18
- end
19
- end
@@ -1,11 +0,0 @@
1
- module Hydra::Works
2
- class AddOriginalFile
3
-
4
- # Adds the original file to the work
5
-
6
- def self.call(object, path, replace=false)
7
- Hydra::Works::AddFileToGenericFile.call(object, path, ::RDF::URI("http://pcdm.org/OriginalFile"), replace)
8
- end
9
-
10
- end
11
- end
@@ -1,19 +0,0 @@
1
- module Hydra::Works
2
- class AddRelatedObjectToGenericFile
3
-
4
- ##
5
- # Add a related object to a generic file.
6
- #
7
- # @param [Hydra::Works::GenericFile::Base] :parent_generic_file to which to add the related object
8
- # @param [Hydra::PCDM::Object] :child_related_object being added
9
- #
10
- # @return [Hydra::Works::GenericFile::Base] the updated hydra works generic file
11
-
12
- def self.call( parent_generic_file, child_related_object )
13
- raise ArgumentError, 'parent_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? parent_generic_file
14
- raise ArgumentError, 'child_related_object must be a pcdm object' unless Hydra::PCDM.object? child_related_object
15
- Hydra::PCDM::AddRelatedObjectToObject.call( parent_generic_file, child_related_object )
16
- end
17
-
18
- end
19
- end
@@ -1,10 +0,0 @@
1
- module Hydra::Works
2
- class AddVersionedOriginalFile
3
-
4
- # TODO: Create a new version of the original file instead of replacing it
5
- def self.call(object, file)
6
-
7
- end
8
-
9
- end
10
- end
@@ -1,17 +0,0 @@
1
- module Hydra::Works
2
- class GetGenericFilesFromGenericFile
3
-
4
- ##
5
- # Get member generic files from a generic file in order.
6
- #
7
- # @param [Hydra::Works::GenericFile::Base] :parent_generic_file in which the child generic files are members
8
- #
9
- # @return [Array<Hydra::Works::GenericFile::Base>] all member generic files
10
-
11
- def self.call( parent_generic_file )
12
- raise ArgumentError, 'parent_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? parent_generic_file
13
- parent_generic_file.generic_files
14
- end
15
-
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- module Hydra::Works
2
- class GetRelatedObjectsFromGenericFile
3
-
4
- ##
5
- # Get related objects from a generic_file.
6
- #
7
- # @param [Hydra::Works::GenericFile::Base] :parent_generic_file to which the child objects are related
8
- #
9
- # @return [Array<Hydra::Works::GenericFile::Base>] all related objects
10
-
11
- def self.call( parent_generic_file )
12
- raise ArgumentError, 'parent_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? parent_generic_file
13
- Hydra::PCDM::GetRelatedObjectsFromObject.call( parent_generic_file )
14
- end
15
-
16
- end
17
- end
@@ -1,20 +0,0 @@
1
- module Hydra::Works
2
- class RemoveGenericFileFromGenericFile
3
-
4
- ##
5
- # Remove a generic_file from a generic_file.
6
- #
7
- # @param [Hydra::Works::GenericFile::Base] :parent_generic_file from which to remove generic_file
8
- # @param [Hydra::Works::GenericFile::Base] :child_generic_file being removed
9
- # @param [Fixnum] :nth_occurrence remove nth occurrence of this generic_file in the list (default=1)
10
- #
11
- # @return [Hydra::Works::GenericFile::Base] the updated hydra works generic file
12
-
13
- def self.call( parent_generic_file, child_generic_file, nth_occurrence=1 )
14
- raise ArgumentError, 'parent_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? parent_generic_file
15
- raise ArgumentError, 'child_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? child_generic_file
16
- Hydra::PCDM::RemoveObjectFromObject.call( parent_generic_file, child_generic_file, nth_occurrence )
17
- end
18
-
19
- end
20
- end
@@ -1,19 +0,0 @@
1
- module Hydra::Works
2
- class RemoveRelatedObjectFromGenericFile
3
-
4
- ##
5
- # Remove an object from a generic file.
6
- #
7
- # @param [Hydra::Works::GenericFile::Base] :parent_generic_file from which to remove the related object
8
- # @param [Hydra::PCDM::Object] :child_related_object being removed
9
- #
10
- # @return [Hydra::Works::GenericFile::Base] the updated hydra works generic file
11
-
12
- def self.call( parent_generic_file, child_related_object )
13
- raise ArgumentError, 'parent_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? parent_generic_file
14
- raise ArgumentError, 'child_related_object must be a pcdm object' unless Hydra::PCDM.object? child_related_object
15
- Hydra::PCDM::RemoveRelatedObjectFromObject.call( parent_generic_file, child_related_object )
16
- end
17
-
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- module Hydra::Works
2
- class AddGenericFileToGenericWork
3
-
4
- ##
5
- # Add a generic_file to a generic_work.
6
- #
7
- # @param [Hydra::Works::GenericWork::Base] :parent_generic_work to which to add generic_work
8
- # @param [Hydra::Works::GenericFile::Base] :child_generic_file being added
9
- #
10
- # @return [Hydra::Works::GenericWork::Base] the updated hydra works generic work
11
-
12
- def self.call( parent_generic_work, child_generic_file )
13
- raise ArgumentError, 'parent_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? parent_generic_work
14
- raise ArgumentError, 'child_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? child_generic_file
15
- Hydra::PCDM::AddObjectToObject.call( parent_generic_work, child_generic_file )
16
- end
17
-
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- module Hydra::Works
2
- class AddGenericWorkToGenericWork
3
-
4
- ##
5
- # Add a generic_work to a generic_work.
6
- #
7
- # @param [Hydra::Works::GenericWork::Base] :parent_generic_work to which to add generic_work
8
- # @param [Hydra::Works::GenericWork::Base] :child_generic_work being added
9
- #
10
- # @return [Hydra::Works::GenericWork::Base] the updated hydra works generic work
11
-
12
- def self.call( parent_generic_work, child_generic_work )
13
- raise ArgumentError, 'parent_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? parent_generic_work
14
- raise ArgumentError, 'child_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? child_generic_work
15
- Hydra::PCDM::AddObjectToObject.call( parent_generic_work, child_generic_work )
16
- end
17
-
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- module Hydra::Works
2
- class AddRelatedObjectToGenericWork
3
-
4
- ##
5
- # Add a related object to a generic work.
6
- #
7
- # @param [Hydra::Works::GenericWork::Base] :parent_generic_work to which to add the related object
8
- # @param [Hydra::PCDM::Object] :child_related_object being added
9
- #
10
- # @return [Hydra::Works::GenericWork::Base] the updated hydra works generic work
11
-
12
- def self.call( parent_generic_work, child_related_object )
13
- raise ArgumentError, 'parent_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? parent_generic_work
14
- raise ArgumentError, 'child_related_object must be a pcdm object' unless Hydra::PCDM.object? child_related_object
15
- Hydra::PCDM::AddRelatedObjectToObject.call( parent_generic_work, child_related_object )
16
- end
17
-
18
- end
19
- end
@@ -1,17 +0,0 @@
1
- module Hydra::Works
2
- class GetGenericFilesFromGenericWork
3
-
4
- ##
5
- # Get member generic files from a generic work in order.
6
- #
7
- # @param [Hydra::Works::GenericWork::Base] :parent_generic_work in which the child generic files are members
8
- #
9
- # @return [Array<Hydra::Works::GenericFile::Base>] all member generic files
10
-
11
- def self.call( parent_generic_work )
12
- raise ArgumentError, 'parent_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? parent_generic_work
13
- parent_generic_work.generic_files
14
- end
15
-
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- module Hydra::Works
2
- class GetGenericWorksFromGenericWork
3
-
4
- ##
5
- # Get member generic works from a generic work in order.
6
- #
7
- # @param [Hydra::Works::GenericWork::Base] :parent_generic_work in which the child generic works are members
8
- #
9
- # @return [Array<Hydra::Works::GenericWork::Base>] all member generic works
10
-
11
- def self.call( parent_generic_work )
12
- raise ArgumentError, 'parent_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? parent_generic_work
13
- parent_generic_work.generic_works
14
- end
15
-
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- module Hydra::Works
2
- class GetRelatedObjectsFromGenericWork
3
-
4
- ##
5
- # Get related objects from a generic_work.
6
- #
7
- # @param [Hydra::Works::GenericWork::Base] :parent_generic_work to which the child objects are related
8
- #
9
- # @return [Array<Hydra::Works::GenericWork::Base>] all related objects
10
-
11
- def self.call( parent_generic_work )
12
- raise ArgumentError, 'parent_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? parent_generic_work
13
- Hydra::PCDM::GetRelatedObjectsFromObject.call( parent_generic_work )
14
- end
15
-
16
- end
17
- end
@@ -1,19 +0,0 @@
1
- module Hydra::Works
2
- class MoveGenericFileToGenericWork
3
-
4
- ##
5
- # Move a generic file from one generic work to another
6
- #
7
- # @param [Hydra::Works::GenericWork] :old_parent_work where the generic file currently lives
8
- # @param [Hydra::Works::GenericWork] :new_parent_work where the generic file is being moved
9
- # @param [Hydra::Works::GenericFile] :child_generic_file being moved
10
- #
11
- # @return [Hydra::Works::GenericWork] the destination generic work
12
- def self.call(old_parent_work, new_parent_work, child_generic_file)
13
- AddGenericFileToGenericWork.call(new_parent_work, child_generic_file)
14
- RemoveGenericFileFromGenericWork.call(old_parent_work, child_generic_file)
15
- new_parent_work
16
- end
17
-
18
- end
19
- end
@@ -1,20 +0,0 @@
1
- module Hydra::Works
2
- class RemoveGenericFileFromGenericWork
3
-
4
- ##
5
- # Remove a generic_file from a generic_work.
6
- #
7
- # @param [Hydra::Works::GenericWork::Base] :parent_generic_work from which to remove generic_work
8
- # @param [Hydra::Works::GenericFile::Base] :child_generic_file being removed
9
- # @param [Fixnum] :nth_occurrence remove nth occurrence of this generic_work in the list (default=1)
10
- #
11
- # @return [Hydra::Works::GenericWork::Base] the updated hydra works generic work
12
-
13
- def self.call( parent_generic_work, child_generic_file, nth_occurrence=1 )
14
- raise ArgumentError, 'parent_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? parent_generic_work
15
- raise ArgumentError, 'child_generic_file must be a hydra-works generic file' unless Hydra::Works.generic_file? child_generic_file
16
- Hydra::PCDM::RemoveObjectFromObject.call( parent_generic_work, child_generic_file, nth_occurrence )
17
- end
18
-
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- module Hydra::Works
2
- class RemoveGenericWorkFromGenericWork
3
-
4
- ##
5
- # Remove a generic_work from a generic_work.
6
- #
7
- # @param [Hydra::Works::GenericWork::Base] :parent_generic_work from which to remove generic_work
8
- # @param [Hydra::Works::GenericWork::Base] :child_generic_work being removed
9
- # @param [Fixnum] :nth_occurrence remove nth occurrence of this generic_work in the list (default=1)
10
- #
11
- # @return [Hydra::Works::GenericWork::Base] the updated hydra works generic work
12
-
13
- def self.call( parent_generic_work, child_generic_work, nth_occurrence=1 )
14
- raise ArgumentError, 'parent_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? parent_generic_work
15
- raise ArgumentError, 'child_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? child_generic_work
16
- Hydra::PCDM::RemoveObjectFromObject.call( parent_generic_work, child_generic_work, nth_occurrence )
17
- end
18
-
19
- end
20
- end
@@ -1,19 +0,0 @@
1
- module Hydra::Works
2
- class RemoveRelatedObjectFromGenericWork
3
-
4
- ##
5
- # Remove an object from a generic work.
6
- #
7
- # @param [Hydra::Works::GenericWork::Base] :parent_generic_work from which to remove the related object
8
- # @param [Hydra::PCDM::Object] :child_related_object being removed
9
- #
10
- # @return [Hydra::Works::GenericWork::Base] the updated hydra works generic work
11
-
12
- def self.call( parent_generic_work, child_related_object )
13
- raise ArgumentError, 'parent_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? parent_generic_work
14
- raise ArgumentError, 'child_related_object must be a pcdm object' unless Hydra::PCDM.object? child_related_object
15
- Hydra::PCDM::RemoveRelatedObjectFromObject.call( parent_generic_work, child_related_object )
16
- end
17
-
18
- end
19
- end