active-fedora 3.1.0.pre8 → 3.1.0.pre9
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 +139 -0
- data/active-fedora.gemspec +1 -1
- data/lib/active_fedora/base.rb +7 -8
- data/lib/active_fedora/digital_object.rb +18 -0
- data/lib/active_fedora/metadata_datastream.rb +6 -0
- data/lib/active_fedora/metadata_datastream_helper.rb +7 -1
- data/lib/active_fedora/model.rb +0 -2
- data/lib/active_fedora/nokogiri_datastream.rb +4 -0
- data/lib/active_fedora/semantic_node.rb +10 -2
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/base_find_by_fields_spec.rb +1 -5
- data/spec/integration/mods_article_integration_spec.rb +2 -2
- data/spec/integration/semantic_node_spec.rb +23 -23
- data/spec/unit/base_spec.rb +4 -3
- data/spec/unit/metadata_datastream_spec.rb +14 -7
- data/spec/unit/semantic_node_spec.rb +11 -8
- metadata +10 -7
data/Gemfile.lock
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active-fedora (3.1.0.pre9)
|
5
|
+
activeresource (~> 3.0.0)
|
6
|
+
activesupport (~> 3.0.0)
|
7
|
+
equivalent-xml
|
8
|
+
facets
|
9
|
+
mediashelf-loggable
|
10
|
+
mime-types (>= 1.16)
|
11
|
+
multipart-post (= 1.1.2)
|
12
|
+
nokogiri
|
13
|
+
om (>= 1.4.3)
|
14
|
+
rdf
|
15
|
+
rdf-rdfxml
|
16
|
+
rubydora (~> 0.1.9)
|
17
|
+
solr-ruby (>= 0.0.6)
|
18
|
+
solrizer (> 1.0.0)
|
19
|
+
xml-simple (>= 1.0.12)
|
20
|
+
|
21
|
+
GEM
|
22
|
+
remote: http://rubygems.org/
|
23
|
+
specs:
|
24
|
+
RedCloth (4.2.8)
|
25
|
+
activemodel (3.0.10)
|
26
|
+
activesupport (= 3.0.10)
|
27
|
+
builder (~> 2.1.2)
|
28
|
+
i18n (~> 0.5.0)
|
29
|
+
activeresource (3.0.10)
|
30
|
+
activemodel (= 3.0.10)
|
31
|
+
activesupport (= 3.0.10)
|
32
|
+
activesupport (3.0.10)
|
33
|
+
addressable (2.2.6)
|
34
|
+
akami (1.0.0)
|
35
|
+
gyoku (>= 0.4.0)
|
36
|
+
builder (2.1.2)
|
37
|
+
childprocess (0.2.2)
|
38
|
+
ffi (~> 1.0.6)
|
39
|
+
columnize (0.3.4)
|
40
|
+
daemons (1.1.4)
|
41
|
+
equivalent-xml (0.2.8)
|
42
|
+
nokogiri (>= 1.4.3)
|
43
|
+
facets (2.9.2)
|
44
|
+
fastercsv (1.5.4)
|
45
|
+
ffi (1.0.10)
|
46
|
+
gyoku (0.4.4)
|
47
|
+
builder (>= 2.1.2)
|
48
|
+
httpi (0.9.5)
|
49
|
+
rack
|
50
|
+
i18n (0.5.0)
|
51
|
+
jettywrapper (1.0.1)
|
52
|
+
activesupport (>= 3.0.0)
|
53
|
+
childprocess
|
54
|
+
i18n
|
55
|
+
logger
|
56
|
+
mediashelf-loggable
|
57
|
+
linecache (0.46)
|
58
|
+
rbx-require-relative (> 0.0.4)
|
59
|
+
logger (1.2.8)
|
60
|
+
mediashelf-loggable (0.4.7)
|
61
|
+
metaclass (0.0.1)
|
62
|
+
mime-types (1.16)
|
63
|
+
mocha (0.10.0)
|
64
|
+
metaclass (~> 0.0.1)
|
65
|
+
multipart-post (1.1.2)
|
66
|
+
nokogiri (1.5.0)
|
67
|
+
nori (1.0.2)
|
68
|
+
om (1.4.3)
|
69
|
+
mediashelf-loggable
|
70
|
+
nokogiri (>= 1.4.2)
|
71
|
+
rack (1.3.5)
|
72
|
+
rake (0.9.2)
|
73
|
+
rbx-require-relative (0.0.5)
|
74
|
+
rcov (0.9.11)
|
75
|
+
rdf (0.3.4.1)
|
76
|
+
addressable (>= 2.2.6)
|
77
|
+
rdf-rdfxml (0.3.5)
|
78
|
+
nokogiri (>= 1.4.4)
|
79
|
+
rdf (>= 0.3.4)
|
80
|
+
rest-client (1.6.7)
|
81
|
+
mime-types (>= 1.16)
|
82
|
+
rsolr (1.0.2)
|
83
|
+
builder (>= 2.1.2)
|
84
|
+
rspec (1.3.2)
|
85
|
+
ruby-debug (0.10.4)
|
86
|
+
columnize (>= 0.1)
|
87
|
+
ruby-debug-base (~> 0.10.4.0)
|
88
|
+
ruby-debug-base (0.10.4)
|
89
|
+
linecache (>= 0.3)
|
90
|
+
rubydora (0.1.9)
|
91
|
+
activemodel
|
92
|
+
activesupport
|
93
|
+
fastercsv
|
94
|
+
mime-types
|
95
|
+
nokogiri
|
96
|
+
rest-client
|
97
|
+
savon
|
98
|
+
savon (0.9.7)
|
99
|
+
akami (~> 1.0)
|
100
|
+
builder (>= 2.1.2)
|
101
|
+
gyoku (>= 0.4.0)
|
102
|
+
httpi (~> 0.9)
|
103
|
+
nokogiri (>= 1.4.0)
|
104
|
+
nori (~> 1.0)
|
105
|
+
wasabi (~> 2.0)
|
106
|
+
solr-ruby (0.0.8)
|
107
|
+
solrizer (1.1.2)
|
108
|
+
daemons
|
109
|
+
mediashelf-loggable
|
110
|
+
nokogiri
|
111
|
+
om (>= 1.4.0)
|
112
|
+
stomp
|
113
|
+
xml-simple
|
114
|
+
solrizer-fedora (1.1.3)
|
115
|
+
active-fedora (>= 2.3.0)
|
116
|
+
fastercsv
|
117
|
+
rsolr
|
118
|
+
solr-ruby (>= 0.0.6)
|
119
|
+
solrizer (>= 1.0.0)
|
120
|
+
stomp (1.1.9)
|
121
|
+
wasabi (2.0.0)
|
122
|
+
nokogiri (>= 1.4.0)
|
123
|
+
xml-simple (1.1.1)
|
124
|
+
yard (0.7.3)
|
125
|
+
|
126
|
+
PLATFORMS
|
127
|
+
ruby
|
128
|
+
|
129
|
+
DEPENDENCIES
|
130
|
+
RedCloth
|
131
|
+
active-fedora!
|
132
|
+
jettywrapper (>= 1.0.1)
|
133
|
+
mocha (>= 0.9.8)
|
134
|
+
rake
|
135
|
+
rcov
|
136
|
+
rspec (< 2.0.0)
|
137
|
+
ruby-debug
|
138
|
+
solrizer-fedora (>= 1.1.3)
|
139
|
+
yard
|
data/active-fedora.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency('mime-types', '>= 1.16')
|
21
21
|
s.add_dependency('multipart-post', "= 1.1.2")
|
22
22
|
s.add_dependency('nokogiri')
|
23
|
-
s.add_dependency('om', '>= 1.
|
23
|
+
s.add_dependency('om', '>= 1.4.3')
|
24
24
|
s.add_dependency('solrizer', '>1.0.0')
|
25
25
|
s.add_dependency("activeresource", '~> 3.0.0')
|
26
26
|
s.add_dependency("activesupport", '~> 3.0.0')
|
data/lib/active_fedora/base.rb
CHANGED
@@ -49,8 +49,7 @@ module ActiveFedora
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def new_object=(bool)
|
52
|
-
|
53
|
-
#inner_object.new_object = bool
|
52
|
+
ActiveSupport::Deprecation.warn("ActiveFedora::Base.new_object= has been deprecated and nolonger has any effect")
|
54
53
|
end
|
55
54
|
|
56
55
|
## Required by associations
|
@@ -84,10 +83,9 @@ module ActiveFedora
|
|
84
83
|
else
|
85
84
|
attrs = attrs.merge!({:pid=>RubydoraConnection.instance.nextid})
|
86
85
|
end
|
87
|
-
|
86
|
+
self.relationships_loaded = true
|
88
87
|
@inner_object = DigitalObject.find(self.class, attrs[:pid])
|
89
88
|
else
|
90
|
-
@new_object = attrs[:new_object] == false ? false : true
|
91
89
|
@inner_object = DigitalObject.find(self.class, attrs[:pid])
|
92
90
|
load_datastreams_from_fedora
|
93
91
|
end
|
@@ -135,7 +133,6 @@ module ActiveFedora
|
|
135
133
|
else
|
136
134
|
result = update
|
137
135
|
end
|
138
|
-
@new_object = false
|
139
136
|
self.update_index if @metadata_is_dirty == true && ENABLE_SOLR_UPDATES
|
140
137
|
@metadata_is_dirty == false
|
141
138
|
return result
|
@@ -208,7 +205,10 @@ module ActiveFedora
|
|
208
205
|
if ds_spec.last.class == Proc
|
209
206
|
ds_spec.last.call(datastreams[dsid])
|
210
207
|
end
|
211
|
-
klass.from_xml
|
208
|
+
# if klass.respond_to? :from_xml
|
209
|
+
# ### TODO, this is loading eagerly, we could load it as needed
|
210
|
+
# klass.from_xml(datastreams[dsid].content, datastreams[dsid])
|
211
|
+
# end
|
212
212
|
end
|
213
213
|
end
|
214
214
|
end
|
@@ -508,7 +508,7 @@ module ActiveFedora
|
|
508
508
|
# has_datastream :name=>"external_images", :prefix=>"EXTIMG", :type=>ActiveFedora::Datastream,:mimeType=>"image/jpeg", :controlGroup=>'E'
|
509
509
|
#
|
510
510
|
# Returns
|
511
|
-
# {"external_images"=>[],"thumbnails"=>{#<ActiveFedora::Datastream:0x7ffd6512daf8
|
511
|
+
# {"external_images"=>[],"thumbnails"=>{#<ActiveFedora::Datastream:0x7ffd6512daf8 ...}}
|
512
512
|
def named_datastreams
|
513
513
|
ds_values = {}
|
514
514
|
self.class.named_datastreams_desc.keys.each do |name|
|
@@ -872,7 +872,6 @@ module ActiveFedora
|
|
872
872
|
create_date = solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date)].nil? ? solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date).to_s] : solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date)]
|
873
873
|
modified_date = solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date)].nil? ? solr_doc[ActiveFedora::SolrService.solr_name(:system_modified, :date).to_s] : solr_doc[ActiveFedora::SolrService.solr_name(:system_modified, :date)]
|
874
874
|
obj = self.new({:pid=>solr_doc[SOLR_DOCUMENT_ID],:create_date=>create_date,:modified_date=>modified_date})
|
875
|
-
#obj.new_object = false
|
876
875
|
#set by default to load any dependent relationship objects from solr as well
|
877
876
|
#need to call rels_ext once so it exists when iterating over datastreams
|
878
877
|
obj.rels_ext
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActiveFedora
|
2
|
+
# Helps Rubydora create datastreams of the type defined by the ActiveFedora::Base#datastream_class_for_name
|
3
|
+
class DigitalObject < Rubydora::DigitalObject
|
4
|
+
attr_accessor :original_class
|
5
|
+
|
6
|
+
def self.find(original_class, pid)
|
7
|
+
obj = super(pid, RubydoraConnection.instance.connection)
|
8
|
+
obj.original_class = original_class
|
9
|
+
obj
|
10
|
+
end
|
11
|
+
|
12
|
+
def datastream_object_for dsid
|
13
|
+
klass = original_class.datastream_class_for_name(dsid)
|
14
|
+
klass.new self, dsid
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -48,6 +48,7 @@ module ActiveFedora
|
|
48
48
|
# ds.update_attributes({:myfield=>{"0"=>"a","1"=>"b"},:myotherfield=>{"-1"=>"c"}})
|
49
49
|
#
|
50
50
|
def update_indexed_attributes(params={}, opts={})
|
51
|
+
ensure_xml_loaded
|
51
52
|
|
52
53
|
##FIX this bug, it should delete it from a copy of params in case passed to another datastream for update since this will modify params
|
53
54
|
##for subsequent calls if updating more than one datastream in a single update_indexed_attributes call
|
@@ -105,6 +106,7 @@ module ActiveFedora
|
|
105
106
|
|
106
107
|
|
107
108
|
def get_values(field_name, default=[])
|
109
|
+
ensure_xml_loaded
|
108
110
|
field_accessor_method = "#{field_name}_values"
|
109
111
|
if respond_to? field_accessor_method
|
110
112
|
values = self.send(field_accessor_method)
|
@@ -123,6 +125,7 @@ module ActiveFedora
|
|
123
125
|
end
|
124
126
|
|
125
127
|
def set_value(field_name, values)
|
128
|
+
ensure_xml_loaded
|
126
129
|
field_accessor_method = "#{field_name}_values="
|
127
130
|
if respond_to? field_accessor_method
|
128
131
|
values = self.send(field_accessor_method, values)
|
@@ -173,13 +176,16 @@ module ActiveFedora
|
|
173
176
|
@fields[name.to_s.to_sym]={:type=>tupe, :values=>[]}.merge(opts)
|
174
177
|
eval <<-EOS
|
175
178
|
def #{name}_values=(arg)
|
179
|
+
ensure_xml_loaded
|
176
180
|
@fields["#{name.to_s}".to_sym][:values]=[arg].flatten
|
177
181
|
self.dirty=true
|
178
182
|
end
|
179
183
|
def #{name}_values
|
184
|
+
ensure_xml_loaded
|
180
185
|
@fields["#{name}".to_sym][:values]
|
181
186
|
end
|
182
187
|
def #{name}_append(arg)
|
188
|
+
ensure_xml_loaded
|
183
189
|
@fields["#{name}".to_sym][:values] << arg
|
184
190
|
self.dirty =true
|
185
191
|
end
|
@@ -3,7 +3,7 @@ require 'solrizer/field_name_mapper'
|
|
3
3
|
#this class represents a MetadataDatastream, a special case of ActiveFedora::Datastream
|
4
4
|
module ActiveFedora::MetadataDatastreamHelper
|
5
5
|
|
6
|
-
attr_accessor :fields
|
6
|
+
attr_accessor :fields, :xml_loaded
|
7
7
|
|
8
8
|
module ClassMethods
|
9
9
|
|
@@ -20,6 +20,12 @@ module ActiveFedora::MetadataDatastreamHelper
|
|
20
20
|
klass.extend(ClassMethods)
|
21
21
|
klass.send(:include, Solrizer::FieldNameMapper)
|
22
22
|
end
|
23
|
+
|
24
|
+
def ensure_xml_loaded
|
25
|
+
return if xml_loaded
|
26
|
+
self.xml_loaded = true
|
27
|
+
self.class.from_xml content, self
|
28
|
+
end
|
23
29
|
|
24
30
|
def serialize! # :nodoc:
|
25
31
|
self.content = self.to_xml ##TODO only do this when the xml will have changed to avoid a load of the datastream content.
|
data/lib/active_fedora/model.rb
CHANGED
@@ -23,6 +23,7 @@ module ActiveFedora
|
|
23
23
|
self.class.from_xml(nil, self)
|
24
24
|
end
|
25
25
|
|
26
|
+
|
26
27
|
|
27
28
|
# Create an instance of this class based on xml content
|
28
29
|
# @param [String, File, Nokogiri::XML::Node] xml the xml content to build from
|
@@ -296,6 +297,7 @@ module ActiveFedora
|
|
296
297
|
if self.class.terminology.nil?
|
297
298
|
raise "No terminology is set for this NokogiriDatastream class. Cannot perform update_indexed_attributes"
|
298
299
|
end
|
300
|
+
ensure_xml_loaded
|
299
301
|
# remove any fields from params that this datastream doesn't recognize
|
300
302
|
# make sure to make a copy of params so not to modify hash that might be passed to other methods
|
301
303
|
current_params = params.clone
|
@@ -317,6 +319,7 @@ module ActiveFedora
|
|
317
319
|
end
|
318
320
|
|
319
321
|
def get_values(field_key,default=[])
|
322
|
+
ensure_xml_loaded
|
320
323
|
term_values(*field_key)
|
321
324
|
end
|
322
325
|
|
@@ -342,6 +345,7 @@ module ActiveFedora
|
|
342
345
|
#lazy load values from solr on demand
|
343
346
|
get_values_from_solr(*term_pointer)
|
344
347
|
else
|
348
|
+
ensure_xml_loaded
|
345
349
|
om_term_values(*term_pointer)
|
346
350
|
end
|
347
351
|
end
|
@@ -8,7 +8,7 @@ module ActiveFedora
|
|
8
8
|
self.class_relationships = {}
|
9
9
|
self.class_named_relationships_desc = {}
|
10
10
|
end
|
11
|
-
attr_accessor :named_relationship_desc, :relationships_are_dirty, :load_from_solr, :subject #:internal_uri
|
11
|
+
attr_accessor :named_relationship_desc, :relationships_are_dirty, :relationships_loaded, :load_from_solr, :subject #:internal_uri
|
12
12
|
|
13
13
|
#TODO I think we can remove named_relationship_desc from attr_accessor - jcoyne
|
14
14
|
|
@@ -147,9 +147,17 @@ module ActiveFedora
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def relationships
|
150
|
-
# @relationships ||= {:self=>{}}
|
151
150
|
@subject ||= RDF::URI.new(internal_uri)
|
152
151
|
@relationships ||= RDF::Graph.new
|
152
|
+
load_relationships if !relationships_loaded
|
153
|
+
@relationships
|
154
|
+
end
|
155
|
+
|
156
|
+
def load_relationships
|
157
|
+
self.relationships_loaded = true
|
158
|
+
content = rels_ext.content
|
159
|
+
return unless content.present?
|
160
|
+
RelsExtDatastream.from_xml content, rels_ext
|
153
161
|
end
|
154
162
|
|
155
163
|
def relationships_from_class
|
@@ -19,7 +19,6 @@ describe ActiveFedora::Base do
|
|
19
19
|
|
20
20
|
before(:each) do
|
21
21
|
@test_object = ActiveFedora::Base.new
|
22
|
-
@test_object.new_object = true
|
23
22
|
end
|
24
23
|
|
25
24
|
after(:each) do
|
@@ -49,7 +48,6 @@ describe ActiveFedora::Base do
|
|
49
48
|
it 'should return fedora objects of the model of self that match the given solr query, queries the active_fedora solr instance' do
|
50
49
|
#get objects into fedora and solr
|
51
50
|
@test_object2 = MockAFBaseQuerySolr.new
|
52
|
-
@test_object2.new_object = true
|
53
51
|
attributes = {"holding_id"=>{0=>"Holding 1"},
|
54
52
|
"language"=>{0=>"Italian"},
|
55
53
|
"creator"=>{0=>"Linguist, A."},
|
@@ -59,7 +57,6 @@ describe ActiveFedora::Base do
|
|
59
57
|
@test_object2.save
|
60
58
|
|
61
59
|
@test_object3 = MockAFBaseQuerySolr.new
|
62
|
-
@test_object3.new_object = true
|
63
60
|
attributes = {"holding_id"=>{0=>"Holding 2"},
|
64
61
|
"language"=>{0=>"Spanish;Latin"},
|
65
62
|
"creator"=>{0=>"Linguist, A."},
|
@@ -69,7 +66,6 @@ describe ActiveFedora::Base do
|
|
69
66
|
@test_object3.save
|
70
67
|
|
71
68
|
@test_object4 = MockAFBaseQuerySolr.new
|
72
|
-
@test_object4.new_object = true
|
73
69
|
attributes = {"holding_id"=>{0=>"Holding 3"},
|
74
70
|
"language"=>{0=>"Spanish;Latin"},
|
75
71
|
"creator"=>{0=>"Linguist, A."},
|
@@ -212,4 +208,4 @@ describe ActiveFedora::Base do
|
|
212
208
|
found_pids.should == [@test_object2.pid]
|
213
209
|
end
|
214
210
|
end
|
215
|
-
end
|
211
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
-
# require File.join( File.dirname(__FILE__), "..", "samples", "models", "mods_article" )
|
3
2
|
require "active_fedora/samples"
|
3
|
+
|
4
4
|
describe ActiveFedora::Base do
|
5
5
|
|
6
6
|
before(:all) do
|
@@ -42,4 +42,4 @@ describe ActiveFedora::Base do
|
|
42
42
|
retrieved_article.get_values_from_datastream("descMetadata", [{:person=>0}, :first_name]).should == ["Replacement FirstName"]
|
43
43
|
end
|
44
44
|
end
|
45
|
-
end
|
45
|
+
end
|
@@ -5,17 +5,17 @@ require 'active_fedora'
|
|
5
5
|
describe ActiveFedora::SemanticNode do
|
6
6
|
|
7
7
|
before(:all) do
|
8
|
-
class
|
9
|
-
include ActiveFedora::RelationshipsHelper
|
10
|
-
include ActiveFedora::SemanticNode
|
11
|
-
has_relationship "collection_members", :has_collection_member
|
12
|
-
attr_accessor :rels_ext
|
13
|
-
def initialize
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
@node =
|
8
|
+
class SNSpecNode < ActiveFedora::Base
|
9
|
+
# include ActiveFedora::RelationshipsHelper
|
10
|
+
# include ActiveFedora::SemanticNode
|
11
|
+
# has_relationship "collection_members", :has_collection_member
|
12
|
+
# attr_accessor :rels_ext
|
13
|
+
# def initialize
|
14
|
+
# self.rels_ext = ActiveFedora::RelsExtDatastream.new(nil, nil)
|
15
|
+
# rels_ext.model = self
|
16
|
+
# end
|
17
|
+
end
|
18
|
+
@node = SNSpecNode.new
|
19
19
|
class SNSpecModel < ActiveFedora::Base
|
20
20
|
has_relationship("parts", :is_part_of, :inbound => true)
|
21
21
|
has_relationship("containers", :is_member_of)
|
@@ -148,7 +148,7 @@ describe ActiveFedora::SemanticNode do
|
|
148
148
|
|
149
149
|
describe '#has_relationship' do
|
150
150
|
it "should create useable finders" do
|
151
|
-
spec_node =
|
151
|
+
spec_node = SNSpecNode.new
|
152
152
|
spec_node.collection_members.should == []
|
153
153
|
rel = ActiveFedora::Relationship.new(:subject => :self, :predicate => :has_collection_member, :object => @test_object.pid)
|
154
154
|
|
@@ -434,17 +434,17 @@ describe ActiveFedora::SemanticNode do
|
|
434
434
|
|
435
435
|
#putting this test here instead of relationships_helper because testing that relationships_by_name hash gets refreshed if the relationships hash is changed
|
436
436
|
describe "relationships_by_name" do
|
437
|
-
class MockSemNamedRelationships
|
438
|
-
include ActiveFedora::RelationshipsHelper
|
439
|
-
include ActiveFedora::SemanticNode
|
437
|
+
class MockSemNamedRelationships < ActiveFedora::Base
|
438
|
+
# include ActiveFedora::RelationshipsHelper
|
439
|
+
# include ActiveFedora::SemanticNode
|
440
440
|
has_relationship "testing", :has_part
|
441
441
|
has_relationship "testing2", :has_member
|
442
442
|
has_relationship "testing_inbound", :has_part, :inbound=>true
|
443
|
-
attr_accessor :rels_ext
|
444
|
-
def initialize
|
445
|
-
|
446
|
-
|
447
|
-
end
|
443
|
+
# attr_accessor :rels_ext
|
444
|
+
# def initialize
|
445
|
+
# self.rels_ext = ActiveFedora::RelsExtDatastream.new(nil, nil)
|
446
|
+
# rels_ext.model = self
|
447
|
+
# end
|
448
448
|
end
|
449
449
|
|
450
450
|
it 'should automatically update the relationships_by_name if relationships has changed (no refresh of relationships_by_name hash unless relationships hash has changed' do
|
@@ -452,13 +452,13 @@ describe ActiveFedora::SemanticNode do
|
|
452
452
|
r = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_model,:object=>ActiveFedora::ContentModel.pid_from_ruby_class(MockSemNamedRelationships)})
|
453
453
|
@test_object2.add_relationship(r.predicate, r.object)
|
454
454
|
#should return expected named relationships
|
455
|
-
@test_object2.relationships_by_name.should == {:self=>{"testing"=>[],"testing2"=>[]}}
|
455
|
+
@test_object2.relationships_by_name.should == {:self=>{"testing"=>[],"testing2"=>[], "collection_members"=>[], "part_of"=>[], "parts_outbound"=>[]}}
|
456
456
|
r3 = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_part,:object=>@test_object})
|
457
457
|
@test_object2.add_relationship(r3.predicate, r3.object)
|
458
|
-
@test_object2.relationships_by_name.should == {:self=>{"testing"=>[r3.object],"testing2"=>[]}}
|
458
|
+
@test_object2.relationships_by_name.should == {:self=>{"testing"=>[r3.object],"testing2"=>[], "collection_members"=>[], "part_of"=>[], "parts_outbound"=>[r3.object]}}
|
459
459
|
r4 = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_member,:object=>"3"})
|
460
460
|
@test_object2.add_relationship(r4.predicate, r4.object)
|
461
|
-
@test_object2.relationships_by_name.should == {:self=>{"testing"=>[r3.object],"testing2"=>[r4.object]}}
|
461
|
+
@test_object2.relationships_by_name.should == {:self=>{"testing"=>[r3.object],"testing2"=>[r4.object], "collection_members"=>[], "part_of"=>[], "parts_outbound"=>[r3.object]}}
|
462
462
|
end
|
463
463
|
end
|
464
464
|
end
|
data/spec/unit/base_spec.rb
CHANGED
@@ -30,6 +30,7 @@ describe ActiveFedora::Base do
|
|
30
30
|
@mock_repo = mock("repository")
|
31
31
|
ActiveFedora::DigitalObject.any_instance.expects(:repository).returns(@mock_repo).at_least_once
|
32
32
|
@this_pid = increment_pid.to_s
|
33
|
+
@mock_repo.stubs(:datastream_dissemination)
|
33
34
|
ActiveFedora::RubydoraConnection.instance.stubs(:nextid).returns(@this_pid)
|
34
35
|
|
35
36
|
@mock_repo.expects(:datastream).with{ |x| x[:dsid] == 'RELS-EXT'}.returns("").at_least_once #raises(RuntimeError, "Fake Not found")
|
@@ -118,6 +119,7 @@ describe ActiveFedora::Base do
|
|
118
119
|
@mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'withText'}
|
119
120
|
@mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'withText2'}
|
120
121
|
@mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'RELS-EXT'}
|
122
|
+
@mock_repo.expects(:datastream_dissemination).with(:pid => 'monkey:99', :dsid => 'RELS-EXT')
|
121
123
|
|
122
124
|
@n = FooHistory.new(:pid=>"monkey:99")
|
123
125
|
@n.expects(:update_index)
|
@@ -198,10 +200,10 @@ describe ActiveFedora::Base do
|
|
198
200
|
|
199
201
|
describe '#add_relationship' do
|
200
202
|
it 'should call #add_relationship on the rels_ext datastream' do
|
201
|
-
mock_rels_ext = mock("rels-ext")
|
203
|
+
mock_rels_ext = mock("rels-ext")
|
202
204
|
mock_rels_ext.expects(:dirty=).with(true)
|
203
205
|
@test_object.expects(:relationship_exists?).returns(false).once()
|
204
|
-
@test_object.expects(:rels_ext).returns(mock_rels_ext)
|
206
|
+
@test_object.expects(:rels_ext).returns(mock_rels_ext).at_least_once
|
205
207
|
@test_object.add_relationship("predicate", "object")
|
206
208
|
end
|
207
209
|
|
@@ -392,7 +394,6 @@ describe ActiveFedora::Base do
|
|
392
394
|
@test_object.save
|
393
395
|
end
|
394
396
|
it "should update solr index if relationships have changed" do
|
395
|
-
@mock_repo = mock('repository')
|
396
397
|
@mock_repo.expects(:ingest).with(:pid => @test_object.pid)
|
397
398
|
@test_object.inner_object.expects(:repository).returns(@mock_repo).at_least_once
|
398
399
|
@test_object.inner_object.expects(:new?).returns(true).twice
|
@@ -226,7 +226,8 @@ describe ActiveFedora::MetadataDatastream do
|
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should insert custom element attrs into the xml stream" do
|
229
|
-
sds = SpecDatastream.new(
|
229
|
+
sds = SpecDatastream.new(@test_object.inner_object, nil)
|
230
|
+
sds.stubs(:content=>'')
|
230
231
|
sds.mycomplicated_field_values='foo'
|
231
232
|
sds.fields[:mycomplicated_field][:element_attrs].should == {:foo=>:bar, :baz=>:bat}
|
232
233
|
expected_xml = '<fields><mycomplicated_field baz=\'bat\' foo=\'bar\'>foo</mycomplicated_field></fields>'
|
@@ -234,7 +235,8 @@ describe ActiveFedora::MetadataDatastream do
|
|
234
235
|
end
|
235
236
|
|
236
237
|
it "should add getters and setters and appenders with field name" do
|
237
|
-
local_test_ds = SpecDatastream.new(
|
238
|
+
local_test_ds = SpecDatastream.new(@test_object.inner_object, nil)
|
239
|
+
local_test_ds.stubs(:content=>'')
|
238
240
|
local_test_ds.should respond_to(:publisher_values)
|
239
241
|
local_test_ds.should respond_to(:publisher_append)
|
240
242
|
local_test_ds.should respond_to(:publisher_values=)
|
@@ -251,8 +253,10 @@ describe ActiveFedora::MetadataDatastream do
|
|
251
253
|
end
|
252
254
|
|
253
255
|
it "should track field values at instance level, not at class level" do
|
254
|
-
local_test_ds1 = SpecDatastream.new(
|
255
|
-
|
256
|
+
local_test_ds1 = SpecDatastream.new(@test_object.inner_object, nil)
|
257
|
+
local_test_ds1.stubs(:content=>'')
|
258
|
+
local_test_ds2 = SpecDatastream.new(@test_object.inner_object, nil)
|
259
|
+
local_test_ds2.stubs(:content=>'')
|
256
260
|
local_test_ds1.publisher_values = ["publisher1", "publisher2"]
|
257
261
|
local_test_ds2.publisher_values = ["publisherA", "publisherB"]
|
258
262
|
|
@@ -261,19 +265,22 @@ describe ActiveFedora::MetadataDatastream do
|
|
261
265
|
end
|
262
266
|
|
263
267
|
it "should allow you to add field values using <<" do
|
264
|
-
local_test_ds1 = SpecDatastream.new(
|
268
|
+
local_test_ds1 = SpecDatastream.new(@test_object.inner_object, nil)
|
269
|
+
local_test_ds1.stubs(:content=>'')
|
265
270
|
local_test_ds1.publisher_values << "publisher1"
|
266
271
|
local_test_ds1.publisher_values.should == ["publisher1"]
|
267
272
|
end
|
268
273
|
|
269
274
|
it "should create setter that always turns non-arrays into arrays" do
|
270
|
-
local_test_ds = SpecDatastream.new(
|
275
|
+
local_test_ds = SpecDatastream.new(@test_object.inner_object, nil)
|
276
|
+
local_test_ds.stubs(:content=>'')
|
271
277
|
local_test_ds.publisher_values = "Foo"
|
272
278
|
local_test_ds.publisher_values.should == ["Foo"]
|
273
279
|
end
|
274
280
|
|
275
281
|
it "should create setter that sets datastream.dirty? to true" do
|
276
|
-
local_test_ds = SpecDatastream.new(
|
282
|
+
local_test_ds = SpecDatastream.new(@test_object.inner_object, nil)
|
283
|
+
local_test_ds.stubs(:content=>'')
|
277
284
|
local_test_ds.should_not be_dirty
|
278
285
|
local_test_ds.publisher_values = "Foo"
|
279
286
|
local_test_ds.should be_dirty
|
@@ -44,9 +44,11 @@ describe ActiveFedora::SemanticNode do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
@node = SpecNode.new
|
47
|
+
@node.stubs(:rels_ext).returns(stub("rels_ext", :dirty= => true, :content=>''))
|
47
48
|
@node.pid = increment_pid
|
48
49
|
@test_object = SpecNode2.new
|
49
50
|
@test_object.pid = increment_pid
|
51
|
+
@test_object.stubs(:rels_ext).returns(stub("rels_ext", :dirty= => true, :content=>''))
|
50
52
|
@stub_relationship = stub("mock_relationship", :subject => @pid, :predicate => "isMemberOf", :object => "demo:8", :class => ActiveFedora::Relationship)
|
51
53
|
@test_relationship = ActiveFedora::Relationship.new(:subject => @pid, :predicate => "isMemberOf", :object => "demo:9")
|
52
54
|
@test_relationship1 = ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "demo:10")
|
@@ -183,7 +185,7 @@ describe ActiveFedora::SemanticNode do
|
|
183
185
|
|
184
186
|
# local_node.add_relationship(ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "info:fedora/container:A") )
|
185
187
|
# local_node.add_relationship(ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "info:fedora/container:B") )
|
186
|
-
local_node.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true)).
|
188
|
+
local_node.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true, :content=>'')).at_least_once
|
187
189
|
local_node.add_relationship(:is_member_of, "info:fedora/container:A")
|
188
190
|
local_node.add_relationship(:is_member_of, "info:fedora/container:B")
|
189
191
|
|
@@ -231,7 +233,7 @@ describe ActiveFedora::SemanticNode do
|
|
231
233
|
@test_object2 = MockHasRelationship.new
|
232
234
|
@test_object2.pid = increment_pid
|
233
235
|
@test_object2.stubs(:testing_inbound).returns({})
|
234
|
-
@test_object2.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true))
|
236
|
+
@test_object2.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true, :content =>'')).at_least_once
|
235
237
|
@test_object2.add_relationship(:has_model, ActiveFedora::ContentModel.pid_from_ruby_class(SpecNode2))
|
236
238
|
@test_object2.should respond_to(:testing_append)
|
237
239
|
@test_object2.should respond_to(:testing_remove)
|
@@ -366,6 +368,7 @@ describe ActiveFedora::SemanticNode do
|
|
366
368
|
mock_repo = mock("repo")
|
367
369
|
mock_repo.expects(:find_model).never
|
368
370
|
local_node.stubs(:internal_uri)
|
371
|
+
local_node.expects(:rels_ext).returns(stub('rels-ext', :content=>''))
|
369
372
|
ActiveFedora::SolrService.instance.conn.expects(:query).returns(solr_result)
|
370
373
|
local_node.constituents(:response_format => :solr).should equal(solr_result)
|
371
374
|
end
|
@@ -380,7 +383,7 @@ describe ActiveFedora::SemanticNode do
|
|
380
383
|
it "(:response_format => :id_array) should return an array of fedora PIDs" do
|
381
384
|
SpecNode.create_outbound_relationship_finders("containers", :is_member_of)
|
382
385
|
local_node = SpecNode.new
|
383
|
-
local_node.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true))
|
386
|
+
local_node.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true, :content=>'')).at_least_once
|
384
387
|
local_node.add_relationship(@test_relationship1.predicate, @test_relationship1.object)
|
385
388
|
result = local_node.containers_ids
|
386
389
|
result.should be_instance_of(Array)
|
@@ -475,9 +478,9 @@ describe ActiveFedora::SemanticNode do
|
|
475
478
|
@local_node2 = SpecNode.new
|
476
479
|
@local_node2.pid = "mypid2"
|
477
480
|
r = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_model,:object=>ActiveFedora::ContentModel.pid_from_ruby_class(SpecNode)})
|
478
|
-
@local_node.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true)).
|
481
|
+
@local_node.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true, :content=>'')).at_least_once
|
479
482
|
@local_node.add_relationship(r.predicate, r.object)
|
480
|
-
@local_node2.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true)).
|
483
|
+
@local_node2.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true, :content=>'')).at_least_once
|
481
484
|
@local_node2.add_relationship(r.predicate, r.object)
|
482
485
|
r2 = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_part,:object=>@local_node2})
|
483
486
|
@local_node.add_relationship(r2.predicate, r2.object)
|
@@ -494,7 +497,6 @@ describe ActiveFedora::SemanticNode do
|
|
494
497
|
|
495
498
|
describe ".add_relationship" do
|
496
499
|
it "should add relationship to the relationships hash" do
|
497
|
-
@node.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true))
|
498
500
|
@node.add_relationship(@test_relationship.predicate, @test_relationship.object)
|
499
501
|
@node.ids_for_outbound("isMemberOf").should == ['demo:9']
|
500
502
|
end
|
@@ -502,8 +504,9 @@ describe ActiveFedora::SemanticNode do
|
|
502
504
|
it "adding relationship to an instance should not affect class-level relationships hash" do
|
503
505
|
local_test_node1 = SpecNode.new
|
504
506
|
local_test_node2 = SpecNode.new
|
505
|
-
local_test_node1.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true))
|
507
|
+
local_test_node1.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true, :content=>'')).at_least_once
|
506
508
|
local_test_node1.add_relationship(@test_relationship1.predicate, @test_relationship1.object)
|
509
|
+
local_test_node2.expects(:rels_ext).returns(stub('rels-ext', :content=>''))
|
507
510
|
|
508
511
|
local_test_node1.ids_for_outbound(:is_member_of).should == ["demo:10"]
|
509
512
|
local_test_node2.ids_for_outbound(:is_member_of).should == []
|
@@ -557,7 +560,7 @@ describe ActiveFedora::SemanticNode do
|
|
557
560
|
it 'should remove a relationship from the relationships hash' do
|
558
561
|
r = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_part,:object=>"info:fedora/3"})
|
559
562
|
r2 = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_part,:object=>"info:fedora/4"})
|
560
|
-
@test_object.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true)).times(
|
563
|
+
@test_object.expects(:rels_ext).returns(stub("rels_ext", :dirty= => true, :content=>'')).times(6)
|
561
564
|
@test_object.add_relationship(r.predicate, r.object)
|
562
565
|
@test_object.add_relationship(r2.predicate, r2.object)
|
563
566
|
#check both are there
|
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: 1923832011
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
9
|
- 0
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 3.1.0.
|
11
|
+
- 9
|
12
|
+
version: 3.1.0.pre9
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Matt Zumwalt
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-10-
|
21
|
+
date: 2011-10-20 00:00:00 -05:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -106,11 +106,12 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
hash:
|
109
|
+
hash: 1
|
110
110
|
segments:
|
111
111
|
- 1
|
112
|
-
-
|
113
|
-
|
112
|
+
- 4
|
113
|
+
- 3
|
114
|
+
version: 1.4.3
|
114
115
|
type: :runtime
|
115
116
|
version_requirements: *id006
|
116
117
|
- !ruby/object:Gem::Dependency
|
@@ -548,6 +549,7 @@ files:
|
|
548
549
|
- COPYING.txt
|
549
550
|
- COYING.LESSER.txt
|
550
551
|
- Gemfile
|
552
|
+
- Gemfile.lock
|
551
553
|
- History.txt
|
552
554
|
- LICENSE
|
553
555
|
- License.txt
|
@@ -577,6 +579,7 @@ files:
|
|
577
579
|
- lib/active_fedora/datastream.rb
|
578
580
|
- lib/active_fedora/datastream_hash.rb
|
579
581
|
- lib/active_fedora/delegating.rb
|
582
|
+
- lib/active_fedora/digital_object.rb
|
580
583
|
- lib/active_fedora/fedora_object.rb
|
581
584
|
- lib/active_fedora/fixture_loader.rb
|
582
585
|
- lib/active_fedora/metadata_datastream.rb
|