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
@@ -14,7 +14,7 @@ module ActiveFedora
14
14
  begin
15
15
  ActiveFedora::Base.find(pid).delete
16
16
  1
17
- rescue ActiveFedora::ObjectNotFoundError, (Rubydora::RecordNotFound rescue ActiveFedora::ObjectNotFoundError)
17
+ rescue ActiveFedora::ObjectNotFoundError
18
18
  logger.debug "The object #{pid} has already been deleted (or was never created)."
19
19
  0
20
20
  rescue Errno::ECONNREFUSED => e
@@ -13,8 +13,6 @@ module ActiveFedora
13
13
  end
14
14
  end
15
15
 
16
- extend Deprecation
17
- # include MetadataDatastreamHelper
18
16
  include OM::XML::Document
19
17
  include Solrizer::XML::TerminologyBasedSolrizer # this adds support for calling .to_solr
20
18
 
@@ -63,17 +61,13 @@ module ActiveFedora
63
61
  end
64
62
 
65
63
  def ng_xml=(new_xml)
66
- # before we set ng_xml, we load the datastream so we know if the new value differs.
67
- local_or_remote_content(true)
68
-
69
64
  case new_xml
70
65
  when Nokogiri::XML::Document
71
- self.content=new_xml.to_xml
66
+ @ng_xml = new_xml
72
67
  when Nokogiri::XML::Node
73
- ## Cast a fragment to a document
74
- self.content=new_xml.to_s
68
+ @ng_xml = Nokogiri::XML(new_xml.to_s) ## Cast a fragment to a document
75
69
  when String
76
- self.content=new_xml
70
+ @ng_xml = Nokogiri::XML::Document.parse(new_xml)
77
71
  else
78
72
  raise TypeError, "You passed a #{new_xml.class} into the ng_xml of the #{self.dsid} datastream. NokogiriDatastream.ng_xml= only accepts Nokogiri::XML::Document, Nokogiri::XML::Element, Nokogiri::XML::Node, or raw XML (String) as inputs."
79
73
  end
@@ -98,43 +92,21 @@ module ActiveFedora
98
92
  def metadata?
99
93
  true
100
94
  end
101
-
102
- def local_or_remote_content(ensure_fetch = true)
103
- @content = to_xml if ng_xml_changed? || autocreate?
104
- super
105
- end
106
95
 
107
- def autocreate?
108
- changed_attributes.has_key? :profile
96
+ def content
97
+ to_xml
109
98
  end
110
99
 
111
100
  def datastream_content
112
101
  @datastream_content ||= Nokogiri::XML(super).to_xml {|config| config.no_declaration}.strip
113
102
  end
114
103
 
115
- def content
116
- to_xml
117
- end
118
-
119
- def content=(new_content)
120
- if inline?
121
- # inline datastreams may be transformed by fedora 3, so we test for equivalence instead of equality
122
- if !EquivalentXml.equivalent?(datastream_content, new_content)
123
- ng_xml_will_change!
124
- @ng_xml = Nokogiri::XML::Document.parse(new_content)
125
- super(@ng_xml.to_s)
126
- end
127
- else
128
- if datastream_content != new_content
129
- ng_xml_will_change!
130
- @ng_xml = Nokogiri::XML::Document.parse(new_content)
131
- super(@ng_xml.to_s)
132
- end
133
- end
104
+ def content=(content)
105
+ @ng_xml = Nokogiri::XML::Document.parse(content)
134
106
  end
135
107
 
136
108
  def content_changed?
137
- return false if !xml_loaded
109
+ return false if new? and !xml_loaded
138
110
  super
139
111
  end
140
112
 
@@ -311,7 +283,7 @@ module ActiveFedora
311
283
  end
312
284
 
313
285
  def generate_solr_symbol(base, data_type)
314
- ActiveFedora::SolrService.solr_name(base.to_sym, data_type)
286
+ ActiveFedora::SolrService.solr_name(base.to_sym, type: data_type)
315
287
  end
316
288
 
317
289
  # ** Experimental **
@@ -422,23 +394,9 @@ module ActiveFedora
422
394
  end
423
395
  end
424
396
 
425
- # Deprecated methods left here for backwards compatibility
426
- def ensure_xml_loaded; end
427
- deprecation_deprecate :ensure_xml_loaded
428
-
429
- def serialize!
430
- end
431
-
432
397
  def xml_loaded
433
398
  instance_variable_defined? :@ng_xml
434
399
  end
435
-
436
- def reset_profile_attributes
437
- super
438
- if xml_loaded
439
- @datastream_content = Nokogiri::XML(to_xml).to_xml {|config| config.no_declaration}.strip
440
- end
441
- end
442
400
 
443
401
  end
444
402
  end
@@ -99,7 +99,7 @@ module ActiveFedora
99
99
  @fields.each do |field_key, field_info|
100
100
  things = send(field_key)
101
101
  if things
102
- field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
102
+ field_symbol = ActiveFedora::SolrService.solr_name(field_key, type: field_info[:type])
103
103
  things.val.each do |val|
104
104
  ::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val )
105
105
  end
@@ -25,7 +25,7 @@ module ActiveFedora
25
25
  opts[:qt] = solr_query_handler
26
26
  #set default sort to created date ascending
27
27
  unless opts[:sort].present?
28
- opts[:sort]=[ActiveFedora::SolrService.solr_name(:system_create,:date)+' asc']
28
+ opts[:sort]= default_sort_params
29
29
  end
30
30
 
31
31
  batch_size = opts.delete(:batch_size) || 1000
@@ -39,6 +39,10 @@ module ActiveFedora
39
39
  end while docs.has_next?
40
40
  end
41
41
 
42
+ def default_sort_params
43
+ [ActiveFedora::SolrService.solr_name(:system_create, type: :date)+' asc']
44
+ end
45
+
42
46
  # Yields the found ActiveFedora::Base object to the passed block
43
47
  #
44
48
  # @param [Hash] conditions the conditions for the solr search to match
@@ -80,7 +84,7 @@ module ActiveFedora
80
84
  def find_with_conditions(conditions, opts={})
81
85
  #set default sort to created date ascending
82
86
  unless opts.include?(:sort)
83
- opts[:sort]=[ActiveFedora::SolrService.solr_name(:system_create,:date)+' asc']
87
+ opts[:sort]=default_sort_params
84
88
  end
85
89
  SolrService.query(create_query(conditions), opts)
86
90
  end
@@ -125,7 +129,7 @@ module ActiveFedora
125
129
  unless value.nil?
126
130
  # if the key is a property name, turn it into a solr field
127
131
  if self.delegate_registry.include?(key.to_sym)
128
- key = ActiveFedora::SolrService.solr_name(key, :string, :searchable)
132
+ key = ActiveFedora::SolrService.solr_name(key, :searchable, type: :string)
129
133
  end
130
134
  if value.is_a? Array
131
135
  value.map { |val| "#{key}:#{quote_for_solr(val)}" }
@@ -145,7 +149,7 @@ module ActiveFedora
145
149
  # Return the solr clause that queries for this type of class
146
150
  def search_model_clause
147
151
  unless self == ActiveFedora::Base
148
- return ActiveFedora::SolrService.construct_query_for_rel(:has_model => self.to_class_uri)
152
+ return ActiveFedora::SolrService.construct_query_for_rel(:has_model, self.to_class_uri)
149
153
  end
150
154
  end
151
155
  end
@@ -24,13 +24,9 @@ module ActiveFedora
24
24
 
25
25
  @subject_block ||= lambda { |ds| RDF::URI.new("info:fedora/#{ds.pid}") }
26
26
  end
27
-
28
- def register_vocabularies(*vocabs)
29
- Deprecation.warn(RDFDatastream, "register_vocabularies no longer has any effect and will be removed in active-fedora 6.0", caller)
30
- end
31
-
32
27
  end
33
28
 
29
+ attr_accessor :loaded
34
30
  def metadata?
35
31
  true
36
32
  end
@@ -41,28 +37,32 @@ module ActiveFedora
41
37
  return "#{pre}__#{name}".to_sym
42
38
  end
43
39
 
44
- # Overriding so that one can call ds.content on an unsaved datastream and they will see the serialized format
45
40
  def content
46
41
  serialize
47
42
  end
48
43
 
49
44
  def content=(content)
45
+ self.loaded = true
50
46
  @graph = deserialize(content)
51
47
  end
52
48
 
53
49
  def content_changed?
54
- @content = serialize
50
+ return false if new? and !loaded
55
51
  super
56
52
  end
57
53
 
54
+ def changed?
55
+ super || content_changed?
56
+ end
57
+
58
+
58
59
  def to_solr(solr_doc = Hash.new) # :nodoc:
59
60
  fields.each do |field_key, field_info|
60
61
  values = get_values(rdf_subject, field_key)
61
- directive = Solrizer::Directive.new(field_info[:type], field_info[:behaviors])
62
62
  if values
63
63
  Array(values).each do |val|
64
64
  val = val.to_s if val.kind_of? RDF::URI
65
- self.class.create_and_insert_terms(prefix(field_key), val, directive, solr_doc)
65
+ self.class.create_and_insert_terms(prefix(field_key), val, field_info[:behaviors], solr_doc)
66
66
  end
67
67
  end
68
68
  end
@@ -90,6 +90,7 @@ module ActiveFedora
90
90
 
91
91
  def graph
92
92
  @graph ||= begin
93
+ self.loaded = true
93
94
  deserialize
94
95
  end
95
96
  end
@@ -188,7 +188,7 @@ module ActiveFedora
188
188
 
189
189
  def rdf_type(uri_or_string=nil)
190
190
  if uri_or_string
191
- uri = uri_or_string.kind_of?(RDF::URI) ? uri_or_string : RDF::URI.new(uri_or_string)
191
+ uri = RDF::URI.new(uri_or_string) unless uri_or_string.kind_of? RDF::URI
192
192
  self.config[:type] = {predicate: RDF.type}
193
193
  @rdf_type = uri
194
194
  end
@@ -3,10 +3,7 @@ module ActiveFedora
3
3
  class TermProxy
4
4
 
5
5
  attr_reader :graph, :subject, :predicate, :options
6
-
7
- delegate :class, :to_s, :==, :kind_of?, :each, :each_with_index, :map,
8
- :empty?, :as_json, :is_a?, :to_ary, :to_a, :inspect, :first,
9
- :last, :include?, :count, :size, :join, :[], :to => :values
6
+ delegate :class, :to_s, :==, :kind_of?, :each, :map, :empty?, :as_json, :is_a?, :to => :values
10
7
 
11
8
  # @param graph RDF::Graph
12
9
  # @param subject RDF::URI
@@ -54,7 +51,14 @@ module ActiveFedora
54
51
 
55
52
  values
56
53
  end
57
-
54
+
55
+ def method_missing(method, *args, &block)
56
+ if values.respond_to? method
57
+ values.send(method, *args, &block)
58
+ else
59
+ super
60
+ end
61
+ end
58
62
  end
59
63
  end
60
64
  end
@@ -94,8 +94,8 @@ module ActiveFedora
94
94
  options[:order] ||= sort if sort.present?
95
95
  end
96
96
 
97
+
97
98
  if options.present?
98
- options = args.first unless args.empty?
99
99
  options = {conditions: options}
100
100
  apply_finder_options(options).all
101
101
  else
@@ -1,4 +1,3 @@
1
- require 'solrizer/field_name_mapper'
2
1
  require 'uri'
3
2
  require 'rdf/rdfxml'
4
3
  require 'active_fedora/rdf_xml_writer'
@@ -6,7 +5,6 @@ require 'active_fedora/rdf_xml_writer'
6
5
  module ActiveFedora
7
6
  class RelsExtDatastream < Datastream
8
7
 
9
- include Solrizer::FieldNameMapper
10
8
  attr_accessor :model
11
9
 
12
10
  def self.default_attributes
@@ -42,11 +40,6 @@ module ActiveFedora
42
40
  model.relationships
43
41
  end
44
42
 
45
- def to_xml(fields_xml)
46
- ActiveSupport::Deprecation.warn("to_xml is deprecated, use to_rels_ext")
47
- to_rels_ext()
48
- end
49
-
50
43
  # Populate a RelsExtDatastream object based on the "datastream" content
51
44
  # Assumes that the datastream contains RDF XML from a Fedora RELS-EXT datastream
52
45
  # @param [ActiveFedora::Datastream] tmpl the Datastream object that you are populating
@@ -115,7 +108,7 @@ module ActiveFedora
115
108
  #
116
109
  # This is utilized by ActiveFedora::Base.load_instance_from_solr to load
117
110
  # the relationships hash using the Solr document passed in instead of from the RELS-EXT datastream
118
- # in Fedora. Utilizes solr_name method (provided by Solrizer::FieldNameMapper) to map solr key to
111
+ # in Fedora. Utilizes solr_name method (provided by Solrizer::FieldMapper) to map solr key to
119
112
  # relationship predicate.
120
113
  #
121
114
  # ====Warning
@@ -69,41 +69,6 @@ module ActiveFedora
69
69
  return false
70
70
  end
71
71
 
72
- # Create an RDF statement
73
- # @param uri a string represending the subject
74
- # @param predicate a predicate symbol
75
- # @param target an object to store
76
- def build_statement(uri, predicate, target, literal=false)
77
- ActiveSupport::Deprecation.warn("ActiveFedora::Base#build_statement has been deprecated.")
78
- raise "Not allowed anymore" if uri == :self
79
- target = target.internal_uri if target.respond_to? :internal_uri
80
- subject = RDF::URI.new(uri) #TODO cache
81
- unless literal or target.is_a? RDF::Resource
82
- begin
83
- target_uri = (target.is_a? URI) ? target : URI.parse(target)
84
- if target_uri.scheme.nil?
85
- raise ArgumentError, "Invalid target \"#{target}\". Must have namespace."
86
- end
87
- if target_uri.to_s =~ /\A[\w\-]+:[\w\-]+\Z/
88
- raise ArgumentError, "Invalid target \"#{target}\". Target should be a complete URI, and not a pid."
89
- end
90
- rescue URI::InvalidURIError
91
- raise ArgumentError, "Invalid target \"#{target}\". Target must be specified as a literal, or be a valid URI."
92
- end
93
- end
94
- if literal
95
- object = RDF::Literal.new(target)
96
- elsif target.is_a? RDF::Resource
97
- object = target
98
- else
99
- object = RDF::URI.new(target)
100
- end
101
- RDF::Statement.new(subject, find_graph_predicate(predicate), object)
102
-
103
- end
104
-
105
-
106
-
107
72
  #
108
73
  # Remove a Rels-Ext relationship from the Object.
109
74
  # @param predicate
@@ -85,7 +85,7 @@ module ActiveFedora
85
85
  next if field_key == :location ## FIXME HYDRA-825
86
86
  things = send(field_key)
87
87
  if things
88
- field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
88
+ field_symbol = ActiveFedora::SolrService.solr_name(field_key, type: field_info[:type])
89
89
  things.val.each do |val|
90
90
  ::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val.to_s )
91
91
  end
@@ -3,7 +3,6 @@ require 'rsolr'
3
3
  module ActiveFedora
4
4
  class SolrService
5
5
 
6
- include Solrizer::FieldNameMapper
7
6
  include Loggable
8
7
 
9
8
  attr_reader :conn
@@ -67,18 +66,17 @@ module ActiveFedora
67
66
  query = "id:NEVER_USE_THIS_ID" if query.empty? || query == "id:"
68
67
  return query
69
68
  end
69
+
70
+ def self.solr_name(*args)
71
+ Solrizer.default_field_mapper.solr_name(*args)
72
+ end
70
73
 
71
74
  def self.escape_uri_for_query(uri)
72
75
  return uri.gsub(/(:)/, '\\:').gsub(/(\/)/, '\\/')
73
76
  end
74
77
 
75
- # Create a query with a clause for each key, value
76
- # @param [Hash] args key is the predicate, value is the target_uri
77
- def self.construct_query_for_rel(args)
78
- clauses = args.map do |predicate, target_uri|
79
- "#{solr_name(predicate, :symbol)}:#{escape_uri_for_query(target_uri)}"
80
- end
81
- clauses.join(" AND ")
78
+ def self.construct_query_for_rel(predicate, target_uri)
79
+ "#{solr_name(predicate, :symbol)}:#{escape_uri_for_query(target_uri)}"
82
80
  end
83
81
 
84
82
  def self.query(query, args={})
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "5.7.1"
2
+ VERSION = "6.0.0.pre1"
3
3
  end
@@ -14,7 +14,7 @@ namespace :active_fedora do
14
14
 
15
15
  YARD::Rake::YardocTask.new(:doc) do |yt|
16
16
  yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
17
- [ '-', File.join(project_root, 'README.textile'), File.join(project_root,'CONSOLE_GETTING_STARTED.textile'), File.join(project_root,'NOKOGIRI_DATASTREAMS.textile') ]
17
+ [ File.join(project_root, 'README.textile'),'-', File.join(project_root,'CONSOLE_GETTING_STARTED.textile'),'-', File.join(project_root,'NOKOGIRI_DATASTREAMS.textile') ]
18
18
  yt.options = ['--output-dir', doc_destination, '--readme', 'README.textile']
19
19
  end
20
20
  rescue LoadError
@@ -36,6 +36,13 @@ require 'rspec/core/rake_task'
36
36
  spec.rcov = true
37
37
  end
38
38
 
39
+ task :clean_jetty do
40
+ Dir.chdir("./jetty")
41
+ system("git clean -f -d")
42
+ system("git checkout .")
43
+ Dir.chdir("..")
44
+ end
45
+
39
46
  desc "Loads or refreshes the fixtures needed to run the tests"
40
47
  task :fixtures => :environment do
41
48
  ENV["pid"] = "hydrangea:fixture_mods_article1"
@@ -53,6 +60,7 @@ require 'rspec/core/rake_task'
53
60
 
54
61
  desc "Copies the default SOLR config for the bundled Testing Server"
55
62
  task :configure_jetty do
63
+ Rake::Task["active_fedora:clean_jetty"].invoke
56
64
  FileList['solr/conf/*'].each do |f|
57
65
  cp("#{f}", 'jetty/solr/development-core/conf/', :verbose => true)
58
66
  cp("#{f}", 'jetty/solr/test-core/conf/', :verbose => true)
@@ -60,8 +68,8 @@ require 'rspec/core/rake_task'
60
68
  end
61
69
 
62
70
 
63
- desc "CI build"
64
- task :ci do
71
+ desc "Hudson build"
72
+ task :hudson do
65
73
  ENV['environment'] = "test"
66
74
  Rake::Task["active_fedora:configure_jetty"].invoke
67
75
  jetty_params = Jettywrapper.load_config