active-fedora 5.1.0 → 5.2.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.
- data/active-fedora.gemspec +1 -2
- data/lib/active_fedora/datastreams.rb +14 -14
- data/lib/active_fedora/file_management.rb +5 -3
- data/lib/active_fedora/metadata_datastream_helper.rb +5 -1
- data/lib/active_fedora/nokogiri_datastream.rb +17 -4
- data/lib/active_fedora/rdf_datastream.rb +59 -36
- data/lib/active_fedora/relationships.rb +28 -11
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +3 -3
- data/spec/integration/base_spec.rb +15 -3
- data/spec/integration/bug_spec.rb +0 -3
- data/spec/integration/datastream_collections_spec.rb +9 -9
- data/spec/integration/datastream_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +3 -4
- data/spec/integration/ntriples_datastream_spec.rb +0 -1
- data/spec/integration/rels_ext_datastream_spec.rb +12 -1
- data/spec/integration/semantic_node_spec.rb +10 -0
- data/spec/integration/solr_service_spec.rb +2 -2
- data/spec/spec_helper.rb +4 -7
- data/spec/support/mock_fedora.rb +10 -10
- data/spec/unit/active_fedora_spec.rb +8 -8
- data/spec/unit/association_proxy_spec.rb +2 -1
- data/spec/unit/base_cma_spec.rb +2 -2
- data/spec/unit/base_datastream_management_spec.rb +9 -9
- data/spec/unit/base_extra_spec.rb +25 -25
- data/spec/unit/base_file_management_spec.rb +32 -23
- data/spec/unit/base_spec.rb +94 -151
- data/spec/unit/callback_spec.rb +16 -11
- data/spec/unit/code_configurator_spec.rb +4 -4
- data/spec/unit/content_model_spec.rb +8 -8
- data/spec/unit/datastream_collections_spec.rb +23 -23
- data/spec/unit/datastream_spec.rb +7 -7
- data/spec/unit/datastreams_spec.rb +189 -304
- data/spec/unit/file_configurator_spec.rb +56 -56
- data/spec/unit/has_many_collection_spec.rb +1 -1
- data/spec/unit/model_spec.rb +51 -56
- data/spec/unit/nokogiri_datastream_spec.rb +24 -25
- data/spec/unit/ntriples_datastream_spec.rb +18 -27
- data/spec/unit/property_spec.rb +0 -2
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -2
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +1 -1
- data/spec/unit/relationship_graph_spec.rb +1 -1
- data/spec/unit/relationships_spec.rb +64 -52
- data/spec/unit/rels_ext_datastream_spec.rb +7 -7
- data/spec/unit/semantic_node_spec.rb +5 -5
- data/spec/unit/service_definitions_spec.rb +18 -16
- data/spec/unit/solr_config_options_spec.rb +6 -6
- data/spec/unit/solr_service_spec.rb +16 -16
- metadata +5 -21
data/active-fedora.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_dependency("activesupport", '>= 3.0.0')
|
23
23
|
s.add_dependency("builder", '~> 3.0.0')
|
24
24
|
s.add_dependency("mediashelf-loggable")
|
25
|
-
s.add_dependency("rubydora", '~>
|
25
|
+
s.add_dependency("rubydora", '~>1.0')
|
26
26
|
s.add_dependency("rdf")
|
27
27
|
s.add_dependency("rdf-rdfxml", '~>0.3.8')
|
28
28
|
s.add_dependency("deprecation")
|
@@ -32,7 +32,6 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.add_development_dependency("jettywrapper", ">=1.2.0")
|
33
33
|
s.add_development_dependency("rspec", ">= 2.9.0")
|
34
34
|
s.add_development_dependency("equivalent-xml")
|
35
|
-
s.add_development_dependency("mocha", "0.10.5")
|
36
35
|
|
37
36
|
s.files = `git ls-files`.split("\n")
|
38
37
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module ActiveFedora
|
2
2
|
module Datastreams
|
3
3
|
extend ActiveSupport::Concern
|
4
|
+
extend Deprecation
|
4
5
|
|
5
6
|
included do
|
6
7
|
class_attribute :ds_specs
|
@@ -19,13 +20,17 @@ module ActiveFedora
|
|
19
20
|
before_save :serialize_datastreams
|
20
21
|
end
|
21
22
|
|
23
|
+
def ds_specs
|
24
|
+
self.class.ds_specs
|
25
|
+
end
|
26
|
+
|
22
27
|
def serialize_datastreams
|
23
28
|
datastreams.each {|k, ds| ds.serialize! }
|
24
29
|
end
|
25
30
|
|
26
31
|
# Adds the disseminator location to the datastream after the pid has been established
|
27
32
|
def add_disseminator_location_to_datastreams
|
28
|
-
self.
|
33
|
+
self.ds_specs.each do |name,ds_config|
|
29
34
|
ds = datastreams[name]
|
30
35
|
if ds && ds.controlGroup == 'E' && ds_config[:disseminator].present?
|
31
36
|
ds.dsLocation= "#{ActiveFedora.config_for_environment[:url]}/objects/#{pid}/methods/#{ds_config[:disseminator]}"
|
@@ -57,7 +62,7 @@ module ActiveFedora
|
|
57
62
|
end
|
58
63
|
|
59
64
|
def configure_datastream(ds, ds_spec=nil)
|
60
|
-
ds_spec ||= self.
|
65
|
+
ds_spec ||= self.ds_specs[ds.dsid]
|
61
66
|
if ds_spec
|
62
67
|
ds.model = self if ds_spec[:type] == RelsExtDatastream
|
63
68
|
# If you called has_metadata with a block, pass the block into the Datastream class
|
@@ -72,13 +77,13 @@ module ActiveFedora
|
|
72
77
|
end
|
73
78
|
|
74
79
|
def load_datastreams
|
75
|
-
|
80
|
+
local_ds_specs = self.ds_specs.dup
|
76
81
|
inner_object.datastreams.each do |dsid, ds|
|
77
82
|
self.add_datastream(ds)
|
78
83
|
configure_datastream(datastreams[dsid])
|
79
|
-
|
84
|
+
local_ds_specs.delete(dsid)
|
80
85
|
end
|
81
|
-
|
86
|
+
local_ds_specs.each do |name,ds_spec|
|
82
87
|
ds = datastream_from_spec(ds_spec, name)
|
83
88
|
self.add_datastream(ds)
|
84
89
|
configure_datastream(ds, ds_spec)
|
@@ -100,13 +105,7 @@ module ActiveFedora
|
|
100
105
|
|
101
106
|
#return all datastreams of type ActiveFedora::RDFDatastream or ActiveFedora::NokogiriDatastream
|
102
107
|
def metadata_streams
|
103
|
-
|
104
|
-
datastreams.each_value do |ds|
|
105
|
-
if ds.metadata? && !ds.kind_of?(ActiveFedora::RelsExtDatastream)
|
106
|
-
results << ds
|
107
|
-
end
|
108
|
-
end
|
109
|
-
return results
|
108
|
+
datastreams.select { |k, ds| ds.metadata? }.reject { |k, ds| ds.kind_of?(ActiveFedora::RelsExtDatastream) }.values
|
110
109
|
end
|
111
110
|
|
112
111
|
# return a valid dsid that is not currently in use. Uses a prefix (default "DS") and an auto-incrementing integer
|
@@ -167,9 +166,9 @@ module ActiveFedora
|
|
167
166
|
|
168
167
|
|
169
168
|
def create_datastream(type, dsid, opts={})
|
170
|
-
dsid
|
169
|
+
dsid ||= generate_dsid(opts[:prefix] || "DS")
|
171
170
|
klass = type.kind_of?(Class) ? type : type.constantize
|
172
|
-
raise ArgumentError, "Argument dsid must be of type string" unless dsid.kind_of?(String)
|
171
|
+
raise ArgumentError, "Argument dsid must be of type string" unless dsid.kind_of?(String)
|
173
172
|
ds = klass.new(inner_object, dsid)
|
174
173
|
[:mimeType, :controlGroup, :dsLabel, :dsLocation, :checksumType, :versionable].each do |key|
|
175
174
|
ds.send("#{key}=".to_sym, opts[key]) unless opts[key].nil?
|
@@ -202,6 +201,7 @@ module ActiveFedora
|
|
202
201
|
ds.dsLocation= ds_config[:url]
|
203
202
|
end
|
204
203
|
end
|
204
|
+
deprecation_deprecate :additional_attributes_for_external_and_redirect_control_groups
|
205
205
|
|
206
206
|
|
207
207
|
module ClassMethods
|
@@ -6,9 +6,11 @@ module ActiveFedora
|
|
6
6
|
|
7
7
|
included do
|
8
8
|
include ActiveFedora::Relationships
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Deprecation.silence(ActiveFedora::Relationships::ClassMethods) do
|
10
|
+
has_relationship "collection_members", :has_collection_member
|
11
|
+
has_relationship "part_of", :is_part_of
|
12
|
+
has_bidirectional_relationship "parts", :has_part, :is_part_of
|
13
|
+
end
|
12
14
|
end
|
13
15
|
|
14
16
|
# List the objects that assert isPartOf pointing at this object _plus_ all objects that this object asserts hasPart for
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'solrizer/field_name_mapper'
|
2
2
|
|
3
3
|
module ActiveFedora::MetadataDatastreamHelper
|
4
|
-
|
4
|
+
extend Deprecation
|
5
|
+
self.deprecation_horizon = 'active-fedora 6.0'
|
6
|
+
|
5
7
|
attr_accessor :fields, :xml_loaded
|
6
8
|
|
7
9
|
module ClassMethods
|
@@ -28,6 +30,7 @@ module ActiveFedora::MetadataDatastreamHelper
|
|
28
30
|
self.class.from_xml content, self
|
29
31
|
end
|
30
32
|
end
|
33
|
+
deprecation_deprecate :ensure_xml_loaded
|
31
34
|
|
32
35
|
def serialize! # :nodoc:
|
33
36
|
if changed?
|
@@ -35,5 +38,6 @@ module ActiveFedora::MetadataDatastreamHelper
|
|
35
38
|
self.content = self.to_xml
|
36
39
|
end
|
37
40
|
end
|
41
|
+
deprecation_deprecate :serialize!
|
38
42
|
|
39
43
|
end
|
@@ -47,6 +47,12 @@ module ActiveFedora
|
|
47
47
|
Nokogiri::XML::Document.parse("<xml/>")
|
48
48
|
end
|
49
49
|
|
50
|
+
def save
|
51
|
+
@content = to_xml
|
52
|
+
super
|
53
|
+
end
|
54
|
+
|
55
|
+
|
50
56
|
def ng_xml
|
51
57
|
@ng_xml ||= begin
|
52
58
|
self.xml_loaded = true
|
@@ -76,7 +82,7 @@ module ActiveFedora
|
|
76
82
|
|
77
83
|
new_xml_string = nokogiri_document.to_xml {|config| config.no_declaration}
|
78
84
|
|
79
|
-
ng_xml_will_change! unless (xml_loaded && (new_xml_string.to_s.strip == datastream_content.strip))
|
85
|
+
ng_xml_will_change! unless (xml_loaded && (new_xml_string.to_s.strip == (datastream_content || '').strip))
|
80
86
|
self.xml_loaded=true
|
81
87
|
|
82
88
|
@ng_xml = nokogiri_document
|
@@ -94,12 +100,19 @@ module ActiveFedora
|
|
94
100
|
|
95
101
|
# don't want content eagerly loaded by proxy, so implementing methods that would be implemented by define_attribute_methods
|
96
102
|
def ng_xml_changed?
|
97
|
-
changed_attributes.has_key?
|
98
|
-
|
103
|
+
return true if changed_attributes.has_key?('ng_xml')
|
104
|
+
|
105
|
+
return false unless xml_loaded
|
106
|
+
|
107
|
+
if new?
|
108
|
+
!to_xml.empty?
|
109
|
+
else
|
110
|
+
(to_xml.strip != (datastream_content || '').strip)
|
111
|
+
end
|
99
112
|
end
|
100
113
|
|
101
114
|
def changed?
|
102
|
-
|
115
|
+
ng_xml_changed? || super
|
103
116
|
end
|
104
117
|
|
105
118
|
def content_changed?
|
@@ -1,5 +1,11 @@
|
|
1
1
|
module ActiveFedora
|
2
2
|
class RDFDatastream < Datastream
|
3
|
+
|
4
|
+
before_save do
|
5
|
+
return unless graph_changed?
|
6
|
+
content_will_change!
|
7
|
+
end
|
8
|
+
|
3
9
|
# this enables a cleaner API for solr integration
|
4
10
|
class IndexObject
|
5
11
|
attr_accessor :data_type, :behaviors
|
@@ -145,46 +151,26 @@ module ActiveFedora
|
|
145
151
|
include ModelMethods
|
146
152
|
attr_accessor :loaded
|
147
153
|
|
148
|
-
def ensure_loaded
|
149
|
-
return if loaded
|
150
|
-
self.loaded = true
|
151
|
-
unless new?
|
152
|
-
deserialize content
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def changed?
|
157
|
-
super || dirty?
|
158
|
-
end
|
159
|
-
|
160
|
-
def dirty?
|
161
|
-
graph.dirty
|
162
|
-
end
|
163
|
-
|
164
154
|
def metadata?
|
165
155
|
true
|
166
156
|
end
|
167
157
|
|
168
158
|
def save
|
169
|
-
|
170
|
-
|
171
|
-
end
|
159
|
+
@content = serialize
|
160
|
+
|
172
161
|
|
173
|
-
|
174
|
-
return unless dirty?
|
175
|
-
return unless loaded
|
176
|
-
self.content = serialize
|
162
|
+
super
|
177
163
|
end
|
178
164
|
|
179
165
|
def content=(content)
|
180
|
-
|
181
|
-
|
182
|
-
deserialize(content)
|
166
|
+
content_will_change!
|
167
|
+
self.loaded = true
|
168
|
+
@graph = deserialize(content)
|
183
169
|
end
|
184
170
|
|
185
171
|
# returns a Hash, e.g.: {field => {:values => [], :type => :something, :behaviors => []}, ...}
|
186
172
|
def fields
|
187
|
-
|
173
|
+
|
188
174
|
field_map = {}
|
189
175
|
graph.relationships.each do |predicate, values|
|
190
176
|
vocab_sym, name = predicate.qname
|
@@ -203,7 +189,7 @@ module ActiveFedora
|
|
203
189
|
end
|
204
190
|
|
205
191
|
def to_solr(solr_doc = Hash.new) # :nodoc:
|
206
|
-
|
192
|
+
|
207
193
|
fields.each do |field_key, field_info|
|
208
194
|
values = field_info.fetch(:values, false)
|
209
195
|
if values
|
@@ -229,8 +215,12 @@ module ActiveFedora
|
|
229
215
|
# Populate a RDFDatastream object based on the "datastream" content
|
230
216
|
# Assumes that the datastream contains RDF content
|
231
217
|
# @param [String] data the "rdf" node
|
232
|
-
def deserialize(data)
|
233
|
-
|
218
|
+
def deserialize(data = nil)
|
219
|
+
graph = RelationshipGraph.new
|
220
|
+
return graph if new? and data.nil?
|
221
|
+
|
222
|
+
data ||= datastream_content
|
223
|
+
|
234
224
|
RDF::Reader.for(serialization_format).new(data) do |reader|
|
235
225
|
reader.each_statement do |statement|
|
236
226
|
begin
|
@@ -242,17 +232,51 @@ module ActiveFedora
|
|
242
232
|
graph.add(statement.predicate, object, literal)
|
243
233
|
end
|
244
234
|
end
|
245
|
-
|
235
|
+
|
246
236
|
graph
|
247
237
|
end
|
248
238
|
|
249
239
|
def graph
|
250
|
-
@graph ||=
|
240
|
+
@graph ||= begin
|
241
|
+
self.loaded = true
|
242
|
+
deserialize
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
# alias the original datastream content
|
247
|
+
alias :datastream_content :content
|
248
|
+
|
249
|
+
def content
|
250
|
+
# return the RDF graph content if it's available (or all we have)
|
251
|
+
return serialize if loaded or new?
|
252
|
+
|
253
|
+
# otherwise, grab the data from the datastore
|
254
|
+
super
|
255
|
+
end
|
256
|
+
|
257
|
+
def graph_will_change!
|
258
|
+
changed_attributes['graph'] = nil
|
259
|
+
end
|
260
|
+
|
261
|
+
def graph_changed?
|
262
|
+
return true if changed_attributes.has_key?('graph')
|
263
|
+
return false unless loaded
|
264
|
+
|
265
|
+
if new?
|
266
|
+
!serialize.empty?
|
267
|
+
else
|
268
|
+
serialize.strip != (datastream_content || '').strip
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
def changed?
|
274
|
+
graph_changed? || super
|
251
275
|
end
|
252
276
|
|
253
277
|
# @param [Symbol, RDF::URI] predicate the predicate to insert into the graph
|
254
278
|
def get_values(predicate)
|
255
|
-
|
279
|
+
|
256
280
|
predicate = find_predicate(predicate) unless predicate.kind_of? RDF::URI
|
257
281
|
results = graph[predicate]
|
258
282
|
return if results.nil?
|
@@ -266,7 +290,7 @@ module ActiveFedora
|
|
266
290
|
# if there are any existing statements with this predicate, replace them
|
267
291
|
# @param [Symbol, RDF::URI] predicate the predicate to insert into the graph
|
268
292
|
def set_value(predicate, args)
|
269
|
-
|
293
|
+
|
270
294
|
predicate = find_predicate(predicate) unless predicate.kind_of? RDF::URI
|
271
295
|
graph.delete(predicate)
|
272
296
|
args = [args] unless args.respond_to? :each
|
@@ -281,7 +305,7 @@ module ActiveFedora
|
|
281
305
|
# append a value
|
282
306
|
# @param [Symbol, RDF::URI] predicate the predicate to insert into the graph
|
283
307
|
def append(predicate, args)
|
284
|
-
|
308
|
+
|
285
309
|
predicate = find_predicate(predicate) unless predicate.kind_of? RDF::URI
|
286
310
|
graph.add(predicate, args, true)
|
287
311
|
graph.dirty = true
|
@@ -316,7 +340,6 @@ module ActiveFedora
|
|
316
340
|
writer << statement
|
317
341
|
end
|
318
342
|
end
|
319
|
-
graph.dirty = false
|
320
343
|
out
|
321
344
|
end
|
322
345
|
end
|
@@ -93,7 +93,9 @@ module ActiveFedora
|
|
93
93
|
# @param [Boolean] if false it will include inbound relationships (defaults to true)
|
94
94
|
# @return [Hash] Returns a hash of subject name (:self or :inbound) mapped to nested hashs of each relationship name mapped to an Array of objects linked via the relationship
|
95
95
|
def relationships_by_name(outbound_only=true)
|
96
|
-
|
96
|
+
Deprecation.silence(ActiveFedora::Relationships) do
|
97
|
+
@relationships_by_name = relationships_by_name_from_class()
|
98
|
+
end
|
97
99
|
outbound_only ? @relationships_by_name : @relationships_by_name.merge(:inbound=>inbound_relationships_by_name)
|
98
100
|
end
|
99
101
|
|
@@ -152,11 +154,13 @@ module ActiveFedora
|
|
152
154
|
# @param [String] Name of relationship
|
153
155
|
# @param [Boolean] If false checks inbound relationships as well (defaults to true)
|
154
156
|
def is_relationship_name?(name, outbound_only=true)
|
157
|
+
Deprecation.silence(ActiveFedora::Relationships) do
|
155
158
|
if outbound_only
|
156
159
|
outbound_relationship_names.include?(name)
|
157
160
|
else
|
158
161
|
(outbound_relationship_names.include?(name)||inbound_relationship_names.include?(name))
|
159
162
|
end
|
163
|
+
end
|
160
164
|
end
|
161
165
|
|
162
166
|
|
@@ -240,6 +244,7 @@ module ActiveFedora
|
|
240
244
|
# @param [ActiveFedora::Base] object to add to the relationship (expects ActvieFedora::Base to be an ancestor)
|
241
245
|
# @return [Boolean] returns true if add operation successful
|
242
246
|
def add_relationship_by_name(name, object)
|
247
|
+
Deprecation.silence(ActiveFedora::Relationships) do
|
243
248
|
if is_relationship_name?(name,true)
|
244
249
|
if relationships_desc[:self][name].has_key?(:type)
|
245
250
|
klass = class_from_name(relationships_desc[:self][name][:type])
|
@@ -251,6 +256,7 @@ module ActiveFedora
|
|
251
256
|
else
|
252
257
|
false
|
253
258
|
end
|
259
|
+
end
|
254
260
|
end
|
255
261
|
|
256
262
|
# Remove an object for the given relationship name
|
@@ -268,6 +274,7 @@ module ActiveFedora
|
|
268
274
|
deprecation_deprecate :find_relationship_by_name, :inbound_relationship_names, :inbound_relationships_by_name, :relationship_query, :relationships_by_name, :relationships_by_name_from_class, :assert_conforms_to, :class_from_name, :outbound_relationship_names, :is_relationship_name?, :load_inbound_relationship, :load_bidirectional, :load_outbound_relationship, :relationship_has_solr_filter_query?, :add_relationship_by_name, :remove_relationship_by_name
|
269
275
|
|
270
276
|
module ClassMethods
|
277
|
+
extend Deprecation
|
271
278
|
# Tests if the relationship name passed is in bidirectional
|
272
279
|
# @param [String] relationship name to test
|
273
280
|
# @return [Boolean]
|
@@ -494,7 +501,6 @@ module ActiveFedora
|
|
494
501
|
#
|
495
502
|
# @deprecated use ActiveFedora::Base.has_many or ActiveFedora::Base.belongs_to. has_relationship will be removed in active-fedora 6.0
|
496
503
|
def has_relationship(name, predicate, opts = {})
|
497
|
-
ActiveSupport::Deprecation.warn("ActiveFedora::Relationships#has_relationship has been deprecated use ActiveFedora::Base.has_many or ActiveFedora::Base.belongs_to. has_relationship will be removed in active-fedora 6.0.", caller(1))
|
498
504
|
opts = {:singular => nil, :inbound => false}.merge(opts)
|
499
505
|
if opts[:inbound] == true
|
500
506
|
register_relationship_desc(:inbound, name, predicate, opts)
|
@@ -508,6 +514,7 @@ module ActiveFedora
|
|
508
514
|
create_outbound_relationship_finders(name, predicate, opts)
|
509
515
|
end
|
510
516
|
end
|
517
|
+
deprecation_deprecate :has_relationship
|
511
518
|
|
512
519
|
# Used in has_relationship call to create dynamic helper methods to
|
513
520
|
# append and remove objects to and from a relationship
|
@@ -524,8 +531,9 @@ module ActiveFedora
|
|
524
531
|
def create_relationship_name_methods(name)
|
525
532
|
append_method_name = "#{name.to_s.downcase}_append"
|
526
533
|
remove_method_name = "#{name.to_s.downcase}_remove"
|
527
|
-
|
528
|
-
self.send(:define_method,:"#{
|
534
|
+
|
535
|
+
self.send(:define_method,:"#{append_method_name}") {|object| Deprecation.silence(ActiveFedora::Relationships) { add_relationship_by_name(name,object) } }
|
536
|
+
self.send(:define_method,:"#{remove_method_name}") {|object| Deprecation.silence(ActiveFedora::Relationships) {remove_relationship_by_name(name,object) } }
|
529
537
|
end
|
530
538
|
|
531
539
|
|
@@ -547,14 +555,16 @@ module ActiveFedora
|
|
547
555
|
#
|
548
556
|
# @deprecated use ActiveFedora::Base.has_and_belongs_to_many. has_bidirectional_relationship will be removed in active-fedora 6.0
|
549
557
|
def has_bidirectional_relationship(name, outbound_predicate, inbound_predicate, opts={})
|
550
|
-
ActiveSupport::Deprecation.warn("ActiveFedora::Relationships#has_bidirectional_relationship has been deprecated, reference ActiveFedora::Base.has_and_belongs_to_many. has_bidirectional_relationship will be removed in active-fedora 6.0.", caller(1))
|
551
558
|
create_bidirectional_relationship_finders(name, outbound_predicate, inbound_predicate, opts)
|
552
559
|
end
|
553
|
-
|
560
|
+
deprecation_deprecate :has_bidirectional_relationship
|
561
|
+
|
554
562
|
def create_inbound_relationship_finders(name, predicate, opts = {})
|
555
563
|
class_eval <<-END, __FILE__, __LINE__
|
556
564
|
def #{name}(opts={})
|
557
|
-
|
565
|
+
Deprecation.silence(ActiveFedora::Relationships) do
|
566
|
+
load_inbound_relationship('#{name}', '#{predicate}', opts)
|
567
|
+
end
|
558
568
|
end
|
559
569
|
def #{name}_ids
|
560
570
|
#{name}(:response_format => :id_array)
|
@@ -571,7 +581,9 @@ module ActiveFedora
|
|
571
581
|
def create_outbound_relationship_finders(name, predicate, opts = {})
|
572
582
|
class_eval <<-END, __FILE__, __LINE__
|
573
583
|
def #{name}(opts={})
|
574
|
-
|
584
|
+
Deprecation.silence(ActiveFedora::Relationships) do
|
585
|
+
load_outbound_relationship(#{name.inspect}, #{predicate.inspect}, opts)
|
586
|
+
end
|
575
587
|
end
|
576
588
|
def #{name}_ids
|
577
589
|
#{name}(:response_format => :id_array)
|
@@ -596,18 +608,22 @@ module ActiveFedora
|
|
596
608
|
# @param [Hash] opts (optional)
|
597
609
|
# @deprecated create_bidirectional_relationship_finders will be removed in active-fedora 6.0
|
598
610
|
def create_bidirectional_relationship_finders(name, outbound_predicate, inbound_predicate, opts={})
|
599
|
-
ActiveSupport::Deprecation.warn("ActiveFedora::Relationships#create_bidirectional_relationship_finders has been deprecated and will be removed in active-fedora 6.0.", caller(1))
|
600
611
|
inbound_method_name = name.to_s+"_inbound"
|
601
612
|
outbound_method_name = name.to_s+"_outbound"
|
613
|
+
Deprecation.silence(ActiveFedora::Relationships::ClassMethods) do
|
602
614
|
has_relationship(outbound_method_name, outbound_predicate, opts)
|
603
615
|
has_relationship(inbound_method_name, inbound_predicate, opts.merge!(:inbound=>true))
|
604
616
|
|
605
617
|
#create methods that mirror the outbound append and remove with our bidirectional name, assume just add and remove locally
|
606
618
|
create_bidirectional_relationship_name_methods(name,outbound_method_name)
|
607
619
|
|
620
|
+
end
|
621
|
+
|
608
622
|
class_eval <<-END, __FILE__, __LINE__
|
609
623
|
def #{name}(opts={})
|
610
|
-
|
624
|
+
Deprecation.silence(ActiveFedora::Relationships) do
|
625
|
+
load_bidirectional("#{name}", :#{inbound_method_name}, :#{outbound_method_name}, opts)
|
626
|
+
end
|
611
627
|
end
|
612
628
|
def #{name}_ids
|
613
629
|
#{name}(:response_format => :id_array)
|
@@ -620,6 +636,7 @@ module ActiveFedora
|
|
620
636
|
end
|
621
637
|
END
|
622
638
|
end
|
639
|
+
deprecation_deprecate :create_bidirectional_relationship_finders
|
623
640
|
|
624
641
|
# Similar to +create_relationship_name_methods+ except it is used when an ActiveFedora::Base model class
|
625
642
|
# declares has_bidirectional_relationship. we are merely creating an alias for outbound portion of bidirectional
|
@@ -634,12 +651,12 @@ module ActiveFedora
|
|
634
651
|
#
|
635
652
|
# @deprecated create_bidirectional_relationship_name_methods will be removed in active-fedora 6.0
|
636
653
|
def create_bidirectional_relationship_name_methods(name,outbound_name)
|
637
|
-
ActiveSupport::Deprecation.warn("ActiveFedora::Relationships#create_bidirectional_relationship_name_methods has been deprecated and will be removed in active-fedora 6.0.", caller(1))
|
638
654
|
append_method_name = "#{name.to_s.downcase}_append"
|
639
655
|
remove_method_name = "#{name.to_s.downcase}_remove"
|
640
656
|
self.send(:define_method,:"#{append_method_name}") {|object| add_relationship_by_name(outbound_name,object)}
|
641
657
|
self.send(:define_method,:"#{remove_method_name}") {|object| remove_relationship_by_name(outbound_name,object)}
|
642
658
|
end
|
659
|
+
deprecation_deprecate :create_bidirectional_relationship_name_methods
|
643
660
|
|
644
661
|
end
|
645
662
|
end
|