active-fedora 4.0.0.rc13 → 4.0.0.rc14
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.
- data/Gemfile.lock +1 -1
- data/History.txt +2 -2
- data/lib/active_fedora/base.rb +7 -5
- data/lib/active_fedora/metadata_datastream.rb +6 -5
- data/lib/active_fedora/nokogiri_datastream.rb +4 -9
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/model_spec.rb +6 -0
- data/spec/integration/mods_article_integration_spec.rb +1 -23
- data/spec/unit/model_spec.rb +0 -5
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/History.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
4.0.0.
|
1
|
+
4.0.0.rc14
|
2
2
|
Removed deprecations
|
3
3
|
* allowing :fedora level in fedora.yml
|
4
4
|
* automatic includes of Relationships and FileMethods is removed
|
@@ -8,7 +8,7 @@ Improved loading from solr
|
|
8
8
|
RDF datastreams
|
9
9
|
Replaced solr-ruby with rsolr. Note: remove any calls to .hits
|
10
10
|
load_instance is now deprecated, replaced with find
|
11
|
-
Find always
|
11
|
+
Find and load_instance_from_solr always instantiate the model defined in the object.
|
12
12
|
Run a stub :environment task in the fixture loading rake tasks (which is overridden by rails)
|
13
13
|
Find raises ObjectNotFoundError when the object isn't found
|
14
14
|
Removed dependency on solrizer-fedora
|
data/lib/active_fedora/base.rb
CHANGED
@@ -316,7 +316,6 @@ module ActiveFedora
|
|
316
316
|
end
|
317
317
|
|
318
318
|
|
319
|
-
# ** EXPERIMENTAL **
|
320
319
|
# This method adapts the inner_object to a new ActiveFedora::Base implementation
|
321
320
|
# This is intended to minimize redundant interactions with Fedora
|
322
321
|
def adapt_to(klass)
|
@@ -346,8 +345,6 @@ module ActiveFedora
|
|
346
345
|
self.init_with DigitalObject.find(self.class,self.pid)
|
347
346
|
end
|
348
347
|
|
349
|
-
# ** EXPERIMENTAL **
|
350
|
-
#
|
351
348
|
# This method can be used instead of ActiveFedora::Model::ClassMethods.find.
|
352
349
|
# It works similarly except it populates an object from Solr instead of Fedora.
|
353
350
|
# It is most useful for objects used in read-only displays in order to speed up loading time. If only
|
@@ -369,8 +366,13 @@ module ActiveFedora
|
|
369
366
|
else
|
370
367
|
raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
|
371
368
|
end
|
369
|
+
klass = if class_str = solr_doc['active_fedora_model_s']
|
370
|
+
class_str.first.constantize
|
371
|
+
else
|
372
|
+
ActiveFedora::Base
|
373
|
+
end
|
372
374
|
|
373
|
-
obj =
|
375
|
+
obj = klass.allocate.init_with(SolrDigitalObject.new(solr_doc, self))
|
374
376
|
#set by default to load any dependent relationship objects from solr as well
|
375
377
|
#need to call rels_ext once so it exists when iterating over datastreams
|
376
378
|
obj.rels_ext
|
@@ -475,7 +477,7 @@ module ActiveFedora
|
|
475
477
|
include Associations
|
476
478
|
include NestedAttributes
|
477
479
|
include Reflection
|
478
|
-
include NamedRelationships
|
480
|
+
include NamedRelationships ##TODO don't include by default
|
479
481
|
end
|
480
482
|
|
481
483
|
end
|
@@ -248,22 +248,23 @@ module ActiveFedora
|
|
248
248
|
def field(name, tupe, opts={})
|
249
249
|
#TODO add term to terminology
|
250
250
|
@fields[name.to_s.to_sym]={:type=>tupe, :values=>[]}.merge(opts)
|
251
|
-
eval <<-EOS
|
252
|
-
|
251
|
+
#eval <<-EOS
|
252
|
+
(class << self; self; end).class_eval do
|
253
|
+
define_method "#{name}_values=".to_sym do |arg|
|
253
254
|
ensure_xml_loaded
|
254
255
|
@fields["#{name.to_s}".to_sym][:values]=[arg].flatten
|
255
256
|
self.dirty=true
|
256
257
|
end
|
257
|
-
|
258
|
+
define_method "#{name}_values".to_sym do
|
258
259
|
ensure_xml_loaded
|
259
260
|
@fields["#{name}".to_sym][:values]
|
260
261
|
end
|
261
|
-
|
262
|
+
define_method "#{name}_append".to_sym do |arg|
|
262
263
|
ensure_xml_loaded
|
263
264
|
@fields["#{name}".to_sym][:values] << arg
|
264
265
|
self.dirty =true
|
265
266
|
end
|
266
|
-
|
267
|
+
end
|
267
268
|
end
|
268
269
|
|
269
270
|
end
|
@@ -176,10 +176,9 @@ module ActiveFedora
|
|
176
176
|
values = []
|
177
177
|
solr_doc = @internal_solr_doc
|
178
178
|
return values if solr_doc.nil?
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
if is_hierarchical_term_pointer?(*term_pointer)
|
179
|
+
term = self.class.terminology.retrieve_term(*OM.pointers_to_flat_array(term_pointer, false))
|
180
|
+
#check if hierarchical term pointer
|
181
|
+
if is_hierarchical_term_pointer?(*term_pointer)
|
183
182
|
# if we are hierarchical need to detect all possible node values that exist
|
184
183
|
# we do this by building up the possible solr names parent by parent and/or child by child
|
185
184
|
# if an index is supplied for any node in the pointer it will be used
|
@@ -227,7 +226,7 @@ module ActiveFedora
|
|
227
226
|
value.is_a?(Array) ? values.concat(value) : values << value
|
228
227
|
end
|
229
228
|
end
|
230
|
-
|
229
|
+
else
|
231
230
|
#this is not hierarchical and we can simply look for the solr name created using the terms without any indexes
|
232
231
|
generic_field_name_base = OM::XML::Terminology.term_generic_name(*term_pointer)
|
233
232
|
generic_field_name = generate_solr_symbol(generic_field_name_base, term.data_type)
|
@@ -235,10 +234,6 @@ module ActiveFedora
|
|
235
234
|
unless value.nil?
|
236
235
|
value.is_a?(Array) ? values.concat(value) : values << value
|
237
236
|
end
|
238
|
-
end
|
239
|
-
rescue Exception => e
|
240
|
-
#just do nothing since term does not exist and return emtpy values
|
241
|
-
raise e
|
242
237
|
end
|
243
238
|
values
|
244
239
|
end
|
@@ -58,4 +58,10 @@ describe ActiveFedora::Model do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
describe "#load_instance_from_solr" do
|
62
|
+
describe "with a valid pid" do
|
63
|
+
subject { ActiveFedora::Base.load_instance_from_solr('hydrangea:fixture_mods_article1') }
|
64
|
+
it { should be_instance_of HydrangeaArticle}
|
65
|
+
end
|
66
|
+
end
|
61
67
|
end
|
@@ -1,31 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
|
-
|
5
|
-
before(:all) do
|
6
|
-
class HydrangeaArticle < ActiveFedora::Base
|
7
|
-
include ActiveFedora::Relationships
|
8
|
-
has_relationship "parts", :is_part_of, :inbound => true
|
9
|
-
|
10
|
-
# Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
|
11
|
-
# has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
|
12
|
-
|
13
|
-
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
14
|
-
has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream
|
15
|
-
|
16
|
-
# A place to put extra metadata values
|
17
|
-
has_metadata :name => "properties", :type => ActiveFedora::MetadataDatastream do |m|
|
18
|
-
m.field 'collection', :string
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
before(:each) do
|
24
|
-
@test_article = HydrangeaArticle.find("hydrangea:fixture_mods_article1")
|
25
|
-
end
|
26
|
-
|
27
4
|
describe ".update_indexed_attributes" do
|
28
5
|
before(:each) do
|
6
|
+
@test_article = HydrangeaArticle.find("hydrangea:fixture_mods_article1")
|
29
7
|
@test_article.update_indexed_attributes({[{:person=>0}, :first_name] => "GIVEN NAMES"}, :datastreams=>"descMetadata")
|
30
8
|
end
|
31
9
|
after(:each) do
|
data/spec/unit/model_spec.rb
CHANGED
@@ -101,11 +101,6 @@ describe ActiveFedora::Model do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
|
105
|
-
it 'should provide #find_by_solr' do
|
106
|
-
SpecModel::Basic.should respond_to(:find)
|
107
|
-
end
|
108
|
-
|
109
104
|
describe '#find_by_solr' do
|
110
105
|
it "(:all) should query solr for all objects with :active_fedora_model_s of self.class and return a Solr result" do
|
111
106
|
mock_response = mock("SolrResponse")
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424137
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 4
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 4.0.0.
|
11
|
+
- 14
|
12
|
+
version: 4.0.0.rc14
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Matt Zumwalt
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2012-03-
|
22
|
+
date: 2012-03-18 00:00:00 Z
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
prerelease: false
|