active-fedora 2.3.1 → 2.3.3
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/CONSOLE_GETTING_STARTED.textile +14 -14
- data/Gemfile.lock +6 -6
- data/NOKOGIRI_DATASTREAMS.textile +19 -17
- data/config/solr.yml +15 -0
- data/lib/active_fedora.rb +14 -7
- data/lib/active_fedora/base.rb +5 -7
- data/lib/active_fedora/datastream.rb +12 -0
- data/lib/active_fedora/semantic_node.rb +15 -254
- data/lib/active_fedora/solr_service.rb +4 -0
- data/lib/active_fedora/version.rb +1 -1
- data/lib/fedora/datastream.rb +14 -3
- data/lib/tasks/active_fedora_dev.rake +2 -2
- data/spec/fixtures/rails_root/config/fedora.yml +4 -4
- data/spec/integration/bug_spec.rb +1 -1
- data/spec/integration/model_spec.rb +1 -1
- data/spec/integration/nokogiri_datastream_spec.rb +1 -2
- data/spec/integration/semantic_node_spec.rb +2 -259
- data/spec/unit/active_fedora_spec.rb +7 -2
- data/spec/unit/base_spec.rb +16 -5
- data/spec/unit/datastream_spec.rb +41 -1
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/relationship_spec.rb +1 -1
- data/spec/unit/rf_datastream_spec.rb +14 -0
- data/spec/unit/semantic_node_spec.rb +7 -14
- metadata +5 -5
- data/lib/active_fedora/samples/sample_af_obj_relationship_query_param.rb +0 -11
data/spec/unit/base_spec.rb
CHANGED
@@ -14,7 +14,7 @@ class FooHistory < ActiveFedora::Base
|
|
14
14
|
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"withText" do |m|
|
15
15
|
m.field "fubar", :text
|
16
16
|
end
|
17
|
-
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"withText2" do |m|
|
17
|
+
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"withText2", :label=>"withLabel" do |m|
|
18
18
|
m.field "fubar", :text
|
19
19
|
end
|
20
20
|
end
|
@@ -65,12 +65,23 @@ describe ActiveFedora::Base do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "has_metadata" do
|
68
|
+
before :each do
|
69
|
+
@n = FooHistory.new(:pid=>"monkey:99")
|
70
|
+
@n.save
|
71
|
+
end
|
72
|
+
|
73
|
+
after :each do
|
74
|
+
begin
|
75
|
+
@n.delete
|
76
|
+
rescue
|
77
|
+
end
|
78
|
+
end
|
68
79
|
|
69
80
|
it "should create specified datastreams with specified fields" do
|
70
|
-
n
|
71
|
-
n.datastreams["someData"].
|
72
|
-
n.datastreams["someData"].fubar_values
|
73
|
-
n.datastreams["
|
81
|
+
@n.datastreams["someData"].should_not be_nil
|
82
|
+
@n.datastreams["someData"].fubar_values='bar'
|
83
|
+
@n.datastreams["someData"].fubar_values.should == ['bar']
|
84
|
+
@n.datastreams["withText2"].label.should == "withLabel"
|
74
85
|
end
|
75
86
|
|
76
87
|
end
|
@@ -81,5 +81,45 @@ describe ActiveFedora::Datastream do
|
|
81
81
|
ds2 = ActiveFedora::Datastream.new(:mime_type=>"text/bar")
|
82
82
|
ds2.mime_type.should == "text/bar"
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
|
+
describe ".size" do
|
86
|
+
it "should lazily load the datastream size attribute from the fedora repository" do
|
87
|
+
ds_profile = <<-EOS
|
88
|
+
<datastreamProfile
|
89
|
+
xmlns=\"http://www.fedora.info/definitions/1/0/management/\"
|
90
|
+
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
|
91
|
+
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
|
92
|
+
xsi:schemaLocation=\"http://www.fedora.info/definitions/1/0/management/ http://www.fedora.info/definitions/1/0/datastreamProfile.xsd\"
|
93
|
+
pid=\"#{@test_object.pid}\"
|
94
|
+
dsID=\"#{@test_datastream.dsid}\" >
|
95
|
+
<dsLabel></dsLabel>
|
96
|
+
<dsVersionID>#{@test_datastream.dsid}.1</dsVersionID>
|
97
|
+
<dsCreateDate>2011-07-11T16:48:13.536Z</dsCreateDate>
|
98
|
+
<dsState>A</dsState>
|
99
|
+
<dsMIME>text/xml</dsMIME>
|
100
|
+
<dsFormatURI></dsFormatURI>
|
101
|
+
<dsControlGroup>X</dsControlGroup>
|
102
|
+
<dsSize>9999</dsSize>
|
103
|
+
<dsVersionable>true</dsVersionable>
|
104
|
+
<dsInfoType></dsInfoType>
|
105
|
+
<dsLocation>#{@test_object.pid}+#{@test_datastream.dsid}+#{@test_datastream.dsid}.1</dsLocation>
|
106
|
+
<dsLocationType></dsLocationType>
|
107
|
+
<dsChecksumType>DISABLED</dsChecksumType>
|
108
|
+
<dsChecksum>none</dsChecksum>
|
109
|
+
</datastreamProfile>"
|
110
|
+
EOS
|
111
|
+
Fedora::Repository.instance.expects(:fetch_custom).with(@test_object.pid, "datastreams/#{@test_datastream.dsid}").returns(ds_profile)
|
112
|
+
@test_datastream.expects(:new_object?).returns(false)
|
113
|
+
@test_datastream.attributes.fetch(:dsSize,nil).should be_nil
|
114
|
+
@test_datastream.size.should == "9999"
|
115
|
+
@test_datastream.attributes.fetch(:dsSize,nil).should_not be_nil
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should default to an empty string if ds has not been saved" do
|
119
|
+
@test_datastream.attributes.fetch(:dsSize,nil).should be_nil
|
120
|
+
@test_datastream.size.should be_nil
|
121
|
+
@test_datastream.attributes.fetch(:dsSize,nil).should be_nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
85
125
|
end
|
data/spec/unit/property_spec.rb
CHANGED
@@ -45,5 +45,19 @@ describe Fedora::Datastream do
|
|
45
45
|
@test_datastream.attributes[:dsLabel].should == "Foo dsLabel"
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
describe ".mime_type" do
|
50
|
+
it "should return the mimeType attribute" do
|
51
|
+
@test_datastream.mime_type.should == @test_datastream.attributes["mimeType"]
|
52
|
+
end
|
53
|
+
end
|
48
54
|
|
55
|
+
describe ".mime_type=" do
|
56
|
+
it "should set the mimeType attribute" do
|
57
|
+
@test_datastream.mime_type.should_not == "foo/bar"
|
58
|
+
@test_datastream.attributes["mimeType"].should_not == "foo/bar"
|
59
|
+
@test_datastream.mime_type= "foo/bar"
|
60
|
+
@test_datastream.mime_type.should == "foo/bar"
|
61
|
+
end
|
62
|
+
end
|
49
63
|
end
|
@@ -5,7 +5,7 @@ require 'xmlsimple'
|
|
5
5
|
#require 'mocha'
|
6
6
|
|
7
7
|
#include ActiveFedora::SemanticNode
|
8
|
-
#include Mocha::
|
8
|
+
#include Mocha::API
|
9
9
|
|
10
10
|
@@last_pid = 0
|
11
11
|
|
@@ -187,7 +187,6 @@ describe ActiveFedora::SemanticNode do
|
|
187
187
|
end
|
188
188
|
|
189
189
|
#can only duplicate predicates if not both inbound or not both outbound
|
190
|
-
=begin
|
191
190
|
class MockHasRelationshipDuplicatePredicate < SpecNode2
|
192
191
|
has_relationship "testing", :has_member, :type=>SpecNode2
|
193
192
|
had_exception = false
|
@@ -198,9 +197,7 @@ describe ActiveFedora::SemanticNode do
|
|
198
197
|
end
|
199
198
|
raise "Did not raise exception if duplicate predicate used" unless had_exception
|
200
199
|
end
|
201
|
-
|
202
|
-
|
203
|
-
=begin
|
200
|
+
|
204
201
|
#can only duplicate predicates if not both inbound or not both outbound
|
205
202
|
class MockHasRelationshipDuplicatePredicate2 < SpecNode2
|
206
203
|
has_relationship "testing", :has_member, :type=>SpecNode2, :inbound=>true
|
@@ -212,7 +209,6 @@ describe ActiveFedora::SemanticNode do
|
|
212
209
|
end
|
213
210
|
raise "Did not raise exception if duplicate predicate used" unless had_exception
|
214
211
|
end
|
215
|
-
=end
|
216
212
|
|
217
213
|
it 'should create relationship descriptions both inbound and outbound' do
|
218
214
|
@test_object2 = MockHasRelationship.new
|
@@ -269,8 +265,7 @@ describe ActiveFedora::SemanticNode do
|
|
269
265
|
mock_repo.expects(:find_model).with("_PID3_", "AudioRecord").returns("AR3")
|
270
266
|
SpecNode.create_inbound_relationship_finders("parts", :is_part_of, :inbound => true)
|
271
267
|
local_node = SpecNode.new()
|
272
|
-
local_node.expects(:
|
273
|
-
SpecNode.expects(:named_relationships_desc).returns({:inbound=>{"parts"=>{:predicate=>:is_part_of}}}).at_least_once()
|
268
|
+
local_node.expects(:internal_uri).returns("info:fedora/test:sample_pid")
|
274
269
|
ActiveFedora::SolrService.instance.conn.expects(:query).with("is_part_of_s:info\\:fedora/test\\:sample_pid", :rows=>25).returns(solr_result)
|
275
270
|
Fedora::Repository.expects(:instance).returns(mock_repo).times(3)
|
276
271
|
Kernel.expects(:const_get).with("AudioRecord").returns("AudioRecord").times(3)
|
@@ -283,8 +278,7 @@ describe ActiveFedora::SemanticNode do
|
|
283
278
|
local_node = SpecNode.new
|
284
279
|
mock_repo = mock("repo")
|
285
280
|
mock_repo.expects(:find_model).never
|
286
|
-
local_node.expects(:
|
287
|
-
SpecNode.expects(:named_relationships_desc).returns({:inbound=>{"constituents"=>{:predicate=>:is_constituent_of}}}).at_least_once()
|
281
|
+
local_node.expects(:internal_uri).returns("info:fedora/test:sample_pid")
|
288
282
|
ActiveFedora::SolrService.instance.conn.expects(:query).with("is_constituent_of_s:info\\:fedora/test\\:sample_pid", :rows=>101).returns(solr_result)
|
289
283
|
local_node.constituents(:response_format => :solr, :rows=>101).should equal(solr_result)
|
290
284
|
end
|
@@ -293,8 +287,7 @@ describe ActiveFedora::SemanticNode do
|
|
293
287
|
it "resulting _ids finder should search against solr and return an array of fedora PIDs" do
|
294
288
|
SpecNode.create_inbound_relationship_finders("parts", :is_part_of, :inbound => true)
|
295
289
|
local_node = SpecNode.new
|
296
|
-
local_node.expects(:
|
297
|
-
SpecNode.expects(:named_relationships_desc).returns({:inbound=>{"parts"=>{:predicate=>:is_part_of}}}).at_least_once()
|
290
|
+
local_node.expects(:internal_uri).returns("info:fedora/test:sample_pid")
|
298
291
|
ActiveFedora::SolrService.instance.conn.expects(:query).with("is_part_of_s:info\\:fedora/test\\:sample_pid", :rows=>25).returns(mock("solr result", :hits => [Hash["id"=>"pid1"], Hash["id"=>"pid2"]]))
|
299
292
|
local_node.parts(:response_format => :id_array).should == ["pid1", "pid2"]
|
300
293
|
end
|
@@ -406,10 +399,10 @@ describe ActiveFedora::SemanticNode do
|
|
406
399
|
end
|
407
400
|
it "(:response_format => :solr) should construct a solr query that combines inbound and outbound searches" do
|
408
401
|
# get the id array for outbound relationships then construct solr query by combining id array with inbound relationship search
|
409
|
-
@local_node.expects(:
|
402
|
+
@local_node.expects(:all_parts_outbound).with(:response_format=>:id_array).returns(["mypid:1"])
|
410
403
|
id_array_query = ActiveFedora::SolrService.construct_query_for_pids(["mypid:1"])
|
411
404
|
solr_result = mock("solr result")
|
412
|
-
ActiveFedora::SolrService.instance.conn.expects(:query).with("
|
405
|
+
ActiveFedora::SolrService.instance.conn.expects(:query).with("is_part_of_s:info\\:fedora/test\\:sample_pid OR #{id_array_query}", :rows=>25).returns(solr_result)
|
413
406
|
@local_node.all_parts(:response_format=>:solr)
|
414
407
|
end
|
415
408
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 2.3.
|
9
|
+
- 3
|
10
|
+
version: 2.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Zumwalt
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-07-
|
19
|
+
date: 2011-07-19 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -444,6 +444,7 @@ files:
|
|
444
444
|
- active-fedora.gemspec
|
445
445
|
- config/fedora.yml
|
446
446
|
- config/predicate_mappings.yml
|
447
|
+
- config/solr.yml
|
447
448
|
- config/solr_mappings.yml
|
448
449
|
- config/solr_mappings_af_0.1.yml
|
449
450
|
- config/solr_mappings_bl_2.4.yml
|
@@ -466,7 +467,6 @@ files:
|
|
466
467
|
- lib/active_fedora/samples/hydra-mods_article_datastream.rb
|
467
468
|
- lib/active_fedora/samples/hydra-rights_metadata_datastream.rb
|
468
469
|
- lib/active_fedora/samples/marpa-dc_datastream.rb
|
469
|
-
- lib/active_fedora/samples/sample_af_obj_relationship_query_param.rb
|
470
470
|
- lib/active_fedora/samples/special_thing.rb
|
471
471
|
- lib/active_fedora/semantic_node.rb
|
472
472
|
- lib/active_fedora/solr_service.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class SampleAFObjRelationshipQueryParam < ActiveFedora::Base
|
2
|
-
#points to all parents linked via is_member_of
|
3
|
-
has_relationship "parents", :is_member_of
|
4
|
-
#returns only parents that have a level value set to "series"
|
5
|
-
has_relationship "series_parents", :is_member_of, :query_params=>{:q=>{"level_t"=>"series"}}
|
6
|
-
#returns all parts
|
7
|
-
has_relationship "parts", :is_part_of, :inbound=>true
|
8
|
-
#returns only parts that have level to "series"
|
9
|
-
has_relationship "series_parts", :is_part_of, :inbound=>true, :query_params=>{:q=>{"level_t"=>"series"}}
|
10
|
-
has_bidirectional_relationship "bi_series_parts", :has_part, :is_part_of, :query_params=>{:q=>{"level_t"=>"series"}}
|
11
|
-
end
|