active-fedora 8.0.1 → 8.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/History.txt +15 -0
- data/active-fedora.gemspec +1 -1
- data/lib/active_fedora.rb +1 -1
- data/lib/active_fedora/content_model.rb +6 -7
- data/lib/active_fedora/core.rb +7 -13
- data/lib/active_fedora/rdf/identifiable.rb +1 -1
- data/lib/active_fedora/relation/finder_methods.rb +5 -3
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/datastreams_spec.rb +5 -5
- data/spec/unit/base_spec.rb +2 -2
- data/spec/unit/content_model_spec.rb +2 -2
- data/spec/unit/om_datastream_spec.rb +2 -2
- data/spec/unit/rdf_datastream_spec.rb +2 -1
- data/spec/unit/rdf_resource_datastream_spec.rb +1 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f80f162fa9ed3128b27996f14c735381637053d0
|
4
|
+
data.tar.gz: 7fd1c593871f7b7e02176bd4498b65d5c58e5bc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a35dc73b4243b5b5c3c3c647ae84102126e0e7781e6b65b88a140c65407055ba6e846a6281af56d8440f79fba19d1b78e04fbbe0dc079c13a714d042e3278840
|
7
|
+
data.tar.gz: 49a39ac794359b97de9d8165fed133211950b6f2e4ce2b8fdf84d9550dc0a659bad1c39cd09d7dc52cacc957e3019f96ef728614cd412325da6b687cfd95b3fa
|
data/History.txt
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
8.1.0
|
2
|
+
|
3
|
+
2015-04-27: Patches casting behavior [David Chandek-Stark]
|
4
|
+
See https://github.com/projecthydra/active_fedora/wiki/Patching-ActiveFedora-7.x-&-8.x-Casting-Behavior
|
5
|
+
for detailed information on the problem.
|
6
|
+
|
7
|
+
The solution offered in this patch preserves the most-specific-class algorithm
|
8
|
+
of `ActiveFedora::ContentModel.best_model_for` and raises a new execption,
|
9
|
+
`ActiveFedora::ModelNotAsserted` in `ActiveFedora::Core#adapt_to_cmodel`.
|
10
|
+
|
11
|
+
Note that a repository object can still be loaded into a model class not asserted,
|
12
|
+
for example, by using `.find` with `cast: false`.
|
13
|
+
|
14
|
+
Closes #746 (although not really a backport)
|
15
|
+
|
1
16
|
8.0.1
|
2
17
|
|
3
18
|
2015-03-11: Backport solr escape patch [Chris Colvard]
|
data/active-fedora.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.license = "APACHE2"
|
15
15
|
s.required_ruby_version = '>= 1.9.3'
|
16
16
|
|
17
|
-
s.add_dependency 'rsolr', "~> 1.0.
|
17
|
+
s.add_dependency 'rsolr', "~> 1.0.11"
|
18
18
|
s.add_dependency 'om', '~> 3.1'
|
19
19
|
s.add_dependency 'nom-xml', '>= 0.5.1'
|
20
20
|
s.add_dependency "activesupport", '>= 3.0.0'
|
data/lib/active_fedora.rb
CHANGED
@@ -23,7 +23,7 @@ module ActiveFedora #:nodoc:
|
|
23
23
|
class RecordNotSaved < RuntimeError; end # :nodoc:
|
24
24
|
class IllegalOperation < RuntimeError; end # :nodoc:
|
25
25
|
class Rollback < RuntimeError; end # :nodoc:
|
26
|
-
|
26
|
+
class ModelNotAsserted < RuntimeError; end # :nodoc:
|
27
27
|
|
28
28
|
eager_autoload do
|
29
29
|
autoload :AssociationRelation
|
@@ -14,15 +14,14 @@ module ActiveFedora
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.best_model_for(obj)
|
17
|
-
best_model_match =
|
17
|
+
best_model_match = nil
|
18
18
|
|
19
19
|
known_models_for(obj).each do |model_value|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
best_model_match = model_value
|
20
|
+
if model_value <= obj.class
|
21
|
+
# If there is an inheritance structure, use the most specific case.
|
22
|
+
if best_model_match.nil? || best_model_match > model_value
|
23
|
+
best_model_match = model_value
|
24
|
+
end
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
data/lib/active_fedora/core.rb
CHANGED
@@ -119,22 +119,16 @@ module ActiveFedora
|
|
119
119
|
klass.allocate.init_with_object(inner_object)
|
120
120
|
end
|
121
121
|
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
# in the RELS-EXT for this object. Due to how the RDF writer works, this is
|
126
|
-
# currently just the first alphabetical model.
|
127
|
-
#
|
128
|
-
# If the object was instantiated with any other class, then use that class
|
129
|
-
# as the base of the type the user wants rather than casting to the first
|
130
|
-
# :has_model found on the object.
|
131
|
-
#
|
132
|
-
# In either case, if an extended model of that initial base model of the two
|
133
|
-
# cases above exists in the :has_model, then instantiate as that extended
|
134
|
-
# model type instead.
|
122
|
+
# Adapts the inner object to the best known model
|
123
|
+
# Raise ActiveFedora::ModelNotAsserted if unable to adapt object
|
124
|
+
# (i.e, best model is nil)
|
135
125
|
def adapt_to_cmodel
|
136
126
|
best_model_match = ActiveFedora::ContentModel.best_model_for(self)
|
137
127
|
|
128
|
+
if best_model_match.nil?
|
129
|
+
raise ActiveFedora::ModelNotAsserted, "Unable to adapt #{self.inspect} to a model asserted for the resource."
|
130
|
+
end
|
131
|
+
|
138
132
|
self.instance_of?(best_model_match) ? self : self.adapt_to(best_model_match)
|
139
133
|
end
|
140
134
|
|
@@ -47,7 +47,7 @@ module ActiveFedora::RDF::Identifiable
|
|
47
47
|
# @param [RDF::URI] uri URI that is being looked up.
|
48
48
|
def from_uri(uri,_)
|
49
49
|
begin
|
50
|
-
|
50
|
+
ActiveFedora::Base.find(pid_from_subject(uri))
|
51
51
|
rescue ActiveFedora::ObjectNotFoundError
|
52
52
|
self.ds_specs[resource_datastream.to_s][:type].resource_class.new(uri)
|
53
53
|
end
|
@@ -168,10 +168,12 @@ module ActiveFedora
|
|
168
168
|
protected
|
169
169
|
|
170
170
|
def load_from_fedora(pid, cast)
|
171
|
-
cast = true if klass == ActiveFedora::Base && cast.nil?
|
172
171
|
inner = DigitalObject.find(klass, pid)
|
173
|
-
|
174
|
-
cast
|
172
|
+
obj = klass.allocate.init_with_object(inner)
|
173
|
+
if cast != false
|
174
|
+
obj = obj.adapt_to_cmodel
|
175
|
+
end
|
176
|
+
obj
|
175
177
|
end
|
176
178
|
|
177
179
|
def find_with_ids(ids, cast)
|
@@ -60,7 +60,7 @@ describe ActiveFedora::Datastreams do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should use ds_specs and preserve existing datastreams on migrated objects" do
|
63
|
-
test_obj = HasMetadata.find(@base.pid)
|
63
|
+
test_obj = HasMetadata.find(@base.pid, cast: false)
|
64
64
|
expect(test_obj.datastreams["testDS"].dsLabel).to eql "Test DS"
|
65
65
|
expect(test_obj.datastreams["testDS"].new?).to be_false
|
66
66
|
expect(test_obj.with_versions.dsLabel).to eql "Versioned DS"
|
@@ -114,17 +114,17 @@ describe ActiveFedora::Datastreams do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should use ds_specs on migrated objects" do
|
117
|
-
test_obj = HasFile.find(@base.pid)
|
117
|
+
test_obj = HasFile.find(@base.pid, cast: false)
|
118
118
|
expect(test_obj.file_ds.versionable).to be_false
|
119
119
|
expect(test_obj.file_ds.new?).to be_true
|
120
120
|
test_obj.file_ds.content = "blah blah blah"
|
121
121
|
test_obj.save
|
122
122
|
expect(test_obj.file_ds.versionable).to be_false
|
123
123
|
# look it up again to check datastream profile
|
124
|
-
test_obj = HasFile.find(@base.pid)
|
124
|
+
test_obj = HasFile.find(@base.pid, cast: false)
|
125
125
|
expect(test_obj.file_ds.versionable).to be_false
|
126
126
|
expect(test_obj.file_ds.dsLabel).to eql "File Datastream"
|
127
|
-
test_obj = HasFile.find(@base2.pid)
|
127
|
+
test_obj = HasFile.find(@base2.pid, cast: false)
|
128
128
|
expect(test_obj.file_ds.versionable).to be_true
|
129
129
|
expect(test_obj.file_ds.dsLabel).to eql "Pre-existing DS"
|
130
130
|
end
|
@@ -170,4 +170,4 @@ describe ActiveFedora::Datastreams do
|
|
170
170
|
expect(test_obj.datastreams['someMetadata'].controlGroup).to eql 'M'
|
171
171
|
end
|
172
172
|
end
|
173
|
-
end
|
173
|
+
end
|
data/spec/unit/base_spec.rb
CHANGED
@@ -428,9 +428,9 @@ describe ActiveFedora::Base do
|
|
428
428
|
describe ".adapt_to_cmodel with implemented (non-ActiveFedora::Base) cmodel" do
|
429
429
|
subject { FooHistory.new }
|
430
430
|
|
431
|
-
it "should
|
431
|
+
it "should raise an exception if the object class is not equal to or a subclass of any known model" do
|
432
432
|
ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooAdaptation])
|
433
|
-
subject.adapt_to_cmodel.
|
433
|
+
expect { subject.adapt_to_cmodel }.to raise_error(ActiveFedora::ModelNotAsserted)
|
434
434
|
end
|
435
435
|
it "should cast to an inherited model over a random one" do
|
436
436
|
ActiveFedora::ContentModel.should_receive(:known_models_for).with(subject).and_return([FooAdaptation, FooInherited])
|
@@ -19,10 +19,10 @@ describe ActiveFedora::ContentModel do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '.best_model_for' do
|
22
|
-
it 'should be
|
22
|
+
it 'should be nil if no relationships' do
|
23
23
|
mock_object = BaseModel.new
|
24
24
|
mock_object.should_receive(:relationships).with(:has_model).and_return([])
|
25
|
-
expect(ActiveFedora::ContentModel.best_model_for(mock_object)).to
|
25
|
+
expect(ActiveFedora::ContentModel.best_model_for(mock_object)).to be_nil
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should be based on inheritance hierarchy' do
|
@@ -407,15 +407,15 @@ describe ActiveFedora::OmDatastream do
|
|
407
407
|
@obj = MyObj.new
|
408
408
|
@obj.descMetadata.title = 'Foobar'
|
409
409
|
@obj.save
|
410
|
+
@obj.reload
|
410
411
|
end
|
411
412
|
after do
|
412
413
|
@obj.destroy
|
413
414
|
Object.send(:remove_const, :MyObj)
|
414
415
|
end
|
415
|
-
subject { @obj.reload.descMetadata }
|
416
416
|
it "should not load the descMetadata datastream when calling content_changed?" do
|
417
417
|
@obj.inner_object.repository.should_not_receive(:datastream_dissemination).with(hash_including(:dsid=>'descMetadata'))
|
418
|
-
|
418
|
+
@obj.descMetadata.should_not be_content_changed
|
419
419
|
end
|
420
420
|
end
|
421
421
|
end
|
@@ -18,13 +18,14 @@ describe ActiveFedora::RDFDatastream do
|
|
18
18
|
@obj = MyObj.new
|
19
19
|
@obj.descMetadata.title = 'Foobar'
|
20
20
|
@obj.save
|
21
|
+
@obj.reload
|
21
22
|
end
|
22
23
|
after do
|
23
24
|
@obj.destroy
|
24
25
|
Object.send(:remove_const, :MyDatastream)
|
25
26
|
Object.send(:remove_const, :MyObj)
|
26
27
|
end
|
27
|
-
subject { @obj.
|
28
|
+
subject { @obj.descMetadata }
|
28
29
|
it "should not load the descMetadata datastream when calling content_changed?" do
|
29
30
|
@obj.inner_object.repository.should_not_receive(:datastream_dissemination).with(hash_including(:dsid=>'descMetadata'))
|
30
31
|
subject.should_not be_content_changed
|
@@ -7,8 +7,6 @@ describe ActiveFedora::RDFDatastream do
|
|
7
7
|
property :relation, :predicate => RDF::DC[:relation]
|
8
8
|
end
|
9
9
|
|
10
|
-
class DummyAsset < ActiveFedora::Base; end;
|
11
|
-
|
12
10
|
class DummyResource < ActiveFedora::RDFDatastream
|
13
11
|
property :title, :predicate => RDF::DC[:title], :class_name => RDF::Literal do |index|
|
14
12
|
index.as :searchable, :displayable
|
@@ -16,7 +14,7 @@ describe ActiveFedora::RDFDatastream do
|
|
16
14
|
property :license, :predicate => RDF::DC[:license], :class_name => DummySubnode do |index|
|
17
15
|
index.as :searchable, :displayable
|
18
16
|
end
|
19
|
-
property :creator, :predicate => RDF::DC[:creator], :class_name => DummyAsset do |index|
|
17
|
+
property :creator, :predicate => RDF::DC[:creator], :class_name => "DummyAsset" do |index|
|
20
18
|
index.as :searchable
|
21
19
|
end
|
22
20
|
def serialization_format
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0
|
4
|
+
version: 8.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.0.
|
21
|
+
version: 1.0.11
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.0.
|
28
|
+
version: 1.0.11
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: om
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|