active-fedora 3.3.2 → 4.0.0.rc1
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 +21 -22
- data/History.txt +9 -0
- data/README.textile +1 -1
- data/TODO +1 -0
- data/active-fedora.gemspec +3 -3
- data/config/fedora.yml +9 -3
- data/lib/active_fedora.rb +43 -33
- data/lib/active_fedora/base.rb +80 -31
- data/lib/active_fedora/config.rb +38 -0
- data/lib/active_fedora/content_model.rb +0 -6
- data/lib/active_fedora/datastream.rb +22 -0
- data/lib/active_fedora/delegating.rb +24 -25
- data/lib/active_fedora/digital_object.rb +2 -1
- data/lib/active_fedora/file_management.rb +1 -0
- data/lib/active_fedora/fixture_exporter.rb +1 -1
- data/lib/active_fedora/fixture_loader.rb +3 -3
- data/lib/active_fedora/metadata_datastream.rb +6 -0
- data/lib/active_fedora/model.rb +24 -5
- data/lib/active_fedora/nokogiri_datastream.rb +1 -0
- data/lib/active_fedora/ntriples_rdf_datastream.rb +0 -1
- data/lib/active_fedora/persistence.rb +2 -1
- data/lib/active_fedora/predicates.rb +27 -27
- data/lib/active_fedora/rdf_datastream.rb +104 -30
- data/lib/active_fedora/rels_ext_datastream.rb +14 -10
- data/lib/active_fedora/rubydora_connection.rb +4 -27
- data/lib/active_fedora/service_definitions.rb +2 -3
- data/lib/active_fedora/solr_digital_object.rb +22 -8
- data/lib/active_fedora/solr_service.rb +1 -1
- data/lib/active_fedora/unsaved_digital_object.rb +1 -4
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora.rake +6 -6
- data/lib/tasks/active_fedora_dev.rake +0 -1
- data/spec/fixtures/mixed_rdf_descMetadata.nt +6 -0
- data/spec/fixtures/rails_root/config/fedora.yml +3 -1
- data/spec/fixtures/sharded_fedora.yml +11 -0
- data/spec/integration/base_file_management_spec.rb +6 -3
- data/spec/integration/base_find_by_fields_spec.rb +15 -16
- data/spec/integration/base_spec.rb +11 -178
- data/spec/integration/datastream_collections_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +1 -2
- data/spec/integration/model_spec.rb +8 -9
- data/spec/integration/mods_article_integration_spec.rb +1 -1
- data/spec/integration/nokogiri_datastream_spec.rb +1 -1
- data/spec/integration/ntriples_datastream_spec.rb +80 -0
- data/spec/integration/rels_ext_datastream_spec.rb +0 -1
- data/spec/integration/semantic_node_spec.rb +18 -26
- data/spec/integration/solr_service_spec.rb +51 -1
- data/{lib/active_fedora → spec}/samples/hydra-mods_article_datastream.rb +0 -0
- data/{lib/active_fedora → spec}/samples/hydra-rights_metadata_datastream.rb +0 -0
- data/{lib/active_fedora → spec}/samples/marpa-dc_datastream.rb +0 -0
- data/spec/samples/models/hydrangea_article.rb +2 -2
- data/spec/samples/samples.rb +2 -0
- data/{lib/active_fedora → spec}/samples/special_thing.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/active_fedora_spec.rb +17 -50
- data/spec/unit/base_extra_spec.rb +4 -0
- data/spec/unit/base_file_management_spec.rb +5 -2
- data/spec/unit/base_spec.rb +692 -628
- data/spec/unit/config_spec.rb +19 -0
- data/spec/unit/content_model_spec.rb +1 -24
- data/spec/unit/datastream_collections_spec.rb +11 -14
- data/spec/unit/datastreams_spec.rb +49 -54
- data/spec/unit/model_spec.rb +24 -53
- data/spec/unit/nokogiri_datastream_spec.rb +6 -1
- data/spec/unit/ntriples_datastream_spec.rb +73 -0
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
- data/spec/unit/relationships_spec.rb +6 -3
- data/spec/unit/rels_ext_datastream_spec.rb +19 -0
- data/spec/unit/rubydora_connection_spec.rb +2 -56
- data/spec/unit/solr_service_spec.rb +3 -1
- data/spec/unit/unsaved_digital_object_spec.rb +2 -2
- metadata +46 -33
- data/lib/active_fedora/dcrdf_datastream.rb +0 -11
- data/lib/active_fedora/relationship.rb +0 -47
- data/lib/active_fedora/samples.rb +0 -3
- data/spec/integration/dc_rdf_datastream_spec.rb +0 -24
- data/spec/unit/dc_rdf_datastream_spec.rb +0 -50
- data/spec/unit/relationship_spec.rb +0 -92
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active-fedora (
|
4
|
+
active-fedora (4.0.0.rc1)
|
5
5
|
activeresource (>= 3.0.0)
|
6
6
|
activesupport (>= 3.0.0)
|
7
7
|
equivalent-xml
|
@@ -9,10 +9,10 @@ PATH
|
|
9
9
|
mime-types (>= 1.16)
|
10
10
|
multipart-post (= 1.1.2)
|
11
11
|
nokogiri
|
12
|
-
om (>= 1.5.
|
12
|
+
om (>= 1.5.3)
|
13
13
|
rdf
|
14
14
|
rdf-rdfxml
|
15
|
-
rubydora (~> 0.5.
|
15
|
+
rubydora (~> 0.5.4)
|
16
16
|
solr-ruby (>= 0.0.6)
|
17
17
|
solrizer (~> 1.2.0)
|
18
18
|
xml-simple (>= 1.0.12)
|
@@ -21,22 +21,22 @@ GEM
|
|
21
21
|
remote: http://rubygems.org/
|
22
22
|
specs:
|
23
23
|
RedCloth (4.2.9)
|
24
|
-
activemodel (3.2.
|
25
|
-
activesupport (= 3.2.
|
24
|
+
activemodel (3.2.2)
|
25
|
+
activesupport (= 3.2.2)
|
26
26
|
builder (~> 3.0.0)
|
27
|
-
activeresource (3.2.
|
28
|
-
activemodel (= 3.2.
|
29
|
-
activesupport (= 3.2.
|
30
|
-
activesupport (3.2.
|
27
|
+
activeresource (3.2.2)
|
28
|
+
activemodel (= 3.2.2)
|
29
|
+
activesupport (= 3.2.2)
|
30
|
+
activesupport (3.2.2)
|
31
31
|
i18n (~> 0.6)
|
32
32
|
multi_json (~> 1.0)
|
33
33
|
addressable (2.2.7)
|
34
34
|
akami (1.0.0)
|
35
35
|
gyoku (>= 0.4.0)
|
36
36
|
builder (3.0.0)
|
37
|
-
childprocess (0.3.
|
37
|
+
childprocess (0.3.1)
|
38
38
|
ffi (~> 1.0.6)
|
39
|
-
daemons (1.1.
|
39
|
+
daemons (1.1.8)
|
40
40
|
diff-lcs (1.1.3)
|
41
41
|
equivalent-xml (0.2.9)
|
42
42
|
nokogiri (>= 1.4.3)
|
@@ -57,13 +57,13 @@ GEM
|
|
57
57
|
mediashelf-loggable (0.4.9)
|
58
58
|
metaclass (0.0.1)
|
59
59
|
mime-types (1.17.2)
|
60
|
-
mocha (0.10.
|
60
|
+
mocha (0.10.5)
|
61
61
|
metaclass (~> 0.0.1)
|
62
|
-
multi_json (1.0
|
62
|
+
multi_json (1.1.0)
|
63
63
|
multipart-post (1.1.2)
|
64
64
|
nokogiri (1.5.0)
|
65
65
|
nori (1.1.0)
|
66
|
-
om (1.5.
|
66
|
+
om (1.5.3)
|
67
67
|
mediashelf-loggable
|
68
68
|
nokogiri (>= 1.4.2)
|
69
69
|
rack (1.4.1)
|
@@ -85,7 +85,7 @@ GEM
|
|
85
85
|
rspec-expectations (2.8.0)
|
86
86
|
diff-lcs (~> 1.1.2)
|
87
87
|
rspec-mocks (2.8.0)
|
88
|
-
rubydora (0.5.
|
88
|
+
rubydora (0.5.4)
|
89
89
|
activemodel
|
90
90
|
activesupport
|
91
91
|
fastercsv
|
@@ -109,19 +109,18 @@ GEM
|
|
109
109
|
om (>= 1.5.0)
|
110
110
|
stomp
|
111
111
|
xml-simple
|
112
|
-
solrizer-fedora (1.2.
|
113
|
-
active-fedora (>= 3.
|
114
|
-
activesupport
|
112
|
+
solrizer-fedora (1.2.5)
|
113
|
+
active-fedora (>= 3.2.0)
|
114
|
+
activesupport (>= 3.0.11)
|
115
115
|
fastercsv
|
116
|
-
|
117
|
-
rsolr
|
116
|
+
rsolr (= 1.0.6)
|
118
117
|
solr-ruby (>= 0.0.6)
|
119
118
|
solrizer (>= 1.0.0)
|
120
119
|
stomp (1.2.0)
|
121
120
|
wasabi (2.1.0)
|
122
121
|
nokogiri (>= 1.4.0)
|
123
122
|
xml-simple (1.1.1)
|
124
|
-
yard (0.7.
|
123
|
+
yard (0.7.5)
|
125
124
|
|
126
125
|
PLATFORMS
|
127
126
|
ruby
|
@@ -133,5 +132,5 @@ DEPENDENCIES
|
|
133
132
|
mocha (>= 0.9.8)
|
134
133
|
rake
|
135
134
|
rspec (~> 2.0)
|
136
|
-
solrizer-fedora (~> 1.2.
|
135
|
+
solrizer-fedora (~> 1.2.5)
|
137
136
|
yard
|
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
4.0.0.rc1
|
2
|
+
Removed deprecations
|
3
|
+
* allowing :fedora level in fedora.yml
|
4
|
+
* automatic includes of Relationships and FileMethods is removed
|
5
|
+
Added sharding TODO add documentation
|
6
|
+
Added find_document which determines the correct model and then casts the object to that.
|
7
|
+
Improved loading from solr
|
8
|
+
RDF datastreams
|
9
|
+
|
1
10
|
3.3.2
|
2
11
|
HYDRA-745 No need to require :url be present on external datastreams
|
3
12
|
Initialize relationships graph to empty array
|
data/README.textile
CHANGED
data/TODO
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Get rid of ActiveFedora::Relationships methods in specs (except in relationships_spec.rb of course)
|
data/active-fedora.gemspec
CHANGED
@@ -20,20 +20,20 @@ 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.5.
|
23
|
+
s.add_dependency('om', '>= 1.5.3')
|
24
24
|
s.add_dependency('solrizer', '~>1.2.0')
|
25
25
|
s.add_dependency("activeresource", '>= 3.0.0')
|
26
26
|
s.add_dependency("activesupport", '>= 3.0.0')
|
27
27
|
s.add_dependency("mediashelf-loggable")
|
28
28
|
s.add_dependency("equivalent-xml")
|
29
|
-
s.add_dependency("rubydora", '~>0.5.
|
29
|
+
s.add_dependency("rubydora", '~>0.5.4')
|
30
30
|
s.add_dependency("rdf")
|
31
31
|
s.add_dependency("rdf-rdfxml")
|
32
32
|
s.add_development_dependency("yard")
|
33
33
|
s.add_development_dependency("RedCloth") # for RDoc formatting
|
34
34
|
s.add_development_dependency("rake")
|
35
35
|
# s.add_development_dependency("rcov") # not ruby 1.9 compatible
|
36
|
-
s.add_development_dependency("solrizer-fedora", "~>1.2.
|
36
|
+
s.add_development_dependency("solrizer-fedora", "~>1.2.5") # used by the fixtures rake tasks
|
37
37
|
s.add_development_dependency("jettywrapper", ">=1.2.0")
|
38
38
|
s.add_development_dependency("rspec", "~> 2.0")
|
39
39
|
s.add_development_dependency("mocha", ">= 0.9.8")
|
data/config/fedora.yml
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
development:
|
2
|
-
|
2
|
+
user: fedoraAdmin
|
3
|
+
password: fedoraAdmin
|
4
|
+
url: http://127.0.0.1:8983/fedora
|
3
5
|
test:
|
4
|
-
|
6
|
+
user: fedoraAdmin
|
7
|
+
password: fedoraAdmin
|
8
|
+
url: http://127.0.0.1:8983/fedora-test
|
5
9
|
production:
|
6
|
-
|
10
|
+
user: fedoraAdmin
|
11
|
+
password: fedoraAdmin
|
12
|
+
url: http://127.0.0.1:8080/fedora
|
7
13
|
|
data/lib/active_fedora.rb
CHANGED
@@ -12,18 +12,26 @@ ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
|
|
12
12
|
module ActiveFedora #:nodoc:
|
13
13
|
extend ActiveSupport::Autoload
|
14
14
|
|
15
|
+
class ObjectNotFoundError < RuntimeError; end # :nodoc:
|
16
|
+
class PredicateMappingsNotFoundError < RuntimeError; end # :nodoc:
|
17
|
+
class UnknownAttributeError < NoMethodError; end; # :nodoc:
|
18
|
+
class ConfigurationError < RuntimeError; end # :nodoc:
|
19
|
+
class AssociationTypeMismatch < RuntimeError; end # :nodoc:
|
20
|
+
class UnregisteredPredicateError < RuntimeError; end
|
21
|
+
|
22
|
+
|
15
23
|
eager_autoload do
|
16
24
|
autoload :Associations
|
17
25
|
autoload :AttributeMethods
|
18
26
|
autoload :Base
|
19
27
|
autoload :ContentModel
|
20
28
|
autoload :Callbacks
|
29
|
+
autoload :Config
|
21
30
|
autoload :Reflection
|
22
31
|
autoload :Relationships
|
23
32
|
autoload :FileManagement
|
24
33
|
autoload :RelationshipGraph
|
25
34
|
autoload :Datastream
|
26
|
-
autoload :DCRDFDatastream
|
27
35
|
autoload :Datastreams
|
28
36
|
autoload :Delegating
|
29
37
|
autoload :DigitalObject
|
@@ -55,7 +63,7 @@ module ActiveFedora #:nodoc:
|
|
55
63
|
include Loggable
|
56
64
|
|
57
65
|
class << self
|
58
|
-
attr_accessor :solr_config, :fedora_config, :config_env, :
|
66
|
+
attr_accessor :solr_config, :fedora_config, :config_env, :solr_config_path
|
59
67
|
attr_reader :config_options
|
60
68
|
end
|
61
69
|
|
@@ -92,9 +100,20 @@ module ActiveFedora #:nodoc:
|
|
92
100
|
# Options allowed in fedora.yml
|
93
101
|
# first level is the environment (e.g. development, test, production and any custom environments you may have)
|
94
102
|
# the second level has these keys:
|
95
|
-
# 1. url: url including protocol,
|
96
|
-
# 2.
|
97
|
-
|
103
|
+
# 1. url: url including protocol, host, port and path (e.g. http://127.0.0.1:8983/fedora)
|
104
|
+
# 2. user: username
|
105
|
+
# 3. password: password
|
106
|
+
# 4. validateChecksum: indicates to the fedora server whether you want to validate checksums when the datastreams are queried.
|
107
|
+
#
|
108
|
+
# @example If you want to shard the fedora instance, you can specify an array of credentials.
|
109
|
+
# production:
|
110
|
+
# - user: user1
|
111
|
+
# password: password1
|
112
|
+
# url: http://127.0.0.1:8983/fedora1
|
113
|
+
# - user: user2
|
114
|
+
# password: password2
|
115
|
+
# url: http://127.0.0.1:8983/fedora2
|
116
|
+
#
|
98
117
|
|
99
118
|
def self.init( options={} )
|
100
119
|
# Make config_options into a Hash if nil is passed in as the value
|
@@ -115,6 +134,11 @@ module ActiveFedora #:nodoc:
|
|
115
134
|
load_configs
|
116
135
|
end
|
117
136
|
|
137
|
+
def self.config
|
138
|
+
load_configs
|
139
|
+
@fedora_config
|
140
|
+
end
|
141
|
+
|
118
142
|
def self.reset!
|
119
143
|
@config_loaded = false #Force reload of configs
|
120
144
|
@predicate_config_path = nil
|
@@ -127,7 +151,7 @@ module ActiveFedora #:nodoc:
|
|
127
151
|
def self.load_configs
|
128
152
|
return if config_loaded?
|
129
153
|
@config_env = environment
|
130
|
-
|
154
|
+
@fedora_config = Config.new(get_config_path(:fedora), @config_env)
|
131
155
|
load_config(:solr)
|
132
156
|
@config_loaded = true
|
133
157
|
|
@@ -150,7 +174,8 @@ module ActiveFedora #:nodoc:
|
|
150
174
|
end
|
151
175
|
|
152
176
|
def self.config_for_environment
|
153
|
-
|
177
|
+
ActiveSupport::Deprecation.warn("config_for_environment has been deprecated use `config' instead")
|
178
|
+
config
|
154
179
|
end
|
155
180
|
|
156
181
|
# Determines and sets the fedora_config[:url] or solr_config[:url]
|
@@ -161,13 +186,7 @@ module ActiveFedora #:nodoc:
|
|
161
186
|
c = config[environment.to_sym]
|
162
187
|
c.symbolize_keys!
|
163
188
|
if config_type == "fedora"
|
164
|
-
|
165
|
-
url = if c.fetch(:fedora,nil)
|
166
|
-
ActiveSupport::Deprecation.warn("Using \"fedora\" in the fedora.yml file is no longer supported")
|
167
|
-
c[:fedora]["url"] if config[environment.to_sym].fetch(:fedora,nil)
|
168
|
-
else
|
169
|
-
c[:url]
|
170
|
-
end
|
189
|
+
url = c[:url]
|
171
190
|
if url && !c[:user]
|
172
191
|
u = URI.parse url
|
173
192
|
c[:user] = u.user
|
@@ -233,16 +252,13 @@ module ActiveFedora #:nodoc:
|
|
233
252
|
def self.get_config_path(config_type)
|
234
253
|
config_type = config_type.to_s
|
235
254
|
if (config_path = config_options.fetch("#{config_type}_config_path".to_sym,nil) )
|
236
|
-
raise
|
237
|
-
return config_path
|
255
|
+
raise ConfigurationError, "file does not exist #{config_path}" unless File.file? config_path
|
256
|
+
return File.expand_path(config_path)
|
238
257
|
end
|
239
258
|
|
240
259
|
# if solr, attempt to use path where fedora.yml is first
|
241
260
|
if config_type == "solr" && (config_path = check_fedora_path_for_solr)
|
242
261
|
return config_path
|
243
|
-
elsif config_type == "solr" && fedora_config[environment].fetch("solr",nil)
|
244
|
-
ActiveSupport::Deprecation.warn("You appear to be using a deprecated format for your fedora.yml file. The solr url should be stored in a separate solr.yml file in the same directory as the fedora.yml")
|
245
|
-
raise ActiveFedoraConfigurationException
|
246
262
|
end
|
247
263
|
|
248
264
|
if defined?(Rails.root)
|
@@ -258,12 +274,12 @@ module ActiveFedora #:nodoc:
|
|
258
274
|
config_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "config", "#{config_type}.yml"))
|
259
275
|
logger.warn "Using the default #{config_type}.yml that comes with active-fedora. If you want to override this, pass the path to #{config_type}.yml to ActiveFedora - ie. ActiveFedora.init(:#{config_type}_config_path => '/path/to/#{config_type}.yml) - or set Rails.root and put #{config_type}.yml into \#{Rails.root}/config."
|
260
276
|
return config_path if File.file? config_path
|
261
|
-
raise
|
277
|
+
raise ConfigurationError "Couldn't load #{config_type} config file!"
|
262
278
|
end
|
263
279
|
|
264
|
-
# Checks the existing
|
280
|
+
# Checks the existing fedora_config.path to see if there is a solr.yml there
|
265
281
|
def self.check_fedora_path_for_solr
|
266
|
-
path =
|
282
|
+
path = @fedora_config.path.split('/')[0..-2].join('/') + "/solr.yml"
|
267
283
|
if File.file? path
|
268
284
|
return path
|
269
285
|
else
|
@@ -275,12 +291,15 @@ module ActiveFedora #:nodoc:
|
|
275
291
|
ActiveFedora::SolrService.instance
|
276
292
|
end
|
277
293
|
|
294
|
+
|
278
295
|
def self.fedora
|
279
|
-
ActiveFedora::
|
296
|
+
ActiveSupport::Deprecation.warn("ActiveFedora.fedora() is deprecated and will be removed in the next release use ActiveFedora::Base.connection_for_pid(pid) instead")
|
297
|
+
|
298
|
+
ActiveFedora::Base.connection_for_pid('0')
|
280
299
|
end
|
281
300
|
|
282
301
|
def self.predicate_config
|
283
|
-
@predicate_config_path ||= build_predicate_config_path(File.dirname(@
|
302
|
+
@predicate_config_path ||= build_predicate_config_path(File.dirname(@fedora_config.path))
|
284
303
|
end
|
285
304
|
|
286
305
|
def self.version
|
@@ -311,15 +330,6 @@ module ActiveFedora #:nodoc:
|
|
311
330
|
|
312
331
|
end
|
313
332
|
|
314
|
-
module ActiveFedora
|
315
|
-
class ObjectNotFoundError < RuntimeError; end # :nodoc:
|
316
|
-
class PredicateMappingsNotFoundError < RuntimeError; end # :nodoc:
|
317
|
-
class UnknownAttributeError < NoMethodError; end; # :nodoc:
|
318
|
-
class ActiveFedoraConfigurationException < Exception; end # :nodoc:
|
319
|
-
class AssociationTypeMismatch < RuntimeError; end # :nodoc:
|
320
|
-
class UnregisteredPredicateError < RuntimeError; end
|
321
|
-
|
322
|
-
end
|
323
333
|
|
324
334
|
load File.join(File.dirname(__FILE__),"tasks/active_fedora.rake") if defined?(Rake)
|
325
335
|
|
data/lib/active_fedora/base.rb
CHANGED
@@ -30,28 +30,15 @@ module ActiveFedora
|
|
30
30
|
class Base
|
31
31
|
include SemanticNode
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
if [:has_relationship, :has_bidirectional_relationship, :register_relationship_desc].include? name
|
36
|
-
ActiveSupport::Deprecation.warn("Deprecation: Relationships will not be included by default in the next version. To use #{name} add 'include ActiveFedora::Relationships' to your model")
|
37
|
-
include Relationships
|
38
|
-
send name, *args
|
39
|
-
elsif name == :has_datastream
|
40
|
-
ActiveSupport::Deprecation.warn("Deprecation: DatastreamCollections will not be included by default in the next version. To use has_datastream add 'include ActiveFedora::DatastreamCollections' to your model")
|
41
|
-
include DatastreamCollections
|
42
|
-
has_datastream(*args)
|
43
|
-
else
|
44
|
-
super
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
33
|
+
class_attribute :fedora_connection
|
34
|
+
self.fedora_connection = {}
|
48
35
|
|
49
36
|
def method_missing(name, *args)
|
50
|
-
if [:collection_members, :part_of, :parts, :part_of_append, :file_objects].include? name
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
else
|
37
|
+
# if [:collection_members, :part_of, :parts, :part_of_append, :file_objects].include? name
|
38
|
+
# ActiveSupport::Deprecation.warn("Deprecation: FileManagement will not be included by default in the next version. To use #{name} add 'include ActiveFedora::FileManagement' to your model")
|
39
|
+
# self.class.send :include, FileManagement
|
40
|
+
# send name, *args
|
41
|
+
# else
|
55
42
|
dsid = corresponding_datastream_name(name)
|
56
43
|
if dsid
|
57
44
|
### Create and invoke a proxy method
|
@@ -62,7 +49,6 @@ module ActiveFedora
|
|
62
49
|
else
|
63
50
|
super
|
64
51
|
end
|
65
|
-
end
|
66
52
|
end
|
67
53
|
|
68
54
|
|
@@ -133,6 +119,28 @@ module ActiveFedora
|
|
133
119
|
self
|
134
120
|
end
|
135
121
|
|
122
|
+
# Uses {shard_index} to find or create the rubydora connection for this pid
|
123
|
+
# @param [String] pid the identifier of the object to get the connection for
|
124
|
+
# @return [Rubydora::Repository] The repository that the identifier exists in.
|
125
|
+
def self.connection_for_pid(pid)
|
126
|
+
idx = shard_index(pid)
|
127
|
+
unless fedora_connection.has_key? idx
|
128
|
+
if ActiveFedora.config.sharded?
|
129
|
+
fedora_connection[idx] = RubydoraConnection.new(ActiveFedora.config.credentials[idx])
|
130
|
+
else
|
131
|
+
fedora_connection[idx] = RubydoraConnection.new(ActiveFedora.config.credentials)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
fedora_connection[idx].connection
|
135
|
+
end
|
136
|
+
|
137
|
+
#If you want to use sharding override this method with your strategy
|
138
|
+
#@return [Integer] the index of the shard this object is stored in
|
139
|
+
def self.shard_index(pid)
|
140
|
+
0
|
141
|
+
end
|
142
|
+
|
143
|
+
|
136
144
|
def self.datastream_class_for_name(dsid)
|
137
145
|
ds_specs[dsid] ? ds_specs[dsid][:type] : ActiveFedora::Datastream
|
138
146
|
end
|
@@ -143,6 +151,17 @@ module ActiveFedora
|
|
143
151
|
obj
|
144
152
|
end
|
145
153
|
|
154
|
+
|
155
|
+
### if you are doing sharding, override this method to do something other than use a sequence
|
156
|
+
# @return [String] the unique pid for a new object
|
157
|
+
def self.assign_pid(obj)
|
158
|
+
args = {}
|
159
|
+
args[:namespace] = obj.namespace if obj.namespace
|
160
|
+
raise RuntimeError, "When using shards, you must override #{self}.assign_pid()" if ActiveFedora.config.sharded?
|
161
|
+
d = REXML::Document.new(connection_for_pid('0').next_pid(args))
|
162
|
+
d.elements['//pid'].text
|
163
|
+
end
|
164
|
+
|
146
165
|
def inner_object # :nodoc
|
147
166
|
@inner_object
|
148
167
|
end
|
@@ -167,7 +186,7 @@ module ActiveFedora
|
|
167
186
|
def internal_uri
|
168
187
|
"info:fedora/#{pid}"
|
169
188
|
end
|
170
|
-
|
189
|
+
|
171
190
|
#return the state of the inner object
|
172
191
|
def state
|
173
192
|
@inner_object.state
|
@@ -253,20 +272,30 @@ module ActiveFedora
|
|
253
272
|
def to_solr(solr_doc = Hash.new, opts={})
|
254
273
|
unless opts[:model_only]
|
255
274
|
solr_doc.merge!(SOLR_DOCUMENT_ID.to_sym => pid, ActiveFedora::SolrService.solr_name(:system_create, :date) => self.create_date, ActiveFedora::SolrService.solr_name(:system_modified, :date) => self.modified_date, ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol) => self.class.inspect)
|
275
|
+
solrize_profile(solr_doc)
|
256
276
|
end
|
257
277
|
datastreams.each_value do |ds|
|
278
|
+
solr_doc = ds.solrize_profile(solr_doc)
|
258
279
|
ds.ensure_xml_loaded if ds.respond_to? :ensure_xml_loaded ### Can't put this in the model because it's often implemented in Solrizer::XML::TerminologyBasedSolrizer
|
259
280
|
solr_doc = ds.to_solr(solr_doc) if ds.kind_of?(ActiveFedora::MetadataDatastream) || ds.kind_of?(ActiveFedora::NokogiriDatastream)
|
260
281
|
end
|
261
282
|
solr_doc = solrize_relationships(solr_doc) unless opts[:model_only]
|
262
|
-
|
263
|
-
#logger.info("PID: '#{pid}' solr_doc put into solr: #{solr_doc.inspect}")
|
264
|
-
rescue
|
265
|
-
logger.info("Error encountered trying to output solr_doc details for pid: #{pid}")
|
266
|
-
end
|
267
|
-
return solr_doc
|
283
|
+
solr_doc
|
268
284
|
end
|
269
285
|
|
286
|
+
def solrize_profile(solr_doc = Hash.new) # :nodoc:
|
287
|
+
if inner_object.respond_to? :profile
|
288
|
+
inner_object.profile.each_pair do |property,value|
|
289
|
+
if property =~ /Date/
|
290
|
+
value = Time.parse(value) unless value.is_a?(Time)
|
291
|
+
value = value.xmlschema
|
292
|
+
end
|
293
|
+
solr_doc[ActiveFedora::SolrService.solr_name("objProfile_#{property}", property =~ /Date/ ? :date : :symbol)] = value
|
294
|
+
end
|
295
|
+
end
|
296
|
+
solr_doc
|
297
|
+
end
|
298
|
+
|
270
299
|
# Serialize the datastream's RDF relationships to solr
|
271
300
|
# @param [Hash] solr_doc @deafult an empty Hash
|
272
301
|
def solrize_relationships(solr_doc = Hash.new)
|
@@ -289,6 +318,27 @@ module ActiveFedora
|
|
289
318
|
end
|
290
319
|
klass.allocate.init_with(inner_object)
|
291
320
|
end
|
321
|
+
|
322
|
+
# ** EXPERIMENTAL **
|
323
|
+
# This method returns a new object of the same class, with the internal SolrDigitalObject
|
324
|
+
# replaced with an actual DigitalObject.
|
325
|
+
def reify
|
326
|
+
if self.inner_object.is_a? DigitalObject
|
327
|
+
raise "#{self.inspect} is already a full digital object"
|
328
|
+
end
|
329
|
+
self.class.load_instance self.pid
|
330
|
+
end
|
331
|
+
|
332
|
+
# ** EXPERIMENTAL **
|
333
|
+
# This method reinitializes a lightweight, loaded-from-solr object with an actual
|
334
|
+
# DigitalObject inside.
|
335
|
+
def reify!
|
336
|
+
if self.inner_object.is_a? DigitalObject
|
337
|
+
raise "#{self.inspect} is already a full digital object"
|
338
|
+
end
|
339
|
+
self.init_with DigitalObject.find(self.class,self.pid)
|
340
|
+
end
|
341
|
+
|
292
342
|
# ** EXPERIMENTAL **
|
293
343
|
#
|
294
344
|
# This method can be used instead of ActiveFedora::Model::ClassMethods.load_instance.
|
@@ -313,9 +363,7 @@ module ActiveFedora
|
|
313
363
|
raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
|
314
364
|
end
|
315
365
|
|
316
|
-
|
317
|
-
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)]
|
318
|
-
obj = self.allocate.init_with(SolrDigitalObject.new(:pid=>solr_doc[SOLR_DOCUMENT_ID],:create_date=>create_date,:modified_date=>modified_date))
|
366
|
+
obj = self.allocate.init_with(SolrDigitalObject.new(solr_doc))
|
319
367
|
#set by default to load any dependent relationship objects from solr as well
|
320
368
|
#need to call rels_ext once so it exists when iterating over datastreams
|
321
369
|
obj.rels_ext
|
@@ -324,6 +372,7 @@ module ActiveFedora
|
|
324
372
|
ds.from_solr(solr_doc) if ds.kind_of?(ActiveFedora::MetadataDatastream) || ds.kind_of?(ActiveFedora::NokogiriDatastream) || ( ds.kind_of?(ActiveFedora::RelsExtDatastream))
|
325
373
|
end
|
326
374
|
end
|
375
|
+
obj.inner_object.freeze
|
327
376
|
obj
|
328
377
|
end
|
329
378
|
|