active-fedora 5.7.1 → 6.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/.gitmodules +1 -1
  2. data/Gemfile +2 -1
  3. data/History.txt +0 -14
  4. data/Rakefile +1 -2
  5. data/active-fedora.gemspec +2 -2
  6. data/lib/active_fedora.rb +1 -16
  7. data/lib/active_fedora/associations.rb +8 -11
  8. data/lib/active_fedora/associations/association_collection.rb +2 -4
  9. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +3 -12
  10. data/lib/active_fedora/associations/has_many_association.rb +0 -4
  11. data/lib/active_fedora/base.rb +6 -6
  12. data/lib/active_fedora/config.rb +0 -7
  13. data/lib/active_fedora/datastream.rb +0 -37
  14. data/lib/active_fedora/datastream_collections.rb +0 -10
  15. data/lib/active_fedora/datastreams.rb +0 -17
  16. data/lib/active_fedora/digital_object.rb +1 -1
  17. data/lib/active_fedora/file_configurator.rb +0 -22
  18. data/lib/active_fedora/fixture_loader.rb +1 -1
  19. data/lib/active_fedora/nokogiri_datastream.rb +9 -51
  20. data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
  21. data/lib/active_fedora/querying.rb +8 -4
  22. data/lib/active_fedora/rdf_datastream.rb +10 -9
  23. data/lib/active_fedora/rdf_node.rb +1 -1
  24. data/lib/active_fedora/rdf_node/term_proxy.rb +9 -5
  25. data/lib/active_fedora/relation.rb +1 -1
  26. data/lib/active_fedora/rels_ext_datastream.rb +1 -8
  27. data/lib/active_fedora/semantic_node.rb +0 -35
  28. data/lib/active_fedora/simple_datastream.rb +1 -1
  29. data/lib/active_fedora/solr_service.rb +6 -8
  30. data/lib/active_fedora/version.rb +1 -1
  31. data/lib/tasks/active_fedora_dev.rake +11 -3
  32. data/solr/conf/schema.xml +10 -1
  33. data/spec/integration/base_spec.rb +2 -347
  34. data/spec/integration/complex_rdf_datastream_spec.rb +1 -1
  35. data/spec/integration/full_featured_model_spec.rb +1 -9
  36. data/spec/integration/ntriples_datastream_spec.rb +4 -4
  37. data/spec/integration/om_datastream_spec.rb +2 -1
  38. data/spec/integration/rels_ext_datastream_spec.rb +1 -89
  39. data/spec/integration/scoped_query_spec.rb +4 -4
  40. data/spec/samples/hydra-mods_article_datastream.rb +2 -2
  41. data/spec/spec_helper.rb +3 -0
  42. data/spec/unit/base_spec.rb +7 -81
  43. data/spec/unit/datastream_spec.rb +0 -25
  44. data/spec/unit/has_many_collection_spec.rb +2 -27
  45. data/spec/unit/ntriples_datastream_spec.rb +28 -39
  46. data/spec/unit/om_datastream_spec.rb +13 -13
  47. data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
  48. data/spec/unit/query_spec.rb +1 -24
  49. data/spec/unit/semantic_node_spec.rb +0 -2
  50. data/spec/unit/simple_datastream_spec.rb +2 -2
  51. data/spec/unit/solr_config_options_spec.rb +1 -1
  52. metadata +76 -57
  53. checksums.yaml +0 -7
  54. data/.travis.yml +0 -8
  55. data/lib/active_fedora/file_management.rb +0 -81
  56. data/lib/active_fedora/metadata_datastream_helper.rb +0 -43
  57. data/lib/active_fedora/named_relationships.rb +0 -99
  58. data/lib/active_fedora/relationships.rb +0 -663
  59. data/spec/integration/base_file_management_spec.rb +0 -24
  60. data/spec/integration/has_many_associations_spec.rb +0 -64
  61. data/spec/integration/metadata_datastream_helper_spec.rb +0 -100
  62. data/spec/integration/semantic_node_spec.rb +0 -457
  63. data/spec/unit/base_file_management_spec.rb +0 -95
  64. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +0 -59
  65. data/spec/unit/relationships_spec.rb +0 -871
@@ -1,4 +1,4 @@
1
1
  [submodule "jetty"]
2
2
  path = jetty
3
3
  url = git://github.com/projecthydra/hydra-jetty.git
4
- ignore = dirty
4
+ ignore = all
data/Gemfile CHANGED
@@ -3,8 +3,9 @@ source "http://rubygems.org"
3
3
  # Bundler will rely on active-fedora.gemspec for dependency information.
4
4
 
5
5
  gemspec
6
+
6
7
  group :development, :test do
7
- gem 'simplecov', :platform => [:mri_19, :mri_20]
8
+ gem 'simplecov', :platform => :mri_19
8
9
  gem 'simplecov-rcov', :platform => :mri_19
9
10
  end
10
11
 
@@ -1,17 +1,3 @@
1
- 5.6.1
2
- Fixed delegating enumerable methods (join, [], each_with_index, to_a, etc) on an RdfNode::TermProxy
3
-
4
- 5.6.0
5
- Upgrade to rubydora 1.3.0, which prevents unnecessary loading of datastream content.
6
- #35 fix passing :sort argument to ActiveFedora::Base#find
7
- Better support for ruby 2.0 (delegating inspect within RdfNode::TermProxy)
8
-
9
- 5.5.2
10
- #25 When multiple has_many relationships share a predicate, the solr_query should use class_name to distinguish the sets.
11
-
12
- 5.5.1
13
- #34 Allow passing RDF::URI to rdf_type
14
-
15
1
  5.5.0
16
2
  Added support for complex rdf structures.
17
3
  Changed RdfDatastream to_solr so that it uses the dsid as the solr prefix, not the datastream class name
data/Rakefile CHANGED
@@ -11,9 +11,8 @@ load "lib/tasks/active_fedora_dev.rake" if defined?(Rake)
11
11
 
12
12
  CLEAN.include %w[**/.DS_Store tmp *.log *.orig *.tmp **/*~]
13
13
 
14
- task :ci => ['jetty:clean', 'active_fedora:ci']
15
14
  task :spec => ['active_fedora:rspec']
16
15
  task :rcov => ['active_fedora:rcov']
17
16
 
18
17
 
19
- task :default => [:ci]
18
+ task :default => [:spec]
@@ -18,12 +18,12 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency('rsolr')
19
19
  s.add_dependency('om', '~> 1.8.0')
20
20
  s.add_dependency('nom-xml', '>=0.5.1')
21
- s.add_dependency('solrizer', '~>2.1')
21
+ s.add_dependency('solrizer', '~>3.0.0.pre1')
22
22
  s.add_dependency("activeresource", '>= 3.0.0')
23
23
  s.add_dependency("activesupport", '>= 3.0.0')
24
24
  s.add_dependency("builder", '~> 3.0.0')
25
25
  s.add_dependency("mediashelf-loggable")
26
- s.add_dependency("rubydora", '~>1.6')
26
+ s.add_dependency("rubydora", '~>1.2')
27
27
  s.add_dependency("rdf")
28
28
  s.add_dependency("rdf-rdfxml", '~>0.3.8')
29
29
  s.add_dependency("deprecation")
@@ -8,7 +8,7 @@ require 'active_support/core_ext/object'
8
8
  require 'active_support/core_ext/hash/indifferent_access'
9
9
  require 'rdf'
10
10
 
11
- SOLR_DOCUMENT_ID = ActiveFedora::FileConfigurator.id_field unless defined?(SOLR_DOCUMENT_ID)
11
+ SOLR_DOCUMENT_ID = Solrizer.default_field_mapper.id_field unless defined?(SOLR_DOCUMENT_ID)
12
12
  ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
13
13
 
14
14
  module ActiveFedora #:nodoc:
@@ -32,8 +32,6 @@ module ActiveFedora #:nodoc:
32
32
  autoload :Config
33
33
  autoload :FileConfigurator
34
34
  autoload :Reflection
35
- autoload :Relationships
36
- autoload :FileManagement
37
35
  autoload :RelationshipGraph
38
36
  autoload :Datastream
39
37
  autoload :DatastreamHash
@@ -43,7 +41,6 @@ module ActiveFedora #:nodoc:
43
41
  autoload :UnsavedDigitalObject
44
42
  autoload :SolrDigitalObject
45
43
  autoload :Model
46
- autoload :MetadataDatastreamHelper
47
44
  autoload :NokogiriDatastream
48
45
  autoload :NomDatastream
49
46
  autoload :NtriplesRDFDatastream
@@ -66,7 +63,6 @@ module ActiveFedora #:nodoc:
66
63
  autoload :FixtureLoader
67
64
  autoload :FixtureExporter
68
65
  autoload :DatastreamCollections
69
- autoload :NamedRelationships
70
66
  autoload :Predicates
71
67
  autoload :Validations
72
68
  end
@@ -129,21 +125,10 @@ module ActiveFedora #:nodoc:
129
125
  end
130
126
  end
131
127
 
132
- def self.config_for_environment
133
- ActiveSupport::Deprecation.warn("config_for_environment has been deprecated use `config' instead")
134
- config
135
- end
136
-
137
128
  def self.solr
138
129
  ActiveFedora::SolrService.instance
139
130
  end
140
131
 
141
- def self.fedora
142
- ActiveSupport::Deprecation.warn("ActiveFedora.fedora() is deprecated and will be removed in the next release use ActiveFedora::Base.connection_for_pid(pid) instead")
143
-
144
- ActiveFedora::Base.connection_for_pid('0')
145
- end
146
-
147
132
  def self.predicate_config
148
133
  configurator.predicate_config
149
134
  end
@@ -12,27 +12,24 @@ module ActiveFedora
12
12
 
13
13
  autoload :AssociationCollection, 'active_fedora/associations/association_collection'
14
14
  autoload :AssociationProxy, 'active_fedora/associations/association_proxy'
15
-
16
- # Clears out the association cache.
17
- def clear_association_cache #:nodoc:
18
- @association_cache.clear if persisted?
19
- end
20
-
21
- # :nodoc:
22
- attr_reader :association_cache
23
-
24
15
  private
25
16
 
26
17
  # Returns the specified association instance if it responds to :loaded?, nil otherwise.
27
18
  def association_instance_get(name)
28
- @association_cache[name.to_sym]
19
+ ivar = "@#{name}"
20
+ if instance_variable_defined?(ivar)
21
+ association = instance_variable_get(ivar)
22
+ association if association.respond_to?(:loaded?)
23
+ end
29
24
  end
30
25
 
31
26
  # Set the specified association instance.
32
27
  def association_instance_set(name, association)
33
- @association_cache[name] = association
28
+ instance_variable_set("@#{name}", association)
34
29
  end
35
30
 
31
+
32
+
36
33
  module ClassMethods
37
34
 
38
35
  def has_many(association_id, options={})
@@ -74,7 +74,7 @@ module ActiveFedora
74
74
  flatten_deeper(records).each do |record|
75
75
  raise_on_type_mismatch(record)
76
76
  add_record_to_target_with_callbacks(record) do |r|
77
- result &&= insert_record(record)
77
+ result &&= insert_record(record) unless @owner.new_record?
78
78
  end
79
79
  end
80
80
 
@@ -180,9 +180,7 @@ module ActiveFedora
180
180
  end
181
181
 
182
182
  def construct_query
183
- clauses = {@reflection.options[:property] => @owner.internal_uri}
184
- clauses[:has_model] = @reflection.class_name.constantize.to_class_uri if @reflection.class_name && @reflection.class_name != 'ActiveFedora::Base'
185
- @counter_query = @finder_query = ActiveFedora::SolrService.construct_query_for_rel(clauses)
183
+ @counter_query = @finder_query = ActiveFedora::SolrService.construct_query_for_rel(@reflection.options[:property], @owner.internal_uri)
186
184
  end
187
185
 
188
186
 
@@ -31,25 +31,16 @@ module ActiveFedora
31
31
 
32
32
  ### TODO save relationship
33
33
  @owner.add_relationship(@reflection.options[:property], record)
34
-
35
- if @owner.new_record? and @reflection.options[:inverse_of]
36
- logger.warn("has_and_belongs_to_many #{@reflection.inspect} is cowardly refusing to insert the inverse relationship into #{record}, because #{@owner} is not persisted yet.")
37
- elsif @reflection.options[:inverse_of]
34
+ if (@reflection.options[:inverse_of])
38
35
  record.add_relationship(@reflection.options[:inverse_of], @owner)
39
- record.save
40
36
  end
41
-
37
+ record.save
42
38
  return true
43
39
  end
44
40
 
45
41
  def delete_records(records)
46
42
  records.each do |r|
47
- @owner.remove_relationship(@reflection.options[:property], r)
48
-
49
- if (@reflection.options[:inverse_of])
50
- r.remove_relationship(@reflection.options[:inverse_of], @owner)
51
- r.save
52
- end
43
+ r.remove_relationship(@reflection.options[:property], @owner)
53
44
  end
54
45
  end
55
46
  end
@@ -31,10 +31,6 @@ module ActiveFedora
31
31
  end
32
32
 
33
33
  def insert_record(record, force = false, validate = true)
34
- if @owner.new_record?
35
- logger.warn("has_many #{@reflection.inspect} is cowardly refusing to insert a relationship into #{record}, because #{@owner} is not persisted yet.")
36
- return true
37
- end
38
34
  set_belongs_to_association_for(record)
39
35
  #force ? record.save! : record.save(:validate => validate)
40
36
  record.save
@@ -27,7 +27,7 @@ module ActiveFedora
27
27
 
28
28
  class_attribute :fedora_connection, :profile_solr_name
29
29
  self.fedora_connection = {}
30
- self.profile_solr_name = ActiveFedora::SolrService.solr_name("object_profile", :string, :displayable)
30
+ self.profile_solr_name = ActiveFedora::SolrService.solr_name("object_profile", :displayable)
31
31
 
32
32
 
33
33
  def method_missing(name, *args)
@@ -68,7 +68,6 @@ module ActiveFedora
68
68
  # the given namespace.
69
69
  def initialize(attrs = nil)
70
70
  attrs = {} if attrs.nil?
71
- @association_cache = {}
72
71
  attributes = attrs.dup
73
72
  @inner_object = UnsavedDigitalObject.new(self.class, attributes.delete(:namespace), attributes.delete(:pid))
74
73
  self.relationships_loaded = true
@@ -81,7 +80,6 @@ module ActiveFedora
81
80
 
82
81
  # Reloads the object from Fedora.
83
82
  def reload
84
- clear_association_cache
85
83
  init_with(self.class.find(self.pid).inner_object)
86
84
  end
87
85
 
@@ -96,7 +94,6 @@ module ActiveFedora
96
94
  # post.init_with(DigitalObject.find(pid))
97
95
  # post.properties.title # => 'hello world'
98
96
  def init_with(inner_obj)
99
- @association_cache = {}
100
97
  @inner_object = inner_obj
101
98
  unless @inner_object.is_a? SolrDigitalObject
102
99
  @inner_object.original_class = self.class
@@ -307,7 +304,7 @@ module ActiveFedora
307
304
  c_time = Time.parse(c_time) unless c_time.is_a?(Time)
308
305
  m_time = modified_date
309
306
  m_time = Time.parse(m_time) unless m_time.is_a?(Time)
310
- solr_doc.merge!(SOLR_DOCUMENT_ID.to_sym => pid, ActiveFedora::SolrService.solr_name(:system_create, :date) => c_time.utc.xmlschema, ActiveFedora::SolrService.solr_name(:system_modified, :date) => m_time.utc.xmlschema, ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol) => self.class.inspect)
307
+ solr_doc.merge!(SOLR_DOCUMENT_ID.to_sym => pid, ActiveFedora::SolrService.solr_name(:system_create, type: :date) => c_time.utc.xmlschema, ActiveFedora::SolrService.solr_name(:system_modified, type: :date) => m_time.utc.xmlschema, ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol) => self.class.inspect)
311
308
  solrize_profile(solr_doc)
312
309
  end
313
310
  datastreams.each_value do |ds|
@@ -317,6 +314,10 @@ module ActiveFedora
317
314
  solr_doc
318
315
  end
319
316
 
317
+ def solr_name(*args)
318
+ ActiveFedora::SolrService.solr_name(*args)
319
+ end
320
+
320
321
  def solrize_profile(solr_doc = Hash.new) # :nodoc:
321
322
  profile_hash = { 'datastreams' => {} }
322
323
  if inner_object.respond_to? :profile
@@ -443,7 +444,6 @@ module ActiveFedora
443
444
  include Attributes
444
445
  include ActiveFedora::Persistence
445
446
  include Model
446
- include Solrizer::FieldNameMapper
447
447
  include Loggable
448
448
  include ActiveModel::Conversion
449
449
  include Validations
@@ -21,13 +21,6 @@ module ActiveFedora
21
21
 
22
22
  def init_single(vals)
23
23
  @credentials = vals.symbolize_keys
24
- if @credentials[:url] && !@credentials[:user]
25
- ActiveSupport::Deprecation.warn("Configuring fedora with \":url\" without :user and :password is no longer supported.")
26
- u = URI.parse @credentials[:url]
27
- @credentials[:user] = u.user
28
- @credentials[:password] = u.password
29
- @credentials[:url] = "#{u.scheme}://#{u.host}:#{u.port}#{u.path}"
30
- end
31
24
  unless @credentials.has_key?(:user) && @credentials.has_key?(:password) && @credentials.has_key?(:url)
32
25
  raise ActiveFedora::ConfigurationError, "Fedora configuration must provide :user, :password and :url."
33
26
  end
@@ -2,7 +2,6 @@ module ActiveFedora
2
2
 
3
3
  #This class represents a Fedora datastream
4
4
  class Datastream < Rubydora::Datastream
5
- extend Deprecation
6
5
  attr_writer :digital_object
7
6
  attr_accessor :last_modified
8
7
 
@@ -22,40 +21,12 @@ module ActiveFedora
22
21
  dsid.gsub(/\./, '%2e')
23
22
  end
24
23
 
25
- # Test whether this datastream been modified since it was last saved
26
- # Deprecated
27
- def dirty?
28
- changed?
29
- end
30
- deprecation_deprecate :dirty?
31
-
32
24
  # @abstract Override this in your concrete datastream class.
33
25
  # @return [boolean] does this datastream contain metadata (not file data)
34
26
  def metadata?
35
27
  false
36
28
  end
37
29
 
38
- # Deprecated
39
- def dirty
40
- changed?
41
- end
42
- deprecation_deprecate :dirty
43
-
44
- # Deprecated
45
- def dirty=(value)
46
- if value
47
- content_will_change! # an innocent hack to pretend something has changed
48
- else
49
- changed_attributes.clear
50
- end
51
- end
52
- deprecation_deprecate :dirty=
53
-
54
- def new_object?
55
- new?
56
- end
57
- deprecation_deprecate :new_object?
58
-
59
30
  def validate_content_present
60
31
  has_content?
61
32
  end
@@ -73,14 +44,6 @@ module ActiveFedora
73
44
  # serializes any changed data into the content field
74
45
  def serialize!
75
46
  end
76
- # Populate a Datastream object based on the "datastream" node from a FOXML file
77
- # @param [ActiveFedora::Datastream] tmpl the Datastream object that you are building
78
- # @param [Nokogiri::XML::Node] node the "foxml:datastream" node from a FOXML file
79
- def self.from_xml(tmpl, node)
80
- Deprecation.deprecated_method_warning(self, :from_xml)
81
- tmpl.controlGroup= node['CONTROL_GROUP']
82
- tmpl
83
- end
84
47
 
85
48
  def solrize_profile # :nodoc:
86
49
  profile_hash = {}
@@ -323,15 +323,5 @@ module ActiveFedora
323
323
  @named_datastreams_desc ||= self.class.class_named_datastreams_desc
324
324
  end
325
325
 
326
- # ** EXPERIMENTAL **
327
- #
328
- # Get class variable hash that stores has_datastream arguments.
329
- # It is used to initialize the value returned by public named_datastreams_desc method
330
- # Deprecated
331
- def named_datastreams_desc_from_class
332
- logger.warn "named_datastreams_desc_from_class is deprecated and will be removed in the next version"
333
- self.class.class_named_datastreams_desc
334
- end
335
-
336
326
  end
337
327
  end
@@ -1,7 +1,6 @@
1
1
  module ActiveFedora
2
2
  module Datastreams
3
3
  extend ActiveSupport::Concern
4
- extend Deprecation
5
4
 
6
5
  included do
7
6
  class_attribute :ds_specs
@@ -188,22 +187,6 @@ module ActiveFedora
188
187
  ds
189
188
  end
190
189
 
191
- # This method provides validation of proper options for control_group 'E' and 'R' and builds an attribute hash to be merged back into ds.attributes prior to saving
192
- #
193
- # @param [Object] ds The datastream
194
- # @param [Object] ds_config hash of options which may contain :disseminator and :url
195
- def additional_attributes_for_external_and_redirect_control_groups(ds,ds_config)
196
- if ds.controlGroup=='E'
197
- if !ds_config[:disseminator].present? && ds_config[:url].present?
198
- ds.dsLocation= ds_config[:url]
199
- end
200
- elsif ds.controlGroup=='R'
201
- ds.dsLocation= ds_config[:url]
202
- end
203
- end
204
- deprecation_deprecate :additional_attributes_for_external_and_redirect_control_groups
205
-
206
-
207
190
  module ClassMethods
208
191
  #This method is used to specify the details of a datastream.
209
192
  # You can pass the name as the first argument and a hash of options as the second argument
@@ -35,7 +35,7 @@ module ActiveFedora
35
35
  obj = Deprecation.silence(Rubydora::DigitalObject) do
36
36
  begin
37
37
  super(pid, conn)
38
- rescue Rubydora::FedoraInvalidRequest, (Rubydora::RecordNotFound rescue nil)
38
+ rescue Rubydora::FedoraInvalidRequest => e
39
39
  # PID is nil
40
40
  raise ActiveFedora::ObjectNotFoundError, "Unable to find '#{pid}' in fedora. See logger for details."
41
41
  end
@@ -46,7 +46,6 @@ module ActiveFedora
46
46
  # url: http://127.0.0.1:8983/fedora2
47
47
  #
48
48
 
49
- include Solrizer::FieldNameMapper
50
49
  attr_accessor :config_env
51
50
  attr_reader :config_options, :fedora_config_path, :solr_config_path
52
51
 
@@ -73,12 +72,6 @@ module ActiveFedora
73
72
  @solr_config
74
73
  end
75
74
 
76
- def config_reload!
77
- ActiveSupport::Deprecation.warn("config_reload! is not supported")
78
- reset!
79
- load_configs
80
- end
81
-
82
75
  def path
83
76
  get_config_path(:fedora)
84
77
  end
@@ -101,7 +94,6 @@ module ActiveFedora
101
94
 
102
95
  load_fedora_config
103
96
  load_solr_config
104
- load_solrizer_config
105
97
  @config_loaded = true
106
98
  end
107
99
 
@@ -150,20 +142,6 @@ module ActiveFedora
150
142
  @solr_config = {:url=> get_solr_url(config[ActiveFedora.environment.to_sym].symbolize_keys)}
151
143
  end
152
144
 
153
- def load_solrizer_config
154
- if solrizer_config_path
155
- logger.warn "loading_solrizer_config at #{solrizer_config_path}, this overwrites the default field mapper class."
156
- ActiveFedora::SolrService.load_mappings
157
- end
158
- end
159
-
160
- def solrizer_config_path
161
- begin
162
- get_config_path('solr_mappings')
163
- rescue ActiveFedora::ConfigurationError
164
- end
165
- end
166
-
167
145
  # Given the solr_config that's been loaded for this environment,
168
146
  # determine which solr url to use
169
147
  def get_solr_url(solr_config)