hydra-pcdm 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/Gemfile +0 -4
- data/README.md +2 -2
- data/hydra-pcdm.gemspec +2 -1
- data/lib/hydra/pcdm.rb +21 -30
- data/lib/hydra/pcdm/ancestor_checker.rb +18 -0
- data/lib/hydra/pcdm/collection_indexer.rb +2 -2
- data/lib/hydra/pcdm/deep_member_iterator.rb +31 -0
- data/lib/hydra/pcdm/models/concerns/collection_behavior.rb +20 -57
- data/lib/hydra/pcdm/models/concerns/object_behavior.rb +12 -37
- data/lib/hydra/pcdm/models/concerns/pcdm_behavior.rb +34 -0
- data/lib/hydra/pcdm/object_indexer.rb +1 -1
- data/lib/hydra/pcdm/services/file/get_mime_type.rb +1 -1
- data/lib/hydra/pcdm/validators.rb +8 -0
- data/lib/hydra/pcdm/validators/ancestor_validator.rb +26 -0
- data/lib/hydra/pcdm/validators/composite_validator.rb +17 -0
- data/lib/hydra/pcdm/validators/pcdm_object_validator.rb +9 -0
- data/lib/hydra/pcdm/validators/pcdm_validator.rb +9 -0
- data/lib/hydra/pcdm/version.rb +1 -1
- data/lib/hydra/pcdm/vocab/pcdm_terms.rb +1 -1
- data/spec/hydra/pcdm/ancestor_checker_spec.rb +29 -0
- data/spec/hydra/pcdm/collection_indexer_spec.rb +11 -11
- data/spec/hydra/pcdm/deep_member_iterator_spec.rb +52 -0
- data/spec/hydra/pcdm/models/collection_spec.rb +691 -17
- data/spec/hydra/pcdm/models/file_spec.rb +16 -0
- data/spec/hydra/pcdm/models/object_spec.rb +576 -27
- data/spec/hydra/pcdm/object_indexer_spec.rb +6 -6
- data/spec/spec_helper.rb +8 -1
- metadata +31 -52
- data/lib/hydra/pcdm/services/collection/add_collection.rb +0 -20
- data/lib/hydra/pcdm/services/collection/add_object.rb +0 -19
- data/lib/hydra/pcdm/services/collection/add_related_object.rb +0 -21
- data/lib/hydra/pcdm/services/collection/get_collections.rb +0 -18
- data/lib/hydra/pcdm/services/collection/get_objects.rb +0 -18
- data/lib/hydra/pcdm/services/collection/get_related_objects.rb +0 -17
- data/lib/hydra/pcdm/services/collection/remove_collection.rb +0 -36
- data/lib/hydra/pcdm/services/collection/remove_object.rb +0 -43
- data/lib/hydra/pcdm/services/collection/remove_related_object.rb +0 -36
- data/lib/hydra/pcdm/services/object/add_object.rb +0 -20
- data/lib/hydra/pcdm/services/object/add_related_object.rb +0 -21
- data/lib/hydra/pcdm/services/object/get_objects.rb +0 -18
- data/lib/hydra/pcdm/services/object/get_related_objects.rb +0 -17
- data/lib/hydra/pcdm/services/object/remove_object.rb +0 -43
- data/lib/hydra/pcdm/services/object/remove_related_object.rb +0 -36
- data/spec/hydra/pcdm/services/collection/add_collection_spec.rb +0 -197
- data/spec/hydra/pcdm/services/collection/add_object_spec.rb +0 -132
- data/spec/hydra/pcdm/services/collection/add_related_object_spec.rb +0 -94
- data/spec/hydra/pcdm/services/collection/get_collections_spec.rb +0 -40
- data/spec/hydra/pcdm/services/collection/get_objects_spec.rb +0 -40
- data/spec/hydra/pcdm/services/collection/get_related_objects_spec.rb +0 -37
- data/spec/hydra/pcdm/services/collection/remove_collection_spec.rb +0 -143
- data/spec/hydra/pcdm/services/collection/remove_object_spec.rb +0 -180
- data/spec/hydra/pcdm/services/collection/remove_related_object_spec.rb +0 -146
- data/spec/hydra/pcdm/services/file/add_type_spec.rb +0 -19
- data/spec/hydra/pcdm/services/object/add_object_spec.rb +0 -186
- data/spec/hydra/pcdm/services/object/add_related_object_spec.rb +0 -94
- data/spec/hydra/pcdm/services/object/get_objects_spec.rb +0 -33
- data/spec/hydra/pcdm/services/object/get_related_objects_spec.rb +0 -39
- data/spec/hydra/pcdm/services/object/remove_object_spec.rb +0 -158
- data/spec/hydra/pcdm/services/object/remove_related_object_spec.rb +0 -126
@@ -1,20 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hydra::PCDM::ObjectIndexer do
|
4
|
-
let(:object)
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
let(:indexer)
|
4
|
+
let(:object) { Hydra::PCDM::Object.new }
|
5
|
+
let(:child_object1) { Hydra::PCDM::Object.new(id: '123') }
|
6
|
+
let(:child_object2) { Hydra::PCDM::Object.new(id: '456') }
|
7
|
+
let(:indexer) { described_class.new(object) }
|
8
8
|
|
9
9
|
before do
|
10
|
-
allow(object).to receive(:
|
10
|
+
allow(object).to receive(:child_object_ids).and_return([child_object1.id, child_object2.id])
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#generate_solr_document" do
|
14
14
|
subject { indexer.generate_solr_document }
|
15
15
|
|
16
16
|
it "has fields" do
|
17
|
-
expect(subject['
|
17
|
+
expect(subject['child_object_ids_ssim']).to eq ['123', '456']
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
ENV['environment'] ||= 'test'
|
2
|
+
require 'simplecov'
|
2
3
|
require 'coveralls'
|
4
|
+
|
5
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter '/spec'
|
8
|
+
end
|
9
|
+
|
3
10
|
Coveralls.wear!
|
4
11
|
|
5
12
|
require 'bundler/setup'
|
@@ -29,6 +36,6 @@ RSpec.configure do |config|
|
|
29
36
|
config.formatter = :progress
|
30
37
|
|
31
38
|
config.before :suite do
|
32
|
-
ActiveFedora::Cleaner.clean!
|
39
|
+
ActiveFedora::Cleaner.clean! if ActiveFedora::Base.count > 0
|
33
40
|
end
|
34
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-pcdm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- E. Lynette Rayle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activefedora-aggregation
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mime-types
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,56 +126,35 @@ files:
|
|
112
126
|
- config/jetty.yml
|
113
127
|
- hydra-pcdm.gemspec
|
114
128
|
- lib/hydra/pcdm.rb
|
129
|
+
- lib/hydra/pcdm/ancestor_checker.rb
|
115
130
|
- lib/hydra/pcdm/collection_indexer.rb
|
131
|
+
- lib/hydra/pcdm/deep_member_iterator.rb
|
116
132
|
- lib/hydra/pcdm/models/collection.rb
|
117
133
|
- lib/hydra/pcdm/models/concerns/collection_behavior.rb
|
118
134
|
- lib/hydra/pcdm/models/concerns/object_behavior.rb
|
135
|
+
- lib/hydra/pcdm/models/concerns/pcdm_behavior.rb
|
119
136
|
- lib/hydra/pcdm/models/file.rb
|
120
137
|
- lib/hydra/pcdm/models/object.rb
|
121
138
|
- lib/hydra/pcdm/object_indexer.rb
|
122
|
-
- lib/hydra/pcdm/services/collection/add_collection.rb
|
123
|
-
- lib/hydra/pcdm/services/collection/add_object.rb
|
124
|
-
- lib/hydra/pcdm/services/collection/add_related_object.rb
|
125
|
-
- lib/hydra/pcdm/services/collection/get_collections.rb
|
126
|
-
- lib/hydra/pcdm/services/collection/get_objects.rb
|
127
|
-
- lib/hydra/pcdm/services/collection/get_related_objects.rb
|
128
|
-
- lib/hydra/pcdm/services/collection/remove_collection.rb
|
129
|
-
- lib/hydra/pcdm/services/collection/remove_object.rb
|
130
|
-
- lib/hydra/pcdm/services/collection/remove_related_object.rb
|
131
139
|
- lib/hydra/pcdm/services/file/add_type.rb
|
132
140
|
- lib/hydra/pcdm/services/file/get_mime_type.rb
|
133
|
-
- lib/hydra/pcdm/
|
134
|
-
- lib/hydra/pcdm/
|
135
|
-
- lib/hydra/pcdm/
|
136
|
-
- lib/hydra/pcdm/
|
137
|
-
- lib/hydra/pcdm/
|
138
|
-
- lib/hydra/pcdm/services/object/remove_related_object.rb
|
141
|
+
- lib/hydra/pcdm/validators.rb
|
142
|
+
- lib/hydra/pcdm/validators/ancestor_validator.rb
|
143
|
+
- lib/hydra/pcdm/validators/composite_validator.rb
|
144
|
+
- lib/hydra/pcdm/validators/pcdm_object_validator.rb
|
145
|
+
- lib/hydra/pcdm/validators/pcdm_validator.rb
|
139
146
|
- lib/hydra/pcdm/version.rb
|
140
147
|
- lib/hydra/pcdm/vocab/ebucore_terms.rb
|
141
148
|
- lib/hydra/pcdm/vocab/pcdm_terms.rb
|
142
149
|
- lib/hydra/pcdm/vocab/sweetjpl_terms.rb
|
150
|
+
- spec/hydra/pcdm/ancestor_checker_spec.rb
|
143
151
|
- spec/hydra/pcdm/collection_indexer_spec.rb
|
152
|
+
- spec/hydra/pcdm/deep_member_iterator_spec.rb
|
144
153
|
- spec/hydra/pcdm/models/collection_spec.rb
|
145
154
|
- spec/hydra/pcdm/models/file_spec.rb
|
146
155
|
- spec/hydra/pcdm/models/object_spec.rb
|
147
156
|
- spec/hydra/pcdm/object_indexer_spec.rb
|
148
|
-
- spec/hydra/pcdm/services/collection/add_collection_spec.rb
|
149
|
-
- spec/hydra/pcdm/services/collection/add_object_spec.rb
|
150
|
-
- spec/hydra/pcdm/services/collection/add_related_object_spec.rb
|
151
|
-
- spec/hydra/pcdm/services/collection/get_collections_spec.rb
|
152
|
-
- spec/hydra/pcdm/services/collection/get_objects_spec.rb
|
153
|
-
- spec/hydra/pcdm/services/collection/get_related_objects_spec.rb
|
154
|
-
- spec/hydra/pcdm/services/collection/remove_collection_spec.rb
|
155
|
-
- spec/hydra/pcdm/services/collection/remove_object_spec.rb
|
156
|
-
- spec/hydra/pcdm/services/collection/remove_related_object_spec.rb
|
157
|
-
- spec/hydra/pcdm/services/file/add_type_spec.rb
|
158
157
|
- spec/hydra/pcdm/services/file/get_mime_type_spec.rb
|
159
|
-
- spec/hydra/pcdm/services/object/add_object_spec.rb
|
160
|
-
- spec/hydra/pcdm/services/object/add_related_object_spec.rb
|
161
|
-
- spec/hydra/pcdm/services/object/get_objects_spec.rb
|
162
|
-
- spec/hydra/pcdm/services/object/get_related_objects_spec.rb
|
163
|
-
- spec/hydra/pcdm/services/object/remove_object_spec.rb
|
164
|
-
- spec/hydra/pcdm/services/object/remove_related_object_spec.rb
|
165
158
|
- spec/hydra/pcdm_spec.rb
|
166
159
|
- spec/spec_helper.rb
|
167
160
|
homepage: https://github.com/projecthydra-labs/hydra-pcdm
|
@@ -184,32 +177,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
177
|
version: '0'
|
185
178
|
requirements: []
|
186
179
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.4.
|
180
|
+
rubygems_version: 2.4.5
|
188
181
|
signing_key:
|
189
182
|
specification_version: 4
|
190
183
|
summary: Portland Common Data Model (PCDM)
|
191
184
|
test_files:
|
185
|
+
- spec/hydra/pcdm/ancestor_checker_spec.rb
|
192
186
|
- spec/hydra/pcdm/collection_indexer_spec.rb
|
187
|
+
- spec/hydra/pcdm/deep_member_iterator_spec.rb
|
193
188
|
- spec/hydra/pcdm/models/collection_spec.rb
|
194
189
|
- spec/hydra/pcdm/models/file_spec.rb
|
195
190
|
- spec/hydra/pcdm/models/object_spec.rb
|
196
191
|
- spec/hydra/pcdm/object_indexer_spec.rb
|
197
|
-
- spec/hydra/pcdm/services/collection/add_collection_spec.rb
|
198
|
-
- spec/hydra/pcdm/services/collection/add_object_spec.rb
|
199
|
-
- spec/hydra/pcdm/services/collection/add_related_object_spec.rb
|
200
|
-
- spec/hydra/pcdm/services/collection/get_collections_spec.rb
|
201
|
-
- spec/hydra/pcdm/services/collection/get_objects_spec.rb
|
202
|
-
- spec/hydra/pcdm/services/collection/get_related_objects_spec.rb
|
203
|
-
- spec/hydra/pcdm/services/collection/remove_collection_spec.rb
|
204
|
-
- spec/hydra/pcdm/services/collection/remove_object_spec.rb
|
205
|
-
- spec/hydra/pcdm/services/collection/remove_related_object_spec.rb
|
206
|
-
- spec/hydra/pcdm/services/file/add_type_spec.rb
|
207
192
|
- spec/hydra/pcdm/services/file/get_mime_type_spec.rb
|
208
|
-
- spec/hydra/pcdm/services/object/add_object_spec.rb
|
209
|
-
- spec/hydra/pcdm/services/object/add_related_object_spec.rb
|
210
|
-
- spec/hydra/pcdm/services/object/get_objects_spec.rb
|
211
|
-
- spec/hydra/pcdm/services/object/get_related_objects_spec.rb
|
212
|
-
- spec/hydra/pcdm/services/object/remove_object_spec.rb
|
213
|
-
- spec/hydra/pcdm/services/object/remove_related_object_spec.rb
|
214
193
|
- spec/hydra/pcdm_spec.rb
|
215
194
|
- spec/spec_helper.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Hydra::PCDM
|
2
|
-
class AddCollectionToCollection
|
3
|
-
|
4
|
-
##
|
5
|
-
# Add a collection to a collection.
|
6
|
-
#
|
7
|
-
# @param [Hydra::PCDM::Collection] :parent_collection to which to add collection
|
8
|
-
# @param [Hydra::PCDM::Collection] :child_collection being added
|
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
|
-
raise ArgumentError, "a collection can't be an ancestor of itself" if parent_collection.ancestor? child_collection
|
16
|
-
parent_collection.members << child_collection
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Hydra::PCDM
|
2
|
-
class AddObjectToCollection
|
3
|
-
|
4
|
-
##
|
5
|
-
# Add an object to a collection.
|
6
|
-
#
|
7
|
-
# @param [Hydra::PCDM::Collection] :parent_collection to which to add object
|
8
|
-
# @param [Hydra::PCDM::Object] :child_object being added
|
9
|
-
#
|
10
|
-
# @return [Hydra::PCDM::Collection] the updated pcdm collection
|
11
|
-
|
12
|
-
def self.call( parent_collection, child_object )
|
13
|
-
raise ArgumentError, "parent_collection must be a pcdm collection" unless Hydra::PCDM.collection? parent_collection
|
14
|
-
raise ArgumentError, "child_object must be a pcdm object" unless Hydra::PCDM.object? child_object
|
15
|
-
parent_collection.members << child_object
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Hydra::PCDM
|
2
|
-
class AddRelatedObjectToCollection
|
3
|
-
|
4
|
-
##
|
5
|
-
# Add a related object to a collection.
|
6
|
-
#
|
7
|
-
# @param [Hydra::PCDM::Collection] :parent_collection to which to add the related object
|
8
|
-
# @param [Hydra::PCDM::Object] :child_related_object being added
|
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 object' 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
|
-
# parent_collection.related_objects = parent_collection.related_objects.to_a + child_related_object
|
17
|
-
parent_collection.related_objects << child_related_object
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Hydra::PCDM
|
2
|
-
class GetCollectionsFromCollection
|
3
|
-
|
4
|
-
##
|
5
|
-
# Get member collections from a collection in order.
|
6
|
-
#
|
7
|
-
# @param [Hydra::PCDM::Collection] :parent_collection in which the child collections are members
|
8
|
-
#
|
9
|
-
# @return [Array<Hydra::PCDM::Collection>] all member collections
|
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.child_collections
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,36 +0,0 @@
|
|
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
|
@@ -1,43 +0,0 @@
|
|
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
|
@@ -1,36 +0,0 @@
|
|
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
|
@@ -1,20 +0,0 @@
|
|
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
|