hydra-pcdm 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 +26 -0
- data/.travis.yml +14 -0
- data/CONTRIBUTING.md +115 -0
- data/Gemfile +13 -0
- data/LICENSE +12 -0
- data/README.md +87 -0
- data/Rakefile +20 -0
- data/config/jetty.yml +6 -0
- data/hydra-pcdm.gemspec +30 -0
- data/lib/hydra/pcdm/collection_indexer.rb +12 -0
- data/lib/hydra/pcdm/models/collection.rb +6 -0
- data/lib/hydra/pcdm/models/concerns/collection_behavior.rb +79 -0
- data/lib/hydra/pcdm/models/concerns/object_behavior.rb +104 -0
- data/lib/hydra/pcdm/models/file.rb +20 -0
- data/lib/hydra/pcdm/models/object.rb +6 -0
- data/lib/hydra/pcdm/object_indexer.rb +10 -0
- data/lib/hydra/pcdm/services/collection/add_collection.rb +20 -0
- data/lib/hydra/pcdm/services/collection/add_object.rb +19 -0
- data/lib/hydra/pcdm/services/collection/add_related_object.rb +21 -0
- data/lib/hydra/pcdm/services/collection/get_collections.rb +18 -0
- data/lib/hydra/pcdm/services/collection/get_objects.rb +18 -0
- data/lib/hydra/pcdm/services/collection/get_related_objects.rb +17 -0
- data/lib/hydra/pcdm/services/collection/remove_collection.rb +36 -0
- data/lib/hydra/pcdm/services/collection/remove_object.rb +43 -0
- data/lib/hydra/pcdm/services/collection/remove_related_object.rb +36 -0
- data/lib/hydra/pcdm/services/file/add_type.rb +20 -0
- data/lib/hydra/pcdm/services/file/get_mime_type.rb +11 -0
- data/lib/hydra/pcdm/services/object/add_object.rb +20 -0
- data/lib/hydra/pcdm/services/object/add_related_object.rb +21 -0
- data/lib/hydra/pcdm/services/object/get_objects.rb +18 -0
- data/lib/hydra/pcdm/services/object/get_related_objects.rb +17 -0
- data/lib/hydra/pcdm/services/object/remove_object.rb +43 -0
- data/lib/hydra/pcdm/services/object/remove_related_object.rb +36 -0
- data/lib/hydra/pcdm/version.rb +5 -0
- data/lib/hydra/pcdm/vocab/ebucore_terms.rb +33 -0
- data/lib/hydra/pcdm/vocab/pcdm_terms.rb +87 -0
- data/lib/hydra/pcdm/vocab/sweetjpl_terms.rb +10 -0
- data/lib/hydra/pcdm.rb +69 -0
- data/spec/hydra/pcdm/collection_indexer_spec.rb +26 -0
- data/spec/hydra/pcdm/models/collection_spec.rb +82 -0
- data/spec/hydra/pcdm/models/file_spec.rb +56 -0
- data/spec/hydra/pcdm/models/object_spec.rb +141 -0
- data/spec/hydra/pcdm/object_indexer_spec.rb +20 -0
- data/spec/hydra/pcdm/services/collection/add_collection_spec.rb +197 -0
- data/spec/hydra/pcdm/services/collection/add_object_spec.rb +132 -0
- data/spec/hydra/pcdm/services/collection/add_related_object_spec.rb +94 -0
- data/spec/hydra/pcdm/services/collection/get_collections_spec.rb +40 -0
- data/spec/hydra/pcdm/services/collection/get_objects_spec.rb +40 -0
- data/spec/hydra/pcdm/services/collection/get_related_objects_spec.rb +37 -0
- data/spec/hydra/pcdm/services/collection/remove_collection_spec.rb +143 -0
- data/spec/hydra/pcdm/services/collection/remove_object_spec.rb +180 -0
- data/spec/hydra/pcdm/services/collection/remove_related_object_spec.rb +146 -0
- data/spec/hydra/pcdm/services/file/add_type_spec.rb +19 -0
- data/spec/hydra/pcdm/services/file/get_mime_type_spec.rb +24 -0
- data/spec/hydra/pcdm/services/object/add_object_spec.rb +186 -0
- data/spec/hydra/pcdm/services/object/add_related_object_spec.rb +94 -0
- data/spec/hydra/pcdm/services/object/get_objects_spec.rb +33 -0
- data/spec/hydra/pcdm/services/object/get_related_objects_spec.rb +39 -0
- data/spec/hydra/pcdm/services/object/remove_object_spec.rb +158 -0
- data/spec/hydra/pcdm/services/object/remove_related_object_spec.rb +126 -0
- data/spec/hydra/pcdm_spec.rb +56 -0
- data/spec/spec_helper.rb +34 -0
- metadata +215 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class GetObjectsFromCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Get member objects from a collection in order.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Collection] :parent_collection in which the child objects are members
|
8
|
+
#
|
9
|
+
# @return [Array<Hydra::PCDM::Collection>] all member objects
|
10
|
+
|
11
|
+
def self.call( parent_collection )
|
12
|
+
raise ArgumentError, "parent_collection must be a pcdm collection" unless Hydra::PCDM.collection? parent_collection
|
13
|
+
|
14
|
+
parent_collection.objects
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class GetRelatedObjectsFromCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Get related objects from a collection.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Collection] :parent_collection to which the child objects are related
|
8
|
+
#
|
9
|
+
# @return [Array<Hydra::PCDM::Collection>] all related objects
|
10
|
+
|
11
|
+
def self.call( parent_collection )
|
12
|
+
raise ArgumentError, "parent_collection must be a pcdm collection" unless Hydra::PCDM.collection? parent_collection
|
13
|
+
parent_collection.related_objects.to_a
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class RemoveCollectionFromCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Remove a collection from a collection.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Collection] :parent_collection from which to remove collection
|
8
|
+
# @param [Hydra::PCDM::Collection] :child_collection being removed
|
9
|
+
#
|
10
|
+
# @return [Hydra::PCDM::Collection] the updated pcdm collection
|
11
|
+
|
12
|
+
def self.call( parent_collection, child_collection )
|
13
|
+
raise ArgumentError, "parent_collection must be a pcdm collection" unless Hydra::PCDM.collection? parent_collection
|
14
|
+
raise ArgumentError, "child_collection must be a pcdm collection" unless Hydra::PCDM.collection? child_collection
|
15
|
+
|
16
|
+
|
17
|
+
# TODO FIX when members is empty, members.delete raises ActiveFedora::ObjectNotFoundError "Can't reload an object that hasn't been saved" (activefedora-aggregation issue #35)
|
18
|
+
|
19
|
+
# TODO members.delete should... (issue #103)(activefedora-aggregation issue #34)
|
20
|
+
# * return child_collection when successful delete (not Array [child_collection])
|
21
|
+
# * return nil if child_collection does not exist in parent_collection
|
22
|
+
# * raise error for any other problems
|
23
|
+
|
24
|
+
# TODO Per issue #103, uncomment the following line when (activefedora-aggregation issue #34) is resolved
|
25
|
+
# parent_collection.members.delete child_collection
|
26
|
+
|
27
|
+
# TODO Per issue #103, remove the following lines when (activefedora-aggregation issue #34) is resolved
|
28
|
+
return nil unless Hydra::PCDM::GetCollectionsFromCollection.call( parent_collection ).include? child_collection
|
29
|
+
removed_collection = parent_collection.members.delete child_collection
|
30
|
+
removed_collection = removed_collection.first if removed_collection.is_a? Array
|
31
|
+
removed_collection
|
32
|
+
# END WORK-AROUND
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class RemoveObjectFromCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Remove an object from a collection.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Collection] :parent_collection from which to remove object
|
8
|
+
# @param [Hydra::PCDM::Object] :child_object being removed
|
9
|
+
# @param [Fixnum] :nth_occurrence remove nth occurrence of this object in the list (default=1)
|
10
|
+
#
|
11
|
+
# @return [Hydra::PCDM::Collection] the updated pcdm collection
|
12
|
+
|
13
|
+
def self.call( parent_collection, child_object, nth_occurrence=1 )
|
14
|
+
raise ArgumentError, "parent_collection must be a pcdm collection" unless Hydra::PCDM.collection? parent_collection
|
15
|
+
raise ArgumentError, "child_object must be a pcdm object" unless Hydra::PCDM.object? child_object
|
16
|
+
|
17
|
+
|
18
|
+
# TODO FIX when members is empty, members.delete raises ActiveFedora::ObjectNotFoundError "Can't reload an object that hasn't been saved" (activefedora-aggregation issue #35)
|
19
|
+
|
20
|
+
# TODO members.delete should... (issue #103)(activefedora-aggregation issue #34)
|
21
|
+
# * return child_object when successful delete (not Array [child_object])
|
22
|
+
# * return nil if child_object does not exist in parent_collection
|
23
|
+
# * raise error for any other problems
|
24
|
+
|
25
|
+
# TODO Per issue #103, uncomment the following line when (activefedora-aggregation issue #34) is resolved
|
26
|
+
# parent_collection.members.delete child_object
|
27
|
+
|
28
|
+
# TODO Per issue #103, remove the following lines when (activefedora-aggregation issue #34) is resolved
|
29
|
+
return nil unless parent_collection.members.include? child_object
|
30
|
+
removed_object = parent_collection.members.delete child_object
|
31
|
+
removed_object = removed_object.first if removed_object.is_a? Array
|
32
|
+
removed_object
|
33
|
+
# END WORK-AROUND
|
34
|
+
|
35
|
+
|
36
|
+
# TODO -- The same object may be in the list multiple times. (issue #102)
|
37
|
+
# * How to remove nth occurrence?
|
38
|
+
# * Default to removing 1st occurrence from the beginning of the list.
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class RemoveRelatedObjectFromCollection
|
3
|
+
|
4
|
+
##
|
5
|
+
# Remove an object from a collection.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Collection] :parent_collection from which to remove the related object
|
8
|
+
# @param [Hydra::PCDM::Object] :child_related_object being removed
|
9
|
+
#
|
10
|
+
# @return [Hydra::PCDM::Collection] the updated pcdm collection
|
11
|
+
|
12
|
+
def self.call( parent_collection, child_related_object )
|
13
|
+
raise ArgumentError, "parent_collection must be a pcdm collection" unless Hydra::PCDM.collection? parent_collection
|
14
|
+
raise ArgumentError, "child_related_object must be a pcdm object" unless Hydra::PCDM.object? child_related_object
|
15
|
+
|
16
|
+
|
17
|
+
# TODO FIX when related_objects is empty, related_objects.delete raises ActiveFedora::ObjectNotFoundError "Can't reload an object that hasn't been saved" (activefedora-aggregation issue #805)
|
18
|
+
|
19
|
+
# TODO related_objects.delete should... (issue #103)(activefedora-aggregation issue #805)
|
20
|
+
# * return child_related_object when successful delete (not Array [child_related_object])
|
21
|
+
# * return nil if child_related_object does not exist in parent_collection
|
22
|
+
# * raise error for any other problems
|
23
|
+
|
24
|
+
# TODO Per issue #103, uncomment the following line when (activefedora issue #805) is resolved
|
25
|
+
# parent_collection.related_objects.delete child_related_object
|
26
|
+
|
27
|
+
# TODO Per issue #103, remove the following lines when (activefedora issue #805) is resolved
|
28
|
+
return nil unless Hydra::PCDM::GetRelatedObjectsFromCollection.call( parent_collection ).include? child_related_object
|
29
|
+
removed_related_object = parent_collection.related_objects.delete child_related_object
|
30
|
+
removed_related_object = removed_related_object.first if removed_related_object.is_a? Array
|
31
|
+
removed_related_object
|
32
|
+
# END WORK-AROUND
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class AddTypeToFile
|
3
|
+
|
4
|
+
# This adds an additional RDF type to an exsiting Hydra::PCDM::File
|
5
|
+
#
|
6
|
+
# @param [Hydra::PCDM::File] the file object you want to add it to
|
7
|
+
# @param [RDF::URI] term you want to add as the type
|
8
|
+
#
|
9
|
+
# @return [Hydra::PCDM::File] the updated file
|
10
|
+
|
11
|
+
def self.call(file, uri)
|
12
|
+
t = file.metadata_node.get_values(:type)
|
13
|
+
return file if t.include?(uri)
|
14
|
+
t << uri
|
15
|
+
file.metadata_node.set_value(:type,t)
|
16
|
+
file
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class GetMimeTypeForFile
|
3
|
+
|
4
|
+
def self.call(path)
|
5
|
+
raise ArgumentError, "supplied argument should be a path to a file" unless path.is_a?(String)
|
6
|
+
mime_types = MIME::Types.of(::File.basename(path))
|
7
|
+
mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class AddObjectToObject
|
3
|
+
|
4
|
+
##
|
5
|
+
# Add an object to an object.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Object] :parent_object to which to add object
|
8
|
+
# @param [Hydra::PCDM::Object] :child_object being added
|
9
|
+
#
|
10
|
+
# @return [Hydra::PCDM::Object] the updated pcdm object
|
11
|
+
|
12
|
+
def self.call( parent_object, child_object )
|
13
|
+
raise ArgumentError, "parent_object must be a pcdm object" unless Hydra::PCDM.object? parent_object
|
14
|
+
raise ArgumentError, "child_object must be a pcdm object" unless Hydra::PCDM.object? child_object
|
15
|
+
raise ArgumentError, "an object can't be an ancestor of itself" if parent_object.ancestor? child_object
|
16
|
+
parent_object.members << child_object
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class AddRelatedObjectToObject
|
3
|
+
|
4
|
+
##
|
5
|
+
# Add a related object to an object.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Object] :parent_object to which to add the related object
|
8
|
+
# @param [Hydra::PCDM::Object] :child_related_object being added
|
9
|
+
#
|
10
|
+
# @return [Hydra::PCDM::Object] the updated pcdm object
|
11
|
+
|
12
|
+
def self.call( parent_object, child_related_object )
|
13
|
+
raise ArgumentError, "parent_object must be a pcdm object" unless Hydra::PCDM.object? parent_object
|
14
|
+
raise ArgumentError, "child_related_object must be a pcdm object" unless Hydra::PCDM.object? child_related_object
|
15
|
+
|
16
|
+
# parent_object.related_objects = parent_object.related_objects + child_related_object
|
17
|
+
parent_object.related_objects << child_related_object
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class GetObjectsFromObject
|
3
|
+
|
4
|
+
##
|
5
|
+
# Get member objects from an object in order.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Object] :parent_object in which the child objects are members
|
8
|
+
#
|
9
|
+
# @return [Array<Hydra::PCDM::Object>] all member objects
|
10
|
+
|
11
|
+
def self.call( parent_object )
|
12
|
+
raise ArgumentError, "parent_object must be a pcdm object" unless Hydra::PCDM.object? parent_object
|
13
|
+
|
14
|
+
parent_object.objects
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class GetRelatedObjectsFromObject
|
3
|
+
|
4
|
+
##
|
5
|
+
# Get related objects from an object.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Object] :parent_object to which the child objects are related
|
8
|
+
#
|
9
|
+
# @return [Array<Hydra::PCDM::Object>] all related objects
|
10
|
+
|
11
|
+
def self.call( parent_object )
|
12
|
+
raise ArgumentError, "parent_object must be a pcdm object" unless Hydra::PCDM.object? parent_object
|
13
|
+
parent_object.related_objects.to_a
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class RemoveObjectFromObject
|
3
|
+
|
4
|
+
##
|
5
|
+
# Remove an object from an object.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Object] :parent_object from which to remove object
|
8
|
+
# @param [Hydra::PCDM::Object] :child_object being removed
|
9
|
+
# @param [Fixnum] :nth_occurrence remove nth occurrence of this object in the list (default=1)
|
10
|
+
#
|
11
|
+
# @return [Hydra::PCDM::Object] the updated pcdm object
|
12
|
+
|
13
|
+
def self.call( parent_object, child_object, nth_occurrence=1 )
|
14
|
+
raise ArgumentError, "parent_object must be a pcdm object" unless Hydra::PCDM.object? parent_object
|
15
|
+
raise ArgumentError, "child_object must be a pcdm object" unless Hydra::PCDM.object? child_object
|
16
|
+
|
17
|
+
|
18
|
+
# TODO FIX when members is empty, members.delete raises ActiveFedora::ObjectNotFoundError "Can't reload an object that hasn't been saved" (activefedora-aggregation issue #35)
|
19
|
+
|
20
|
+
# TODO members.delete should... (issue #103)(activefedora-aggregation issue #34)
|
21
|
+
# * return child_object when successful delete (not Array [child_object])
|
22
|
+
# * return nil if child_object does not exist in parent_object
|
23
|
+
# * raise error for any other problems
|
24
|
+
|
25
|
+
# TODO Per issue #103, uncomment the following line when (activefedora-aggregation issue #34) is resolved
|
26
|
+
# parent_object.members.delete child_object
|
27
|
+
|
28
|
+
# TODO Per issue #103, remove the following lines when (activefedora-aggregation issue #34) is resolved
|
29
|
+
return nil unless parent_object.members.include? child_object
|
30
|
+
removed_object = parent_object.members.delete child_object
|
31
|
+
removed_object = removed_object.first if removed_object.is_a? Array
|
32
|
+
removed_object
|
33
|
+
# END WORK-AROUND
|
34
|
+
|
35
|
+
|
36
|
+
# TODO -- The same object may be in the list multiple times. (issue #102)
|
37
|
+
# * How to remove nth occurrence?
|
38
|
+
# * Default to removing 1st occurrence from the beginning of the list.
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class RemoveRelatedObjectFromObject
|
3
|
+
|
4
|
+
##
|
5
|
+
# Remove an object from an object.
|
6
|
+
#
|
7
|
+
# @param [Hydra::PCDM::Object] :parent_object from which to remove the related object
|
8
|
+
# @param [Hydra::PCDM::Object] :child_related_object being removed
|
9
|
+
#
|
10
|
+
# @return [Hydra::PCDM::Collection] the updated pcdm collection
|
11
|
+
|
12
|
+
def self.call( parent_object, child_related_object )
|
13
|
+
raise ArgumentError, "parent_object must be a pcdm object" unless Hydra::PCDM.object? parent_object
|
14
|
+
raise ArgumentError, "child_related_object must be a pcdm object" unless Hydra::PCDM.object? child_related_object
|
15
|
+
|
16
|
+
|
17
|
+
# TODO FIX when related_objects is empty, related_objects.delete raises ActiveFedora::ObjectNotFoundError "Can't reload an object that hasn't been saved" (activefedora-aggregation issue #805)
|
18
|
+
|
19
|
+
# TODO related_objects.delete should... (issue #103)(activefedora-aggregation issue #805)
|
20
|
+
# * return child_related_object when successful delete (not Array [child_related_object])
|
21
|
+
# * return nil if child_related_object does not exist in parent_object
|
22
|
+
# * raise error for any other problems
|
23
|
+
|
24
|
+
# TODO Per issue #103, uncomment the following line when (activefedora issue #805) is resolved
|
25
|
+
# parent_object.related_objects.delete child_related_object
|
26
|
+
|
27
|
+
# TODO Per issue #103, remove the following lines when (activefedora issue #805) is resolved
|
28
|
+
return nil unless Hydra::PCDM::GetRelatedObjectsFromObject.call( parent_object ).include? child_related_object
|
29
|
+
removed_related_object = parent_object.related_objects.delete child_related_object
|
30
|
+
removed_related_object = removed_related_object.first if removed_related_object.is_a? Array
|
31
|
+
removed_related_object
|
32
|
+
# END WORK-AROUND
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
module EBUCoreVocabularies
|
3
|
+
class EBUCoreTerms < RDF::StrictVocabulary("http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#")
|
4
|
+
# Property definitions
|
5
|
+
property :filename,
|
6
|
+
comment: ["The name of the file containing the Resource.".freeze],
|
7
|
+
domain: "ebucore:Resource".freeze,
|
8
|
+
range: "xsd:string".freeze,
|
9
|
+
label: "File Name".freeze
|
10
|
+
|
11
|
+
property :fileSize,
|
12
|
+
comment: ["Size of a MediaResource in bytes.".freeze],
|
13
|
+
domain: "ebucore:Resource".freeze,
|
14
|
+
range: "xsd:integer".freeze,
|
15
|
+
label: "File Size".freeze
|
16
|
+
|
17
|
+
property :dateCreated,
|
18
|
+
comment: ["The date of creation of the media resource.".freeze],
|
19
|
+
domain: "ebucore:Resource".freeze,
|
20
|
+
range: "xsd:dateTime".freeze,
|
21
|
+
label: "Date Created".freeze
|
22
|
+
|
23
|
+
property :hasMimeType,
|
24
|
+
comment: ["Has Mime Type.".freeze],
|
25
|
+
range: "xsd:string".freeze,
|
26
|
+
label: "Has Mime Type".freeze
|
27
|
+
|
28
|
+
property :dateModified,
|
29
|
+
comment: ["To indicate the date at which the media resource has been modified.".freeze],
|
30
|
+
range: "xsd:dateTime".freeze,
|
31
|
+
label: "Date Modified".freeze
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# This file generated automatically using vocab-fetch from https://raw.githubusercontent.com/duraspace/pcdm/master/models.rdf
|
3
|
+
require 'rdf'
|
4
|
+
module RDFVocabularies
|
5
|
+
class PCDMTerms < RDF::StrictVocabulary("http://pcdm.org/models#")
|
6
|
+
|
7
|
+
# Class definitions
|
8
|
+
term :AdministrativeSet,
|
9
|
+
comment: %(
|
10
|
+
An Administrative Set is a grouping of resources that an administrative unit is ultimately
|
11
|
+
responsible for managing. The set itself helps to manage the items within it. An Object
|
12
|
+
or Collection may be contained by only one AdministrativeSet.
|
13
|
+
).freeze,
|
14
|
+
label: "Administrative Set".freeze,
|
15
|
+
"rdfs:isDefinedBy" => %(http://pcdm.org/models#).freeze,
|
16
|
+
subClassOf: "http://www.w3.org/ns/ldp#Container".freeze,
|
17
|
+
type: "rdfs:Class".freeze
|
18
|
+
term :Collection,
|
19
|
+
comment: %(
|
20
|
+
A Collection is a group of resources. Collections have descriptive metadata, access metadata,
|
21
|
+
and may links to works and/or collections. By default, member works and collections are an
|
22
|
+
unordered set, but can be ordered using the ORE Proxy class.
|
23
|
+
).freeze,
|
24
|
+
label: "Collection".freeze,
|
25
|
+
"rdfs:isDefinedBy" => %(http://pcdm.org/models#).freeze,
|
26
|
+
subClassOf: "http://www.openarchives.org/ore/terms/Aggregation".freeze,
|
27
|
+
type: "rdfs:Class".freeze
|
28
|
+
term :File,
|
29
|
+
comment: %(
|
30
|
+
A File is a sequence of binary data and is described by some accompanying metadata.
|
31
|
+
The metadata typically includes at least basic technical metadata \(size, content type,
|
32
|
+
modification date, etc.\), but can also include properties related to preservation,
|
33
|
+
digitization process, provenance, etc. Files MUST be contained by exactly one Object.
|
34
|
+
).freeze,
|
35
|
+
label: "File".freeze,
|
36
|
+
"rdfs:isDefinedBy" => %(http://pcdm.org/models#).freeze,
|
37
|
+
type: "rdfs:Class".freeze
|
38
|
+
term :Object,
|
39
|
+
comment: %(
|
40
|
+
An Object is an intellectual entity, sometimes called a "work", "digital object", etc.
|
41
|
+
Objects have descriptive metadata, access metadata, may contain files and other Objects as
|
42
|
+
member "components". Each level of a work is therefore represented by an Object instance,
|
43
|
+
and is capable of standing on its own, being linked to from Collections and other Objects.
|
44
|
+
Member Objects can be ordered using the ORE Proxy class.
|
45
|
+
).freeze,
|
46
|
+
label: "Object".freeze,
|
47
|
+
"rdfs:isDefinedBy" => %(http://pcdm.org/models#).freeze,
|
48
|
+
subClassOf: "http://www.openarchives.org/ore/terms/Aggregation".freeze,
|
49
|
+
type: "rdfs:Class".freeze
|
50
|
+
|
51
|
+
# Property definitions
|
52
|
+
property :hasFile,
|
53
|
+
comment: %(Links to a File contained by this Object.).freeze,
|
54
|
+
domain: "http://pcdm.org/models#Object".freeze,
|
55
|
+
label: "has file".freeze,
|
56
|
+
range: "http://pcdm.org/models#File".freeze,
|
57
|
+
"rdfs:isDefinedBy" => %(http://pcdm.org/models#).freeze,
|
58
|
+
subPropertyOf: "http://www.w3.org/ns/ldp#contains".freeze,
|
59
|
+
type: "rdf:Property".freeze
|
60
|
+
property :hasMember,
|
61
|
+
comment: %(Links to a related Object. Typically used to link to component parts, such as a book linking to a page.).freeze,
|
62
|
+
domain: "http://www.openarchives.org/ore/terms/Aggregation".freeze,
|
63
|
+
label: "has member".freeze,
|
64
|
+
range: "http://www.openarchives.org/ore/terms/Aggregation".freeze,
|
65
|
+
"rdfs:isDefinedBy" => %(http://pcdm.org/models#).freeze,
|
66
|
+
subPropertyOf: "http://www.openarchives.org/ore/terms/aggregates".freeze,
|
67
|
+
type: "rdf:Property".freeze
|
68
|
+
property :hasRelatedFile,
|
69
|
+
comment: %(Links to a File which is related to this Object but doesn't directly describe or represent it, such as technical metadata about other files.).freeze,
|
70
|
+
domain: "http://pcdm.org/models#Object".freeze,
|
71
|
+
label: "has related file".freeze,
|
72
|
+
range: "http://pcdm.org/models#File".freeze,
|
73
|
+
"rdfs:isDefinedBy" => %(http://pcdm.org/models#).freeze,
|
74
|
+
subPropertyOf: "http://www.w3.org/ns/ldp#contains".freeze,
|
75
|
+
type: "rdf:Property".freeze
|
76
|
+
|
77
|
+
# Extra definitions
|
78
|
+
term :"",
|
79
|
+
comment: %(Ontology for the Portland Common Data Model, intended to underlie a wide array of repository and DAMS applications.).freeze,
|
80
|
+
"dc:modified" => %(2015-03-16).freeze,
|
81
|
+
"dc:publisher" => %(http://www.duraspace.org/).freeze,
|
82
|
+
"dc:title" => %(Portland Common Data Model).freeze,
|
83
|
+
label: "".freeze,
|
84
|
+
"owl:versionInfo" => %(2015/03/16).freeze,
|
85
|
+
"rdfs:seeAlso" => %(https://wiki.duraspace.org/display/FF/Portland+Common+Data+Model).freeze
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
module SweetjplVocabularies
|
3
|
+
class SweetjplTerms < RDF::StrictVocabulary("http://sweet.jpl.nasa.gov/2.2/reprDataFormat.owl#")
|
4
|
+
# Property definitions
|
5
|
+
property :byteOrder,
|
6
|
+
comment: ["Byte Order.".freeze],
|
7
|
+
range: "xsd:string".freeze,
|
8
|
+
label: "Byte Order".freeze
|
9
|
+
end
|
10
|
+
end
|
data/lib/hydra/pcdm.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
module Hydra
|
4
|
+
module PCDM
|
5
|
+
extend ActiveSupport::Autoload
|
6
|
+
|
7
|
+
# vocabularies
|
8
|
+
autoload :RDFVocabularies, 'hydra/pcdm/vocab/pcdm_terms'
|
9
|
+
autoload :EBUCoreVocabularies, 'hydra/pcdm/vocab/ebucore_terms'
|
10
|
+
autoload :SweetjplVocabularies, 'hydra/pcdm/vocab/sweetjpl_terms'
|
11
|
+
|
12
|
+
# models
|
13
|
+
autoload :Collection, 'hydra/pcdm/models/collection'
|
14
|
+
autoload :Object, 'hydra/pcdm/models/object'
|
15
|
+
autoload :File, 'hydra/pcdm/models/file'
|
16
|
+
|
17
|
+
# behavior concerns
|
18
|
+
autoload :CollectionBehavior, 'hydra/pcdm/models/concerns/collection_behavior'
|
19
|
+
autoload :ObjectBehavior, 'hydra/pcdm/models/concerns/object_behavior'
|
20
|
+
|
21
|
+
autoload :CollectionIndexer
|
22
|
+
autoload :ObjectIndexer
|
23
|
+
|
24
|
+
# collection services
|
25
|
+
autoload :AddCollectionToCollection, 'hydra/pcdm/services/collection/add_collection'
|
26
|
+
autoload :AddObjectToCollection, 'hydra/pcdm/services/collection/add_object'
|
27
|
+
autoload :AddRelatedObjectToCollection, 'hydra/pcdm/services/collection/add_related_object'
|
28
|
+
autoload :GetCollectionsFromCollection, 'hydra/pcdm/services/collection/get_collections'
|
29
|
+
autoload :GetObjectsFromCollection, 'hydra/pcdm/services/collection/get_objects'
|
30
|
+
autoload :GetRelatedObjectsFromCollection, 'hydra/pcdm/services/collection/get_related_objects'
|
31
|
+
autoload :RemoveCollectionFromCollection, 'hydra/pcdm/services/collection/remove_collection'
|
32
|
+
autoload :RemoveObjectFromCollection, 'hydra/pcdm/services/collection/remove_object'
|
33
|
+
autoload :RemoveRelatedObjectFromCollection, 'hydra/pcdm/services/collection/remove_related_object'
|
34
|
+
|
35
|
+
# file services
|
36
|
+
autoload :AddTypeToFile, 'hydra/pcdm/services/file/add_type'
|
37
|
+
autoload :GetMimeTypeForFile, 'hydra/pcdm/services/file/get_mime_type'
|
38
|
+
|
39
|
+
|
40
|
+
# object services
|
41
|
+
autoload :AddFileToObject, 'hydra/pcdm/services/object/add_file'
|
42
|
+
autoload :AddObjectToObject, 'hydra/pcdm/services/object/add_object'
|
43
|
+
autoload :AddRelatedObjectToObject, 'hydra/pcdm/services/object/add_related_object'
|
44
|
+
autoload :CreateObject, 'hydra/pcdm/services/object/create'
|
45
|
+
autoload :GetObjectsFromObject, 'hydra/pcdm/services/object/get_objects'
|
46
|
+
autoload :GetRelatedObjectsFromObject, 'hydra/pcdm/services/object/get_related_objects'
|
47
|
+
autoload :GetFilesFromObject, 'hydra/pcdm/services/object/get_collections'
|
48
|
+
autoload :RemoveObjectFromObject, 'hydra/pcdm/services/object/remove_object'
|
49
|
+
autoload :RemoveRelatedObjectFromObject, 'hydra/pcdm/services/object/remove_related_object'
|
50
|
+
|
51
|
+
|
52
|
+
# model validations
|
53
|
+
def self.collection? collection
|
54
|
+
return false unless collection.respond_to? :type
|
55
|
+
collection.type.include? RDFVocabularies::PCDMTerms.Collection
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.object? object
|
59
|
+
return false unless object.respond_to? :type
|
60
|
+
object.type.include? RDFVocabularies::PCDMTerms.Object
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.file? file
|
64
|
+
return false unless file.respond_to? :metadata_node
|
65
|
+
file.metadata_node.type.include? RDFVocabularies::PCDMTerms.File
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::PCDM::CollectionIndexer do
|
4
|
+
let(:collection) { Hydra::PCDM::Collection.new }
|
5
|
+
let(:child_collections1) { Hydra::PCDM::Collection.new(id: '123') }
|
6
|
+
let(:child_collections2) { Hydra::PCDM::Collection.new(id: '456') }
|
7
|
+
let(:object1) { Hydra::PCDM::Object.new(id: '789') }
|
8
|
+
let(:indexer) { described_class.new(collection) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow(collection).to receive(:child_collections).and_return([child_collections1, child_collections2])
|
12
|
+
allow(collection).to receive(:objects).and_return([object1])
|
13
|
+
allow(collection).to receive(:member_ids).and_return(['123', '456', '789'])
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#generate_solr_document" do
|
17
|
+
subject { indexer.generate_solr_document }
|
18
|
+
|
19
|
+
it "has fields" do
|
20
|
+
expect(subject['child_collections_ssim']).to eq ['123', '456']
|
21
|
+
expect(subject['objects_ssim']).to eq ['789']
|
22
|
+
expect(subject['members_ssim']).to eq ['123', '456', '789']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|