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.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.travis.yml +2 -5
- data/Gemfile +1 -3
- data/README.md +28 -13
- data/hydra-works.gemspec +4 -3
- data/lib/hydra/works.rb +7 -57
- data/lib/hydra/works/models/concerns/block_child_objects.rb +16 -0
- data/lib/hydra/works/models/concerns/collection_behavior.rb +27 -2
- data/lib/hydra/works/models/concerns/generic_file/contained_files.rb +5 -13
- data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +9 -13
- data/lib/hydra/works/models/concerns/generic_file/mime_types.rb +14 -9
- data/lib/hydra/works/models/concerns/generic_file/versioned_content.rb +18 -0
- data/lib/hydra/works/models/concerns/generic_file/virus_check.rb +48 -0
- data/lib/hydra/works/models/concerns/generic_file_behavior.rb +24 -1
- data/lib/hydra/works/models/concerns/generic_work_behavior.rb +32 -3
- data/lib/hydra/works/models/generic_file.rb +3 -0
- data/lib/hydra/works/services/generic_file/add_file_to_generic_file.rb +127 -0
- data/lib/hydra/works/services/generic_file/generate/thumbnail.rb +1 -2
- data/lib/hydra/works/services/generic_file/persist_derivative.rb +22 -0
- data/lib/hydra/works/services/generic_file/upload_file.rb +11 -19
- data/lib/hydra/works/version.rb +1 -1
- data/lib/hydra/works/vocab/works_terms.rb +1 -1
- data/spec/fixtures/Example.ogg +0 -0
- data/spec/fixtures/charter.docx +0 -0
- data/spec/fixtures/countdown.avi +0 -0
- data/spec/fixtures/image.jp2 +0 -0
- data/spec/fixtures/piano_note.wav +0 -0
- data/spec/fixtures/test5.mp3 +0 -0
- data/spec/fixtures/world.png +0 -0
- data/spec/hydra/works/models/collection_spec.rb +499 -16
- data/spec/hydra/works/models/concerns/block_child_objects_spec.rb +19 -0
- data/spec/hydra/works/models/concerns/{file → generic_file}/contained_files_spec.rb +20 -17
- data/spec/hydra/works/models/concerns/generic_file/mime_types_spec.rb +76 -0
- data/spec/hydra/works/models/concerns/generic_file/versioned_content_spec.rb +32 -0
- data/spec/hydra/works/models/concerns/generic_file/virus_check_spec.rb +50 -0
- data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +1 -1
- data/spec/hydra/works/models/generic_file_spec.rb +201 -14
- data/spec/hydra/works/models/generic_work_spec.rb +530 -14
- data/spec/hydra/works/services/generic_file/add_file_to_generic_file_spec.rb +110 -0
- data/spec/hydra/works/services/generic_file/upload_file_spec.rb +45 -28
- data/spec/hydra/works/services/persist_derivatives_spec.rb +93 -0
- data/spec/hydra/works_spec.rb +35 -35
- data/spec/spec_helper.rb +6 -0
- metadata +56 -95
- data/lib/hydra/works/models/concerns/aggregates_collections.rb +0 -16
- data/lib/hydra/works/models/concerns/aggregates_generic_files.rb +0 -20
- data/lib/hydra/works/models/concerns/aggregates_generic_works.rb +0 -20
- data/lib/hydra/works/processor.rb +0 -9
- data/lib/hydra/works/services/collection/add_collection.rb +0 -19
- data/lib/hydra/works/services/collection/add_generic_work.rb +0 -19
- data/lib/hydra/works/services/collection/add_related_object.rb +0 -19
- data/lib/hydra/works/services/collection/get_collections.rb +0 -17
- data/lib/hydra/works/services/collection/get_generic_works.rb +0 -17
- data/lib/hydra/works/services/collection/get_related_objects.rb +0 -17
- data/lib/hydra/works/services/collection/remove_collection.rb +0 -19
- data/lib/hydra/works/services/collection/remove_generic_work.rb +0 -20
- data/lib/hydra/works/services/collection/remove_related_object.rb +0 -19
- data/lib/hydra/works/services/generic_file/add_file.rb +0 -55
- data/lib/hydra/works/services/generic_file/add_generic_file.rb +0 -19
- data/lib/hydra/works/services/generic_file/add_original_file.rb +0 -11
- data/lib/hydra/works/services/generic_file/add_related_object.rb +0 -19
- data/lib/hydra/works/services/generic_file/add_versioned_original_file.rb +0 -10
- data/lib/hydra/works/services/generic_file/get_generic_files.rb +0 -17
- data/lib/hydra/works/services/generic_file/get_related_objects.rb +0 -17
- data/lib/hydra/works/services/generic_file/remove_generic_file.rb +0 -20
- data/lib/hydra/works/services/generic_file/remove_related_object.rb +0 -19
- data/lib/hydra/works/services/generic_work/add_generic_file.rb +0 -19
- data/lib/hydra/works/services/generic_work/add_generic_work.rb +0 -19
- data/lib/hydra/works/services/generic_work/add_related_object.rb +0 -19
- data/lib/hydra/works/services/generic_work/get_generic_files.rb +0 -17
- data/lib/hydra/works/services/generic_work/get_generic_works.rb +0 -17
- data/lib/hydra/works/services/generic_work/get_related_objects.rb +0 -17
- data/lib/hydra/works/services/generic_work/move_generic_file.rb +0 -19
- data/lib/hydra/works/services/generic_work/remove_generic_file.rb +0 -20
- data/lib/hydra/works/services/generic_work/remove_generic_work.rb +0 -20
- data/lib/hydra/works/services/generic_work/remove_related_object.rb +0 -19
- data/spec/hydra/works/services/collection/add_collection_spec.rb +0 -166
- data/spec/hydra/works/services/collection/add_generic_work_spec.rb +0 -155
- data/spec/hydra/works/services/collection/add_related_object_spec.rb +0 -149
- data/spec/hydra/works/services/collection/get_collections_spec.rb +0 -35
- data/spec/hydra/works/services/collection/get_generic_works_spec.rb +0 -35
- data/spec/hydra/works/services/collection/get_related_objects_spec.rb +0 -49
- data/spec/hydra/works/services/collection/remove_collection_spec.rb +0 -133
- data/spec/hydra/works/services/collection/remove_generic_work_spec.rb +0 -133
- data/spec/hydra/works/services/collection/remove_related_object_spec.rb +0 -128
- data/spec/hydra/works/services/generic_file/add_file_spec.rb +0 -28
- data/spec/hydra/works/services/generic_file/add_generic_file_spec.rb +0 -174
- data/spec/hydra/works/services/generic_file/add_related_object_spec.rb +0 -150
- data/spec/hydra/works/services/generic_file/get_generic_files_spec.rb +0 -19
- data/spec/hydra/works/services/generic_file/get_related_objects_spec.rb +0 -45
- data/spec/hydra/works/services/generic_file/remove_generic_file_spec.rb +0 -124
- data/spec/hydra/works/services/generic_file/remove_related_object_spec.rb +0 -123
- data/spec/hydra/works/services/generic_work/add_generic_file_spec.rb +0 -156
- data/spec/hydra/works/services/generic_work/add_generic_work_spec.rb +0 -157
- data/spec/hydra/works/services/generic_work/add_related_object_spec.rb +0 -148
- data/spec/hydra/works/services/generic_work/get_generic_files_spec.rb +0 -35
- data/spec/hydra/works/services/generic_work/get_generic_works_spec.rb +0 -35
- data/spec/hydra/works/services/generic_work/get_related_objects_spec.rb +0 -46
- data/spec/hydra/works/services/generic_work/move_generic_file_spec.rb +0 -21
- data/spec/hydra/works/services/generic_work/remove_generic_file_spec.rb +0 -132
- data/spec/hydra/works/services/generic_work/remove_generic_work_spec.rb +0 -133
- 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,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
|