hydra-works 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +14 -0
- data/CONTRIBUTING.md +115 -0
- data/Gemfile +14 -0
- data/LICENSE +16 -0
- data/README.md +80 -0
- data/Rakefile +23 -0
- data/hydra-works.gemspec +33 -0
- data/lib/hydra/works.rb +81 -0
- data/lib/hydra/works/models/collection.rb +5 -0
- data/lib/hydra/works/models/concerns/aggregates_collections.rb +16 -0
- data/lib/hydra/works/models/concerns/aggregates_generic_files.rb +20 -0
- data/lib/hydra/works/models/concerns/aggregates_generic_works.rb +20 -0
- data/lib/hydra/works/models/concerns/collection_behavior.rb +28 -0
- data/lib/hydra/works/models/concerns/generic_file/contained_files.rb +22 -0
- data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +32 -0
- data/lib/hydra/works/models/concerns/generic_file/mime_types.rb +69 -0
- data/lib/hydra/works/models/concerns/generic_file_behavior.rb +25 -0
- data/lib/hydra/works/models/concerns/generic_work_behavior.rb +30 -0
- data/lib/hydra/works/models/generic_file.rb +17 -0
- data/lib/hydra/works/models/generic_work.rb +9 -0
- data/lib/hydra/works/processor.rb +9 -0
- data/lib/hydra/works/services/collection/add_collection.rb +19 -0
- data/lib/hydra/works/services/collection/add_generic_work.rb +19 -0
- data/lib/hydra/works/services/collection/add_related_object.rb +19 -0
- data/lib/hydra/works/services/collection/get_collections.rb +17 -0
- data/lib/hydra/works/services/collection/get_generic_works.rb +17 -0
- data/lib/hydra/works/services/collection/get_related_objects.rb +17 -0
- data/lib/hydra/works/services/collection/remove_collection.rb +19 -0
- data/lib/hydra/works/services/collection/remove_generic_work.rb +20 -0
- data/lib/hydra/works/services/collection/remove_related_object.rb +19 -0
- data/lib/hydra/works/services/generic_file/add_file.rb +55 -0
- data/lib/hydra/works/services/generic_file/add_generic_file.rb +19 -0
- data/lib/hydra/works/services/generic_file/add_original_file.rb +11 -0
- data/lib/hydra/works/services/generic_file/add_related_object.rb +19 -0
- data/lib/hydra/works/services/generic_file/add_versioned_original_file.rb +10 -0
- data/lib/hydra/works/services/generic_file/generate/thumbnail.rb +19 -0
- data/lib/hydra/works/services/generic_file/get_generic_files.rb +17 -0
- data/lib/hydra/works/services/generic_file/get_related_objects.rb +17 -0
- data/lib/hydra/works/services/generic_file/remove_generic_file.rb +20 -0
- data/lib/hydra/works/services/generic_file/remove_related_object.rb +19 -0
- data/lib/hydra/works/services/generic_file/upload_file.rb +32 -0
- data/lib/hydra/works/services/generic_work/add_generic_file.rb +19 -0
- data/lib/hydra/works/services/generic_work/add_generic_work.rb +19 -0
- data/lib/hydra/works/services/generic_work/add_related_object.rb +19 -0
- data/lib/hydra/works/services/generic_work/get_generic_files.rb +17 -0
- data/lib/hydra/works/services/generic_work/get_generic_works.rb +17 -0
- data/lib/hydra/works/services/generic_work/get_related_objects.rb +17 -0
- data/lib/hydra/works/services/generic_work/move_generic_file.rb +19 -0
- data/lib/hydra/works/services/generic_work/remove_generic_file.rb +20 -0
- data/lib/hydra/works/services/generic_work/remove_generic_work.rb +20 -0
- data/lib/hydra/works/services/generic_work/remove_related_object.rb +19 -0
- data/lib/hydra/works/version.rb +5 -0
- data/lib/hydra/works/vocab/works_terms.rb +12 -0
- data/spec/fixtures/sample-file.pdf +0 -0
- data/spec/fixtures/updated-file.txt +1 -0
- data/spec/hydra/works/models/collection_spec.rb +41 -0
- data/spec/hydra/works/models/concerns/file/contained_files_spec.rb +113 -0
- data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +12 -0
- data/spec/hydra/works/models/generic_file_spec.rb +45 -0
- data/spec/hydra/works/models/generic_work_spec.rb +50 -0
- data/spec/hydra/works/services/collection/add_collection_spec.rb +166 -0
- data/spec/hydra/works/services/collection/add_generic_work_spec.rb +155 -0
- data/spec/hydra/works/services/collection/add_related_object_spec.rb +149 -0
- data/spec/hydra/works/services/collection/get_collections_spec.rb +35 -0
- data/spec/hydra/works/services/collection/get_generic_works_spec.rb +35 -0
- data/spec/hydra/works/services/collection/get_related_objects_spec.rb +49 -0
- data/spec/hydra/works/services/collection/remove_collection_spec.rb +133 -0
- data/spec/hydra/works/services/collection/remove_generic_work_spec.rb +133 -0
- data/spec/hydra/works/services/collection/remove_related_object_spec.rb +128 -0
- data/spec/hydra/works/services/generic_file/add_file_spec.rb +28 -0
- data/spec/hydra/works/services/generic_file/add_generic_file_spec.rb +174 -0
- data/spec/hydra/works/services/generic_file/add_related_object_spec.rb +150 -0
- data/spec/hydra/works/services/generic_file/generate/thumbnail_spec.rb +21 -0
- data/spec/hydra/works/services/generic_file/get_generic_files_spec.rb +19 -0
- data/spec/hydra/works/services/generic_file/get_related_objects_spec.rb +45 -0
- data/spec/hydra/works/services/generic_file/remove_generic_file_spec.rb +124 -0
- data/spec/hydra/works/services/generic_file/remove_related_object_spec.rb +123 -0
- data/spec/hydra/works/services/generic_file/upload_file_spec.rb +82 -0
- data/spec/hydra/works/services/generic_work/add_generic_file_spec.rb +156 -0
- data/spec/hydra/works/services/generic_work/add_generic_work_spec.rb +157 -0
- data/spec/hydra/works/services/generic_work/add_related_object_spec.rb +148 -0
- data/spec/hydra/works/services/generic_work/get_generic_files_spec.rb +35 -0
- data/spec/hydra/works/services/generic_work/get_generic_works_spec.rb +35 -0
- data/spec/hydra/works/services/generic_work/get_related_objects_spec.rb +46 -0
- data/spec/hydra/works/services/generic_work/move_generic_file_spec.rb +21 -0
- data/spec/hydra/works/services/generic_work/remove_generic_file_spec.rb +132 -0
- data/spec/hydra/works/services/generic_work/remove_generic_work_spec.rb +133 -0
- data/spec/hydra/works/services/generic_work/remove_related_object_spec.rb +128 -0
- data/spec/hydra/works_spec.rb +149 -0
- data/spec/spec_helper.rb +40 -0
- data/use-cases/conference_event_use_case.md +16 -0
- data/use-cases/lafayette_college_geospatial_use_case.md +80 -0
- data/use-cases/northwestern_adminset_use-case.md +19 -0
- data/use-cases/northwestern_displayset_use_case.md +23 -0
- data/use-cases/northwestern_playlist_use_case.md +21 -0
- data/use-cases/princeton_book_use_case.md +117 -0
- data/use-cases/scholarsphere_use_case.md +32 -0
- data/use-cases/stanford_data_model_use_case.md +86 -0
- data/use-cases/ucin_linked_resource_use_case.md +21 -0
- metadata +338 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
# Allows instances of a class to aggregate (pcdm:hasMember) hydra-works generic works
|
3
|
+
module AggregatesGenericWorks
|
4
|
+
|
5
|
+
def generic_works= generic_works
|
6
|
+
raise ArgumentError, "each generic_work must be a hydra works generic work" unless generic_works.all? { |w| Hydra::Works.generic_work? w }
|
7
|
+
raise ArgumentError, "a generic work can't be an ancestor of itself" if self.respond_to?(:object_ancestor?) && object_ancestor?(generic_works)
|
8
|
+
if self.respond_to?(:generic_files)
|
9
|
+
self.members = self.generic_files + generic_works
|
10
|
+
else
|
11
|
+
self.members = generic_works
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def generic_works
|
16
|
+
members.to_a.select { |m| Hydra::Works.generic_work? m }
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
|
3
|
+
# This module provides all of the Behaviors of a Hydra::Works::Collection
|
4
|
+
#
|
5
|
+
# behavior:
|
6
|
+
# 1) Hydra::Works::Collection can aggregate Hydra::Works::Collection
|
7
|
+
# 2) Hydra::Works::Collection can aggregate Hydra::Works::GenericWork
|
8
|
+
|
9
|
+
# 3) Hydra::Works::Collection can NOT aggregate Hydra::PCDM::Collection unless it is also a Hydra::Works::Collection
|
10
|
+
# 4) Hydra::Works::Collection can NOT aggregate Hydra::Works::GenericFile
|
11
|
+
# 5) Hydra::Works::Collection can NOT aggregate non-PCDM object
|
12
|
+
# 6) Hydra::Works::Collection can NOT contain Hydra::PCDM::File
|
13
|
+
# 7) Hydra::Works::Collection can NOT contain
|
14
|
+
|
15
|
+
# 8) Hydra::Works::Collection can have descriptive metadata
|
16
|
+
# 9) Hydra::Works::Collection can have access metadata
|
17
|
+
module CollectionBehavior
|
18
|
+
extend ActiveSupport::Concern
|
19
|
+
include Hydra::PCDM::CollectionBehavior
|
20
|
+
|
21
|
+
included do
|
22
|
+
type [RDFVocabularies::PCDMTerms.Collection,WorksVocabularies::WorksTerms.Collection]
|
23
|
+
include Hydra::Works::AggregatesGenericWorks
|
24
|
+
include Hydra::Works::AggregatesCollections
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Hydra::Works::GenericFile::ContainedFiles
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
# HydraWorks supports only one each of original_file, thumbnail, and extracted_text. However
|
5
|
+
# you are free to add an unlimited number of addtition types such as different resolutions
|
6
|
+
# of images, different derivatives, etc, and use any established vocabulary you choose.
|
7
|
+
|
8
|
+
# TODO: se PCDM vocab class when projecthydra-labs/hydra-pcdm#80 is merged
|
9
|
+
|
10
|
+
def original_file
|
11
|
+
file_of_type(::RDF::URI("http://pcdm.org/OriginalFile"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def thumbnail
|
15
|
+
file_of_type(::RDF::URI("http://pcdm.org/ThumbnailImage"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def extracted_text
|
19
|
+
file_of_type(::RDF::URI("http://pcdm.org/ExtractedText"))
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Hydra::Works::GenericFile
|
2
|
+
module Derivatives
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
include Hydra::Derivatives
|
7
|
+
|
8
|
+
# This was taken directly from Sufia's GenericFile::Derivatives and modified to exclude any processing that modified the original file
|
9
|
+
makes_derivatives do |obj|
|
10
|
+
case obj.mime_type
|
11
|
+
when *pdf_mime_types
|
12
|
+
obj.transform_file :original_file, { thumbnail: { format: 'jpg', size: '338x493', datastream: 'thumbnail' } }, processor: :work
|
13
|
+
when *office_document_mime_types
|
14
|
+
obj.transform_file :original_file, { thumbnail: { format: 'jpg', size: '200x150>', datastream: 'thumbnail' } }, processor: :document
|
15
|
+
when *video_mime_types
|
16
|
+
obj.transform_file :original_file, { thumbnail: { format: 'jpg', datastream: 'thumbnail' } }, processor: :video
|
17
|
+
when *image_mime_types
|
18
|
+
obj.transform_file :original_file, { thumbnail: { format: 'jpg', size: '200x150>', datastream: 'thumbnail' } }, processor: :work
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
# This bit was not in Sufia, but needs to be here for derivatives to work
|
25
|
+
# TODO: delegate mime type somewhere else?
|
26
|
+
def mime_type
|
27
|
+
return nil unless self.original_file
|
28
|
+
self.original_file.mime_type
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# This was taken directly from Sufia's GenericFile::MimeTypes
|
2
|
+
module Hydra::Works::GenericFile
|
3
|
+
module MimeTypes
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def pdf?
|
7
|
+
self.class.pdf_mime_types.include? self.mime_type
|
8
|
+
end
|
9
|
+
|
10
|
+
def image?
|
11
|
+
self.class.image_mime_types.include? self.mime_type
|
12
|
+
end
|
13
|
+
|
14
|
+
def video?
|
15
|
+
self.class.video_mime_types.include? self.mime_type
|
16
|
+
end
|
17
|
+
|
18
|
+
def audio?
|
19
|
+
self.class.audio_mime_types.include? self.mime_type
|
20
|
+
end
|
21
|
+
|
22
|
+
def office_document?
|
23
|
+
self.class.office_document_mime_types.include? self.mime_type
|
24
|
+
end
|
25
|
+
|
26
|
+
# TODO: remove?
|
27
|
+
def collection?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
def file_format
|
32
|
+
return nil if self.mime_type.blank? and self.format_label.blank?
|
33
|
+
return self.mime_type.split('/')[1]+ " ("+self.format_label.join(", ")+")" unless self.mime_type.blank? or self.format_label.blank?
|
34
|
+
return self.mime_type.split('/')[1] unless self.mime_type.blank?
|
35
|
+
return self.format_label
|
36
|
+
end
|
37
|
+
|
38
|
+
module ClassMethods
|
39
|
+
def image_mime_types
|
40
|
+
['image/png', 'image/jpeg', 'image/jpg', 'image/jp2', 'image/bmp', 'image/gif', 'image/tiff']
|
41
|
+
end
|
42
|
+
|
43
|
+
def pdf_mime_types
|
44
|
+
['application/pdf']
|
45
|
+
end
|
46
|
+
|
47
|
+
def video_mime_types
|
48
|
+
['video/mpeg', 'video/mp4', 'video/webm', 'video/x-msvideo', 'video/avi', 'video/quicktime', 'application/mxf']
|
49
|
+
end
|
50
|
+
|
51
|
+
def audio_mime_types
|
52
|
+
# audio/x-wave is the mime type that fits 0.6.0 returns for a wav file.
|
53
|
+
# audio/mpeg is the mime type that fits 0.6.0 returns for an mp3 file.
|
54
|
+
['audio/mp3', 'audio/mpeg', 'audio/wav', 'audio/x-wave', 'audio/x-wav', 'audio/ogg']
|
55
|
+
end
|
56
|
+
|
57
|
+
def office_document_mime_types
|
58
|
+
['text/rtf',
|
59
|
+
'application/msword',
|
60
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
61
|
+
'application/vnd.oasis.opendocument.text',
|
62
|
+
'application/vnd.ms-excel',
|
63
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
64
|
+
'application/vnd.ms-powerpoint',
|
65
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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
|
11
|
+
module GenericFileBehavior
|
12
|
+
extend ActiveSupport::Concern
|
13
|
+
include Hydra::PCDM::ObjectBehavior
|
14
|
+
|
15
|
+
included do
|
16
|
+
type [RDFVocabularies::PCDMTerms.Object,WorksVocabularies::WorksTerms.GenericFile]
|
17
|
+
|
18
|
+
include Hydra::Works::AggregatesGenericFiles
|
19
|
+
include Hydra::Works::GenericFile::ContainedFiles
|
20
|
+
include Hydra::Works::GenericFile::Derivatives
|
21
|
+
include Hydra::Works::GenericFile::MimeTypes
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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
|
15
|
+
module GenericWorkBehavior
|
16
|
+
extend ActiveSupport::Concern
|
17
|
+
include Hydra::PCDM::ObjectBehavior
|
18
|
+
|
19
|
+
included do
|
20
|
+
type [RDFVocabularies::PCDMTerms.Object,WorksVocabularies::WorksTerms.GenericWork]
|
21
|
+
include Hydra::Works::AggregatesGenericFiles
|
22
|
+
include Hydra::Works::AggregatesGenericWorks
|
23
|
+
end
|
24
|
+
|
25
|
+
def contains= files
|
26
|
+
raise NoMethodError, "works can not directly contain files. You must add a GenericFile to the work's members and add files to that GenericFile."
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
# Namespace for Modules with functionality specific to GenericFiles
|
3
|
+
module GenericFile
|
4
|
+
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
autoload :Derivatives, 'hydra/works/models/concerns/generic_file/derivatives'
|
8
|
+
autoload :MimeTypes, 'hydra/works/models/concerns/generic_file/mime_types'
|
9
|
+
autoload :ContainedFiles, 'hydra/works/models/concerns/generic_file/contained_files'
|
10
|
+
|
11
|
+
# Base class for creating objects that behave like Hydra::Works::GenericFiles
|
12
|
+
class Base < ActiveFedora::Base
|
13
|
+
include Hydra::Works::GenericFileBehavior
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
# Namespace for Modules with functionality specific to GenericWorks
|
3
|
+
module GenericWork
|
4
|
+
# Base class for creating objects that behave like Hydra::Works::GenericWorks
|
5
|
+
class Base < ActiveFedora::Base
|
6
|
+
include Hydra::Works::GenericWorkBehavior
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
class AddCollectionToCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Add a collection to a collection.
|
6
|
+
#
|
7
|
+
# @param [Hydra::Works::Collection] :parent_collection to which to add collection
|
8
|
+
# @param [Hydra::Works::Collection] :child_collection being added
|
9
|
+
#
|
10
|
+
# @return [Hydra::Works::Collection] the updated hydra works collection
|
11
|
+
|
12
|
+
def self.call( parent_collection, child_collection )
|
13
|
+
raise ArgumentError, 'parent_collection must be a hydra-works collection' unless Hydra::Works.collection? parent_collection
|
14
|
+
raise ArgumentError, 'child_collection must be a hydra-works collection' unless Hydra::Works.collection? child_collection
|
15
|
+
Hydra::PCDM::AddCollectionToCollection.call( parent_collection, child_collection )
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
class AddGenericWorkToCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Add a generic_work to a collection.
|
6
|
+
#
|
7
|
+
# @param [Hydra::Works::Collection] :parent_collection to which to add generic_work
|
8
|
+
# @param [Hydra::Works::GenericWork::Base] :child_generic_work being added
|
9
|
+
#
|
10
|
+
# @return [Hydra::Works::Collection] the updated hydra works collection
|
11
|
+
|
12
|
+
def self.call( parent_collection, child_generic_work )
|
13
|
+
raise ArgumentError, 'parent_collection must be a hydra-works collection' unless Hydra::Works.collection? parent_collection
|
14
|
+
raise ArgumentError, 'child_generic_work must be a hydra-works generic work' unless Hydra::Works.generic_work? child_generic_work
|
15
|
+
Hydra::PCDM::AddObjectToCollection.call( parent_collection, child_generic_work )
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
class AddRelatedObjectToCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Add a related object to a collection.
|
6
|
+
#
|
7
|
+
# @param [Hydra::Works::Collection] :parent_collection to which to add the related object
|
8
|
+
# @param [Hydra::PCDM::Object] :child_related_object being added
|
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::AddRelatedObjectToCollection.call( parent_collection, child_related_object )
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
class GetCollectionsFromCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Get member collections from a collection in order.
|
6
|
+
#
|
7
|
+
# @param [Hydra::Works::Collection] :parent_collection in which the child collections are members
|
8
|
+
#
|
9
|
+
# @return [Array<Hydra::Works::Collection>] all member collections
|
10
|
+
|
11
|
+
def self.call( parent_collection )
|
12
|
+
raise ArgumentError, 'parent_collection must be a hydra-works collection' unless Hydra::Works.collection? parent_collection
|
13
|
+
parent_collection.collections
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
class GetGenericWorksFromCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Get member generic works from a collection in order.
|
6
|
+
#
|
7
|
+
# @param [Hydra::Works::Collection] :parent_collection 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_collection )
|
12
|
+
raise ArgumentError, 'parent_collection must be a hydra-works collection' unless Hydra::Works.collection? parent_collection
|
13
|
+
parent_collection.generic_works
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
class GetRelatedObjectsFromCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Get related objects from a collection.
|
6
|
+
#
|
7
|
+
# @param [Hydra::Works::Collection] :parent_collection to which the child objects are related
|
8
|
+
#
|
9
|
+
# @return [Array<Hydra::Works::Collection>] all related objects
|
10
|
+
|
11
|
+
def self.call( parent_collection )
|
12
|
+
raise ArgumentError, 'parent_collection must be a hydra-works collection' unless Hydra::Works.collection? parent_collection
|
13
|
+
Hydra::PCDM::GetRelatedObjectsFromCollection.call( parent_collection )
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Hydra::Works
|
2
|
+
class RemoveCollectionFromCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Remove a collection from a collection.
|
6
|
+
#
|
7
|
+
# @param [Hydra::Works::Collection] :parent_collection from which to remove collection
|
8
|
+
# @param [Hydra::Works::Collection] :child_collection being removed
|
9
|
+
#
|
10
|
+
# @return [Hydra::Works::Collection] the updated hydra works collection
|
11
|
+
|
12
|
+
def self.call( parent_collection, child_collection )
|
13
|
+
raise ArgumentError, 'parent_collection must be a hydra-works collection' unless Hydra::Works.collection? parent_collection
|
14
|
+
raise ArgumentError, 'child_collection must be a hydra-works collection' unless Hydra::Works.collection? child_collection
|
15
|
+
Hydra::PCDM::RemoveCollectionFromCollection.call( parent_collection, child_collection )
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
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
|
@@ -0,0 +1,19 @@
|
|
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
|