active-fedora 1.2.9 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,9 +6,10 @@ gem 'mime-types', '>= 1.16'
6
6
  gem 'multipart-post'
7
7
  gem 'nokogiri'
8
8
  gem 'om', '>= 1.0'
9
- gem 'solrizer', '>=0.3.0'
9
+ gem 'solrizer', '>=1.0.0', '<2.0.0'
10
10
  gem 'activeresource', '<3.0.0'
11
11
  gem 'mediashelf-loggable'
12
+ gem "equivalent-xml"
12
13
 
13
14
  group :development, :test do
14
15
  gem "jeweler"
@@ -1,11 +1,13 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activeresource (2.3.10)
5
- activesupport (= 2.3.10)
6
- activesupport (2.3.10)
4
+ activeresource (2.3.11)
5
+ activesupport (= 2.3.11)
6
+ activesupport (2.3.11)
7
7
  columnize (0.3.2)
8
- facets (2.9.0)
8
+ equivalent-xml (0.1.6)
9
+ nokogiri
10
+ facets (2.9.1)
9
11
  git (1.2.5)
10
12
  jeweler (1.5.2)
11
13
  bundler (~> 1.0.0)
@@ -14,8 +16,7 @@ GEM
14
16
  linecache (0.43)
15
17
  mediashelf-loggable (0.4.0)
16
18
  mime-types (1.16)
17
- mocha (0.9.10)
18
- rake
19
+ mocha (0.9.12)
19
20
  multipart-post (1.1.0)
20
21
  nokogiri (1.4.4)
21
22
  om (1.0.2)
@@ -31,12 +32,15 @@ GEM
31
32
  ruby-debug-base (0.10.4)
32
33
  linecache (>= 0.3)
33
34
  solr-ruby (0.0.8)
34
- solrizer (0.3.2)
35
+ solrizer (1.0.0)
35
36
  mediashelf-loggable
37
+ mediashelf-loggable
38
+ nokogiri
36
39
  nokogiri
37
40
  nokogiri
38
41
  om
39
- solr-ruby
42
+ om (>= 1.0.0)
43
+ xml-simple
40
44
  xml-simple (1.0.14)
41
45
 
42
46
  PLATFORMS
@@ -44,6 +48,7 @@ PLATFORMS
44
48
 
45
49
  DEPENDENCIES
46
50
  activeresource (< 3.0.0)
51
+ equivalent-xml
47
52
  jeweler
48
53
  mediashelf-loggable
49
54
  mime-types (>= 1.16)
@@ -54,5 +59,5 @@ DEPENDENCIES
54
59
  rspec (< 2.0.0)
55
60
  ruby-debug
56
61
  solr-ruby (>= 0.0.6)
57
- solrizer (>= 0.3.0)
62
+ solrizer (>= 1.0.0, < 2.0.0)
58
63
  xml-simple (>= 1.0.12)
@@ -1,3 +1,10 @@
1
+ 2.0.0
2
+
3
+ Upgraded to use solrizer 1.0.0, which uses RSolr instead of the outdated ruby-solr:
4
+
5
+ All solrize and extract methods now accept and return a _Hash_ rather than a Solr::Document
6
+ As part of this switch, *all field names are stored as Strings, not Symbols*. If you previously accessed something as solr_doc[:title_t], now you need to access it as solr_doc["title_t"]
7
+
1
8
  1.2.9
2
9
  Minor: Fixed Gemfile to require activeresource <3.0.0 NOT >3.0.0
3
10
 
@@ -0,0 +1,60 @@
1
+ h1. Using OM-based NokogiriDatastreams
2
+
3
+ h2. Setup
4
+
5
+ This tutorial assumes that you've run script/console from the root of Hydrangea and have imported Hydrangea's fixtures.
6
+
7
+ The HydrangeaArticle model definition is located at https://github.com/projecthydra/hydrangea/blob/master/vendor/plugins/hydrangea_articles/app/models/hydrangea_article.rb
8
+
9
+ Look in the "Hydra::ModsArticle":https://github.com/projecthydra/hydrangea/blob/master/vendor/plugins/hydra_repository/lib/hydra/mods_article.rb and "Hydra::RightsMetadata":https://github.com/projecthydra/hydrangea/blob/master/vendor/plugins/hydra_repository/lib/hydra/rights_metadata.rb" datastream definitions to see the OM Terminologies they define.
10
+
11
+ h2. The Tour
12
+
13
+ First, create some objects to play around with.
14
+
15
+ <pre>
16
+ ha = HydrangeaArticle.new
17
+ fixture_article = HydrangeaArticle.load_instance("hydrangea:fixture_mods_article1")
18
+ <pre>
19
+
20
+ <pre>
21
+ ha.datastreams.keys
22
+ fixture_article.datastreams.keys
23
+ </pre>
24
+
25
+ Each datastream is associated with a class that is aware of its content. These classes are specified in the model.
26
+
27
+ <pre>
28
+ ha.datastreams["rightsMetadata"].class
29
+ ha.datastreams["descMetadata"].class
30
+ <pre>
31
+
32
+ You can retrieve the xml from the object as xml (string) using to_xml, or you can access it as a Nokogiri::XML::Document using .ng_xml
33
+
34
+ <pre>
35
+ ha.datastreams["rightsMetadata"].to_xml
36
+ ha.datastreams["rightsMetadata"].ng_xml.class
37
+ </pre>
38
+
39
+ FYI, an OM terminology is attached to the datastream's class. OM's convenience methods use the terminology to look up nodes and values for you.
40
+
41
+ <pre>
42
+ ha.datastreams["rightsMetadata"].class.terminology
43
+ </pre>
44
+
45
+ The ModsArticle Terminology lets you retrieve values from the descMetadata datastream's MODS content.
46
+
47
+ <pre>
48
+ fixture_mods_ds = fixture_article.datastreams["descMetadata"]
49
+ fixture_mods_ds.term_values(:person, :first_name)
50
+ fixture_mods_ds.term_values(:person, :last_name)
51
+ </pre>
52
+
53
+ You can use OM's find_by_terms method to retrieve xml nodes from the datastream. It returns Nokogiri::XML::Node objects.
54
+
55
+ <pre>
56
+ fixture_mods_ds.find_by_terms(:person)
57
+ fixture_mods_ds.find_by_terms(:person).length
58
+ fixture_mods_ds.find_by_terms(:person).each {|n| puts n.to_xml}
59
+ </pre>
60
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.9
1
+ 2.0.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active-fedora}
8
- s.version = "1.2.9"
8
+ s.version = "2.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Zumwalt", "McClain Looney"]
12
- s.date = %q{2011-01-31}
12
+ s.date = %q{2011-03-03}
13
13
  s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
14
14
  s.email = %q{matt.zumwalt@yourmediashelf.com}
15
15
  s.extra_rdoc_files = [
@@ -178,6 +178,7 @@ Gem::Specification.new do |s|
178
178
  "PostInstall.txt",
179
179
  "README.textile",
180
180
  "Rakefile",
181
+ "USING_OM_DATASTREAMS.textile",
181
182
  "VERSION",
182
183
  "active-fedora.gemspec",
183
184
  "config/fedora.yml",
@@ -351,9 +352,10 @@ Gem::Specification.new do |s|
351
352
  s.add_runtime_dependency(%q<multipart-post>, [">= 0"])
352
353
  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
353
354
  s.add_runtime_dependency(%q<om>, [">= 1.0"])
354
- s.add_runtime_dependency(%q<solrizer>, [">= 0.3.0"])
355
+ s.add_runtime_dependency(%q<solrizer>, [">= 1.0.0", "< 2.0.0"])
355
356
  s.add_runtime_dependency(%q<activeresource>, ["< 3.0.0"])
356
357
  s.add_runtime_dependency(%q<mediashelf-loggable>, [">= 0"])
358
+ s.add_runtime_dependency(%q<equivalent-xml>, [">= 0"])
357
359
  s.add_development_dependency(%q<jeweler>, [">= 0"])
358
360
  s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
359
361
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
@@ -376,9 +378,10 @@ Gem::Specification.new do |s|
376
378
  s.add_dependency(%q<multipart-post>, [">= 0"])
377
379
  s.add_dependency(%q<nokogiri>, [">= 0"])
378
380
  s.add_dependency(%q<om>, [">= 1.0"])
379
- s.add_dependency(%q<solrizer>, [">= 0.3.0"])
381
+ s.add_dependency(%q<solrizer>, [">= 1.0.0", "< 2.0.0"])
380
382
  s.add_dependency(%q<activeresource>, ["< 3.0.0"])
381
383
  s.add_dependency(%q<mediashelf-loggable>, [">= 0"])
384
+ s.add_dependency(%q<equivalent-xml>, [">= 0"])
382
385
  s.add_dependency(%q<jeweler>, [">= 0"])
383
386
  s.add_dependency(%q<rspec>, ["< 2.0.0"])
384
387
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
@@ -402,9 +405,10 @@ Gem::Specification.new do |s|
402
405
  s.add_dependency(%q<multipart-post>, [">= 0"])
403
406
  s.add_dependency(%q<nokogiri>, [">= 0"])
404
407
  s.add_dependency(%q<om>, [">= 1.0"])
405
- s.add_dependency(%q<solrizer>, [">= 0.3.0"])
408
+ s.add_dependency(%q<solrizer>, [">= 1.0.0", "< 2.0.0"])
406
409
  s.add_dependency(%q<activeresource>, ["< 3.0.0"])
407
410
  s.add_dependency(%q<mediashelf-loggable>, [">= 0"])
411
+ s.add_dependency(%q<equivalent-xml>, [">= 0"])
408
412
  s.add_dependency(%q<jeweler>, [">= 0"])
409
413
  s.add_dependency(%q<rspec>, ["< 2.0.0"])
410
414
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
@@ -847,13 +847,13 @@ module ActiveFedora
847
847
  return xml.to_s
848
848
  end
849
849
 
850
- # Return a Solr::Document version of this object.
851
- # @solr_doc (optional) Solr::Document to insert the fields into
850
+ # Return a Hash representation of this object where keys in the hash are appropriate Solr field names.
851
+ # @solr_doc (optional) Hash to insert the fields into
852
852
  # @opts (optional) Hash
853
853
  # If opts[:model_only] == true, the base object metadata and the RELS-EXT datastream will be omitted. This is mainly to support shelver, which calls .to_solr for each model an object subscribes to.
854
- def to_solr(solr_doc = Solr::Document.new, opts={})
854
+ def to_solr(solr_doc = Hash.new, opts={})
855
855
  unless opts[:model_only]
856
- solr_doc << {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}
856
+ 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)
857
857
  end
858
858
  datastreams.each_value do |ds|
859
859
  # solr_doc = ds.to_solr(solr_doc) if ds.class.included_modules.include?(ActiveFedora::MetadataDatastreamHelper) ||( ds.kind_of?(ActiveFedora::RelsExtDatastream) || ( ds.kind_of?(ActiveFedora::QualifiedDublinCoreDatastream) && !opts[:model_only] )
@@ -866,6 +866,7 @@ module ActiveFedora
866
866
  end
867
867
  return solr_doc
868
868
  end
869
+
869
870
 
870
871
  # ** EXPERIMENTAL **
871
872
  #
@@ -99,7 +99,7 @@ module ActiveFedora
99
99
 
100
100
  if datastream_xml.length > 3
101
101
  datastream_xml.elements.each do |el|
102
- puts el.inspect
102
+ logger.debug el.inspect
103
103
  end
104
104
  end
105
105
 
@@ -4,7 +4,7 @@ module ActiveFedora
4
4
 
5
5
  include ActiveFedora::MetadataDatastreamHelper
6
6
 
7
- # .to_solr and .to_xml (among other things) are provided by ActiveFedora::MetadataDatastream
7
+ # .to_solr and .to_xml (among other things) are provided by ActiveFedora::MetadataDatastreamHelper
8
8
  self.xml_model = ActiveFedora::MetadataDatastream
9
9
 
10
10
  def update_attributes(params={},opts={})
@@ -37,12 +37,12 @@ module ActiveFedora::MetadataDatastreamHelper
37
37
  self.blob = self.to_xml
38
38
  end
39
39
 
40
- def to_solr(solr_doc = Solr::Document.new) # :nodoc:
40
+ def to_solr(solr_doc = Hash.new) # :nodoc:
41
41
  fields.each do |field_key, field_info|
42
42
  if field_info.has_key?(:values) && !field_info[:values].nil?
43
43
  field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
44
- field_info[:values].each do |val|
45
- solr_doc << Solr::Field.new(field_symbol => val)
44
+ field_info[:values].each do |val|
45
+ ::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val )
46
46
  end
47
47
  end
48
48
  end
@@ -88,7 +88,6 @@ module ActiveFedora::MetadataDatastreamHelper
88
88
  element_attrs = field_info[:element_attrs].nil? ? {} : field_info[:element_attrs]
89
89
  field_info[:values].each do |val|
90
90
  builder_arg = "xml.#{field}(val, element_attrs)"
91
- puts builder_arg.inspect
92
91
  eval(builder_arg)
93
92
  end
94
93
  end
@@ -188,7 +188,7 @@ module ActiveFedora
188
188
  query_opts[:sort] = sort_array
189
189
  end
190
190
 
191
- puts "Querying solr for #{self.name} objects with query: '#{query}'"
191
+ logger.debug "Querying solr for #{self.name} objects with query: '#{query}'"
192
192
  results = ActiveFedora::SolrService.instance.conn.query(query,query_opts)
193
193
  #objects = []
194
194
  # results.hits.each do |hit|
@@ -97,46 +97,7 @@ class ActiveFedora::NokogiriDatastream < ActiveFedora::Datastream
97
97
  #just initialize internal_solr_doc since any value retrieval will be done via lazy loading on this doc on-demand
98
98
  @internal_solr_doc = solr_doc
99
99
  end
100
-
101
- def solrize_accessor(accessor_name, accessor_info, opts={})
102
- solr_doc = opts.fetch(:solr_doc, Solr::Document.new)
103
- parents = opts.fetch(:parents, [])
104
-
105
- accessor_pointer = parents+[accessor_name]
106
-
107
- if accessor_info.nil?
108
- accessor_info = self.class.accessor_info(accessor_pointer)
109
- if accessor_info.nil?
110
- raise "No accessor is defined for #{accessor_info.select}"
111
- end
112
- end
113
-
114
- # prep children hash
115
- child_accessors = accessor_info.fetch(:children, {})
116
- xpath = self.class.accessor_xpath(*accessor_pointer)
117
- nodeset = lookup(xpath)
118
-
119
- nodeset.each do |node|
120
- # create solr fields
121
- solrize_node(node, accessor_pointer, solr_doc)
122
- child_accessors.each_pair do |child_accessor_name, child_accessor_info|
123
- solrize_accessor(child_accessor_name, child_accessor_info, opts={:solr_doc=>solr_doc, :parents=>parents+[{accessor_name=>nodeset.index(node)}] })
124
- end
125
- end
126
- end
127
-
128
- def solrize_node(node, accessor_pointer, solr_doc = Solr::Document.new)
129
- generic_field_name_base = self.class.accessor_generic_name(*accessor_pointer)
130
- generic_field_name = ActiveFedora::SolrService.solr_name(generic_field_name_base, :text)
131
-
132
- solr_doc << Solr::Field.new(generic_field_name => node.text)
133
-
134
- if accessor_pointer.length > 1
135
- hierarchical_field_name_base = self.class.accessor_hierarchical_name(*accessor_pointer)
136
- hierarchical_field_name = ActiveFedora::SolrService.solr_name(hierarchical_field_name_base, :text)
137
- solr_doc << Solr::Field.new(hierarchical_field_name => node.text)
138
- end
139
- end
100
+
140
101
 
141
102
  # ** Experimental **
142
103
  # This method is called by +get_values+ if this datastream has been initialized by calling from_solr method via
@@ -283,7 +244,7 @@ class ActiveFedora::NokogiriDatastream < ActiveFedora::Datastream
283
244
  #@return [Boolean] true if either the key for name exists in solr or if its string value exists
284
245
  #@param [String] name Name of key to look for
285
246
  #@param [Solr::Document] solr_doc Solr doc to query
286
- def has_solr_name?(name, solr_doc=Solr::Document.new)
247
+ def has_solr_name?(name, solr_doc=Hash.new)
287
248
  !solr_doc[name].nil? || !solr_doc[name.to_s].nil?
288
249
  end
289
250
 
@@ -41,12 +41,12 @@ module ActiveFedora
41
41
  tmpl
42
42
  end
43
43
 
44
- def to_solr(solr_doc = Solr::Document.new)
44
+ def to_solr(solr_doc = Hash.new)
45
45
  self.relationships.each_pair do |subject, predicates|
46
46
  if subject == :self || subject == "info:fedora/#{self.pid}"
47
47
  predicates.each_pair do |predicate, values|
48
48
  values.each do |val|
49
- solr_doc << Solr::Field.new(solr_name(predicate, :symbol) => val)
49
+ ::Solrizer::Extractor.insert_solr_field_value(solr_doc, solr_name(predicate, :symbol), val )
50
50
  end
51
51
  end
52
52
  end
@@ -181,7 +181,7 @@ describe ActiveFedora::Base do
181
181
 
182
182
  @solr_result = OralHistory.find_by_solr(@test_history.pid).hits[0]
183
183
  @properties_sample_values.each_pair do |field, value|
184
- (@solr_result["#{field.to_s}_t"] || @solr_result["#{field.to_s}_dt"]).should == [value]
184
+ (@solr_result["#{field.to_s}_t"] || @solr_result["#{field.to_s}_dt"]).should == [::Solrizer::Extractor.format_node_value(value)]
185
185
  end
186
186
 
187
187
  @dublin_core_sample_values.each_pair do |field, value|
@@ -3,6 +3,7 @@ gem 'mocha'
3
3
  require 'ruby-debug'
4
4
  require 'mocha'
5
5
  require 'ruby-fedora'
6
+ require "equivalent-xml"
6
7
  begin
7
8
  require 'spec'
8
9
  rescue LoadError
@@ -28,7 +28,7 @@ describe ActiveFedora::Base do
28
28
  end
29
29
 
30
30
  before(:each) do
31
- Fedora::Repository.instance.stubs(:nextid).returns(increment_pid)
31
+ Fedora::Repository.instance.stubs(:nextid).returns(increment_pid.to_s)
32
32
  @test_object = ActiveFedora::Base.new
33
33
  @test_object.new_object = true
34
34
  end
@@ -321,14 +321,14 @@ describe ActiveFedora::Base do
321
321
  @test_object.expects(:create_date).returns("cDate")
322
322
  @test_object.expects(:modified_date).returns("mDate")
323
323
  solr_doc = @test_object.to_solr
324
- solr_doc[:system_create_dt].should eql("cDate")
325
- solr_doc[:system_modified_dt].should eql("mDate")
324
+ solr_doc["system_create_dt"].should eql("cDate")
325
+ solr_doc["system_modified_dt"].should eql("mDate")
326
326
  solr_doc[:id].should eql("#{@test_object.pid}")
327
327
  end
328
328
 
329
329
  it "should add self.class as the :active_fedora_model" do
330
330
  solr_doc = @test_object.to_solr
331
- solr_doc[:active_fedora_model_s].should eql(@test_object.class.inspect)
331
+ solr_doc["active_fedora_model_s"].should eql(@test_object.class.inspect)
332
332
  end
333
333
 
334
334
  it "should call .to_xml on all MetadataDatastreams and return the resulting document" do
@@ -340,7 +340,7 @@ describe ActiveFedora::Base do
340
340
  @test_object.to_xml
341
341
  end
342
342
  end
343
-
343
+
344
344
  describe ".to_solr" do
345
345
 
346
346
  # before(:all) do
@@ -361,24 +361,24 @@ describe ActiveFedora::Base do
361
361
  @test_object.expects(:create_date).returns("cDate")
362
362
  @test_object.expects(:modified_date).returns("mDate")
363
363
  solr_doc = @test_object.to_solr
364
- solr_doc[:system_create_dt].should eql("cDate")
365
- solr_doc[:system_modified_dt].should eql("mDate")
364
+ solr_doc["system_create_dt"].should eql("cDate")
365
+ solr_doc["system_modified_dt"].should eql("mDate")
366
366
  solr_doc[:id].should eql("#{@test_object.pid}")
367
367
  end
368
368
 
369
369
  it "should omit base metadata and RELS-EXT if :model_only==true" do
370
370
  @test_object.add_relationship(:has_part, "foo")
371
371
  # @test_object.expects(:modified_date).returns("mDate")
372
- solr_doc = @test_object.to_solr(Solr::Document.new, :model_only => true)
373
- solr_doc[:system_create_dt].should be_nil
374
- solr_doc[:system_modified_dt].should be_nil
375
- solr_doc[:id].should be_nil
376
- solr_doc[:has_part_s].should be_nil
372
+ solr_doc = @test_object.to_solr(Hash.new, :model_only => true)
373
+ solr_doc["system_create_dt"].should be_nil
374
+ solr_doc["system_modified_dt"].should be_nil
375
+ solr_doc["id"].should be_nil
376
+ solr_doc["has_part_s"].should be_nil
377
377
  end
378
378
 
379
379
  it "should add self.class as the :active_fedora_model" do
380
380
  solr_doc = @test_object.to_solr
381
- solr_doc[:active_fedora_model_s].should eql(@test_object.class.inspect)
381
+ solr_doc["active_fedora_model_s"].should eql(@test_object.class.inspect)
382
382
  end
383
383
 
384
384
  it "should use mappings.yml to decide names of solr fields" do
@@ -387,20 +387,20 @@ describe ActiveFedora::Base do
387
387
  @test_object.stubs(:create_date).returns(cdate)
388
388
  @test_object.stubs(:modified_date).returns(mdate)
389
389
  solr_doc = @test_object.to_solr
390
- solr_doc[:system_create_dt].should eql(cdate)
391
- solr_doc[:system_modified_dt].should eql(mdate)
390
+ solr_doc["system_create_dt"].should eql(cdate)
391
+ solr_doc["system_modified_dt"].should eql(mdate)
392
392
  solr_doc[:id].should eql("#{@test_object.pid}")
393
- solr_doc[:active_fedora_model_s].should eql(@test_object.class.inspect)
393
+ solr_doc["active_fedora_model_s"].should eql(@test_object.class.inspect)
394
394
 
395
395
  ActiveFedora::SolrService.load_mappings(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings_af_0.1.yml"))
396
396
  solr_doc = @test_object.to_solr
397
397
  [:system_create_dt, :system_modified_dt, :active_fedora_model_s].each do |fn|
398
398
  solr_doc[fn].should == nil
399
399
  end
400
- solr_doc[:system_create_date].should eql(cdate)
401
- solr_doc[:system_modified_date].should eql(mdate)
400
+ solr_doc["system_create_date"].should eql(cdate)
401
+ solr_doc["system_modified_date"].should eql(mdate)
402
402
  solr_doc[:id].should eql("#{@test_object.pid}")
403
- solr_doc[:active_fedora_model_field].should eql(@test_object.class.inspect)
403
+ solr_doc["active_fedora_model_field"].should eql(@test_object.class.inspect)
404
404
  end
405
405
 
406
406
  it "should call .to_solr on all MetadataDatastreams and NokogiriDatastreams, passing the resulting document to solr" do
@@ -322,11 +322,11 @@ describe ActiveFedora::MetadataDatastream do
322
322
 
323
323
  it "should provide .to_solr and return a SolrDocument" do
324
324
  @test_ds.should respond_to(:to_solr)
325
- @test_ds.to_solr.should be_kind_of(Solr::Document)
325
+ @test_ds.to_solr.should be_kind_of(Hash)
326
326
  end
327
327
 
328
328
  it "should optionally allow you to provide the Solr::Document to add fields to and return that document when done" do
329
- doc = Solr::Document.new
329
+ doc = Hash.new
330
330
  @test_ds.to_solr(doc).should equal(doc)
331
331
  end
332
332
 
@@ -334,12 +334,12 @@ describe ActiveFedora::MetadataDatastream do
334
334
  @test_ds.expects(:fields).returns(@sample_fields)
335
335
  solr_doc = @test_ds.to_solr
336
336
 
337
- solr_doc[:publisher_t].should == "publisher1"
338
- solr_doc[:coverage_t].should == "coverage1"
339
- solr_doc[:creation_date_dt].should == "fake-date"
340
- solr_doc[:mydate_dt].should == "fake-date"
337
+ solr_doc["publisher_t"].should == ["publisher1"]
338
+ solr_doc["coverage_t"].sort.should == ["coverage1", "coverage2"]
339
+ solr_doc["creation_date_dt"].should == ["fake-date"]
340
+ solr_doc["mydate_dt"].should == ["fake-date"]
341
341
 
342
- solr_doc[:empty_field_t].should be_nil
342
+ solr_doc["empty_field_t"].should be_nil
343
343
  end
344
344
 
345
345
  it "should allow multiple values for a single field"
@@ -349,14 +349,14 @@ describe ActiveFedora::MetadataDatastream do
349
349
 
350
350
  #should have these
351
351
 
352
- @test_ds.to_solr[:publisher_t].should_not be_nil
353
- @test_ds.to_solr[:coverage_t].should_not be_nil
354
- @test_ds.to_solr[:creation_date_dt].should_not be_nil
352
+ @test_ds.to_solr["publisher_t"].should_not be_nil
353
+ @test_ds.to_solr["coverage_t"].should_not be_nil
354
+ @test_ds.to_solr["creation_date_dt"].should_not be_nil
355
355
 
356
356
  #should NOT have these
357
- @test_ds.to_solr[:narrator].should be_nil
358
- @test_ds.to_solr[:title].should be_nil
359
- @test_ds.to_solr[:empty_field].should be_nil
357
+ @test_ds.to_solr["narrator"].should be_nil
358
+ @test_ds.to_solr["title"].should be_nil
359
+ @test_ds.to_solr["empty_field"].should be_nil
360
360
 
361
361
  end
362
362
 
@@ -367,31 +367,30 @@ describe ActiveFedora::MetadataDatastream do
367
367
 
368
368
  #should have these
369
369
 
370
- solr_doc[:publisher_field].should == "publisher1"
371
- solr_doc[:coverage_field].should == "coverage1"
372
- solr_doc[:creation_date_date].should == "fake-date"
373
- solr_doc[:mydate_date].should == "fake-date"
370
+ solr_doc["publisher_field"].should == ["publisher1"]
371
+ solr_doc["coverage_field"].sort.should == ["coverage1", "coverage2"]
372
+ solr_doc["creation_date_date"].should == ["fake-date"]
373
+ solr_doc["mydate_date"].should == ["fake-date"]
374
374
 
375
- solr_doc[:publisher_t].should be_nil
376
- solr_doc[:coverage_t].should be_nil
377
- solr_doc[:creation_date_dt].should be_nil
375
+ solr_doc["publisher_t"].should be_nil
376
+ solr_doc["coverage_t"].should be_nil
377
+ solr_doc["creation_date_dt"].should be_nil
378
378
 
379
379
  # Reload default mappings
380
380
  ActiveFedora::SolrService.load_mappings
381
381
  end
382
382
 
383
383
  it 'should append _dt to dates' do
384
+ ActiveFedora::SolrService.load_mappings
384
385
  @test_ds.expects(:fields).returns(@sample_fields).at_least_once
385
386
 
386
- #should have these
387
-
388
- @test_ds.to_solr[:creation_date_dt].should_not be_nil
389
- @test_ds.to_solr[:mydate_dt].should_not be_nil
387
+ @test_ds.to_solr["creation_date_dt"].should_not be_nil
388
+ @test_ds.to_solr["mydate_dt"].should_not be_nil
390
389
 
391
390
  #should NOT have these
392
391
 
393
- @test_ds.to_solr[:mydate].should be_nil
394
- @test_ds.to_solr[:creation_date_date].should be_nil
392
+ @test_ds.to_solr["mydate"].should be_nil
393
+ @test_ds.to_solr["creation_date_date"].should be_nil
395
394
  end
396
395
 
397
396
  end
@@ -80,17 +80,17 @@ describe ActiveFedora::RelsExtDatastream do
80
80
 
81
81
  it "should provide .to_solr and return a SolrDocument" do
82
82
  @test_ds.should respond_to(:to_solr)
83
- @test_ds.to_solr.should be_kind_of(Solr::Document)
83
+ @test_ds.to_solr.should be_kind_of(Hash)
84
84
  end
85
85
 
86
- it "should serialize the relationships into a Solr::Document" do
86
+ it "should serialize the relationships into a Hash" do
87
87
  @test_ds.add_relationship(@test_relationship1)
88
88
  @test_ds.add_relationship(@test_relationship2)
89
89
  @test_ds.add_relationship(@test_relationship3)
90
90
  solr_doc = @test_ds.to_solr
91
- solr_doc[:is_member_of_s].should == "info:fedora/demo:10"
92
- solr_doc[:is_part_of_s].should == "info:fedora/demo:11"
93
- solr_doc[:has_part_s].should == "info:fedora/demo:12"
91
+ solr_doc["is_member_of_s"].should == ["info:fedora/demo:10"]
92
+ solr_doc["is_part_of_s"].should == ["info:fedora/demo:11"]
93
+ solr_doc["has_part_s"].should == ["info:fedora/demo:12"]
94
94
  end
95
95
  end
96
96
 
@@ -503,8 +503,9 @@ describe ActiveFedora::SemanticNode do
503
503
  @node.add_relationship(@test_cmodel_relationship1)
504
504
  @node.add_relationship(@test_cmodel_relationship2)
505
505
  @node.internal_uri = @uri
506
- returned_xml = XmlSimple.xml_in(@node.to_rels_ext(@pid))
507
- returned_xml.should == XmlSimple.xml_in(@sample_rels_ext_xml)
506
+ # returned_xml = XmlSimple.xml_in(@node.to_rels_ext(@pid))
507
+ # returned_xml.should == XmlSimple.xml_in(@sample_rels_ext_xml)
508
+ EquivalentXml.equivalent?(@node.to_rels_ext(@pid), @sample_rels_ext_xml).should be_true
508
509
  end
509
510
 
510
511
  it "should treat :self and self.pid as equivalent subjects"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
- - 1
8
7
  - 2
9
- - 9
10
- version: 1.2.9
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Zumwalt
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-01-31 00:00:00 -06:00
19
+ date: 2011-03-03 00:00:00 -06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -118,12 +118,20 @@ dependencies:
118
118
  requirements:
119
119
  - - ">="
120
120
  - !ruby/object:Gem::Version
121
- hash: 19
121
+ hash: 23
122
122
  segments:
123
+ - 1
123
124
  - 0
124
- - 3
125
125
  - 0
126
- version: 0.3.0
126
+ version: 1.0.0
127
+ - - <
128
+ - !ruby/object:Gem::Version
129
+ hash: 15
130
+ segments:
131
+ - 2
132
+ - 0
133
+ - 0
134
+ version: 2.0.0
127
135
  requirement: *id007
128
136
  - !ruby/object:Gem::Dependency
129
137
  type: :runtime
@@ -156,9 +164,9 @@ dependencies:
156
164
  version: "0"
157
165
  requirement: *id009
158
166
  - !ruby/object:Gem::Dependency
159
- type: :development
167
+ type: :runtime
160
168
  prerelease: false
161
- name: jeweler
169
+ name: equivalent-xml
162
170
  version_requirements: &id010 !ruby/object:Gem::Requirement
163
171
  none: false
164
172
  requirements:
@@ -172,8 +180,22 @@ dependencies:
172
180
  - !ruby/object:Gem::Dependency
173
181
  type: :development
174
182
  prerelease: false
175
- name: rspec
183
+ name: jeweler
176
184
  version_requirements: &id011 !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ hash: 3
190
+ segments:
191
+ - 0
192
+ version: "0"
193
+ requirement: *id011
194
+ - !ruby/object:Gem::Dependency
195
+ type: :development
196
+ prerelease: false
197
+ name: rspec
198
+ version_requirements: &id012 !ruby/object:Gem::Requirement
177
199
  none: false
178
200
  requirements:
179
201
  - - <
@@ -184,12 +206,12 @@ dependencies:
184
206
  - 0
185
207
  - 0
186
208
  version: 2.0.0
187
- requirement: *id011
209
+ requirement: *id012
188
210
  - !ruby/object:Gem::Dependency
189
211
  type: :development
190
212
  prerelease: false
191
213
  name: mocha
192
- version_requirements: &id012 !ruby/object:Gem::Requirement
214
+ version_requirements: &id013 !ruby/object:Gem::Requirement
193
215
  none: false
194
216
  requirements:
195
217
  - - ">="
@@ -200,12 +222,12 @@ dependencies:
200
222
  - 9
201
223
  - 8
202
224
  version: 0.9.8
203
- requirement: *id012
225
+ requirement: *id013
204
226
  - !ruby/object:Gem::Dependency
205
227
  type: :development
206
228
  prerelease: false
207
229
  name: ruby-debug
208
- version_requirements: &id013 !ruby/object:Gem::Requirement
230
+ version_requirements: &id014 !ruby/object:Gem::Requirement
209
231
  none: false
210
232
  requirements:
211
233
  - - ">="
@@ -214,12 +236,12 @@ dependencies:
214
236
  segments:
215
237
  - 0
216
238
  version: "0"
217
- requirement: *id013
239
+ requirement: *id014
218
240
  - !ruby/object:Gem::Dependency
219
241
  type: :runtime
220
242
  prerelease: false
221
243
  name: solr-ruby
222
- version_requirements: &id014 !ruby/object:Gem::Requirement
244
+ version_requirements: &id015 !ruby/object:Gem::Requirement
223
245
  none: false
224
246
  requirements:
225
247
  - - ">="
@@ -230,12 +252,12 @@ dependencies:
230
252
  - 0
231
253
  - 6
232
254
  version: 0.0.6
233
- requirement: *id014
255
+ requirement: *id015
234
256
  - !ruby/object:Gem::Dependency
235
257
  type: :runtime
236
258
  prerelease: false
237
259
  name: xml-simple
238
- version_requirements: &id015 !ruby/object:Gem::Requirement
260
+ version_requirements: &id016 !ruby/object:Gem::Requirement
239
261
  none: false
240
262
  requirements:
241
263
  - - ">="
@@ -246,12 +268,12 @@ dependencies:
246
268
  - 0
247
269
  - 12
248
270
  version: 1.0.12
249
- requirement: *id015
271
+ requirement: *id016
250
272
  - !ruby/object:Gem::Dependency
251
273
  type: :runtime
252
274
  prerelease: false
253
275
  name: mime-types
254
- version_requirements: &id016 !ruby/object:Gem::Requirement
276
+ version_requirements: &id017 !ruby/object:Gem::Requirement
255
277
  none: false
256
278
  requirements:
257
279
  - - ">="
@@ -261,12 +283,12 @@ dependencies:
261
283
  - 1
262
284
  - 16
263
285
  version: "1.16"
264
- requirement: *id016
286
+ requirement: *id017
265
287
  - !ruby/object:Gem::Dependency
266
288
  type: :runtime
267
289
  prerelease: false
268
290
  name: multipart-post
269
- version_requirements: &id017 !ruby/object:Gem::Requirement
291
+ version_requirements: &id018 !ruby/object:Gem::Requirement
270
292
  none: false
271
293
  requirements:
272
294
  - - ">="
@@ -275,12 +297,12 @@ dependencies:
275
297
  segments:
276
298
  - 0
277
299
  version: "0"
278
- requirement: *id017
300
+ requirement: *id018
279
301
  - !ruby/object:Gem::Dependency
280
302
  type: :runtime
281
303
  prerelease: false
282
304
  name: nokogiri
283
- version_requirements: &id018 !ruby/object:Gem::Requirement
305
+ version_requirements: &id019 !ruby/object:Gem::Requirement
284
306
  none: false
285
307
  requirements:
286
308
  - - ">="
@@ -289,12 +311,12 @@ dependencies:
289
311
  segments:
290
312
  - 0
291
313
  version: "0"
292
- requirement: *id018
314
+ requirement: *id019
293
315
  - !ruby/object:Gem::Dependency
294
316
  type: :runtime
295
317
  prerelease: false
296
318
  name: om
297
- version_requirements: &id019 !ruby/object:Gem::Requirement
319
+ version_requirements: &id020 !ruby/object:Gem::Requirement
298
320
  none: false
299
321
  requirements:
300
322
  - - ">="
@@ -304,12 +326,12 @@ dependencies:
304
326
  - 1
305
327
  - 0
306
328
  version: "1.0"
307
- requirement: *id019
329
+ requirement: *id020
308
330
  - !ruby/object:Gem::Dependency
309
331
  type: :runtime
310
332
  prerelease: false
311
333
  name: solrizer
312
- version_requirements: &id020 !ruby/object:Gem::Requirement
334
+ version_requirements: &id021 !ruby/object:Gem::Requirement
313
335
  none: false
314
336
  requirements:
315
337
  - - ">="
@@ -320,12 +342,12 @@ dependencies:
320
342
  - 3
321
343
  - 0
322
344
  version: 0.3.0
323
- requirement: *id020
345
+ requirement: *id021
324
346
  - !ruby/object:Gem::Dependency
325
347
  type: :runtime
326
348
  prerelease: false
327
349
  name: activeresource
328
- version_requirements: &id021 !ruby/object:Gem::Requirement
350
+ version_requirements: &id022 !ruby/object:Gem::Requirement
329
351
  none: false
330
352
  requirements:
331
353
  - - <
@@ -336,12 +358,12 @@ dependencies:
336
358
  - 0
337
359
  - 0
338
360
  version: 3.0.0
339
- requirement: *id021
361
+ requirement: *id022
340
362
  - !ruby/object:Gem::Dependency
341
363
  type: :development
342
364
  prerelease: false
343
365
  name: rspec
344
- version_requirements: &id022 !ruby/object:Gem::Requirement
366
+ version_requirements: &id023 !ruby/object:Gem::Requirement
345
367
  none: false
346
368
  requirements:
347
369
  - - ">="
@@ -352,12 +374,12 @@ dependencies:
352
374
  - 2
353
375
  - 9
354
376
  version: 1.2.9
355
- requirement: *id022
377
+ requirement: *id023
356
378
  - !ruby/object:Gem::Dependency
357
379
  type: :development
358
380
  prerelease: false
359
381
  name: mocha
360
- version_requirements: &id023 !ruby/object:Gem::Requirement
382
+ version_requirements: &id024 !ruby/object:Gem::Requirement
361
383
  none: false
362
384
  requirements:
363
385
  - - ">="
@@ -368,12 +390,12 @@ dependencies:
368
390
  - 9
369
391
  - 8
370
392
  version: 0.9.8
371
- requirement: *id023
393
+ requirement: *id024
372
394
  - !ruby/object:Gem::Dependency
373
395
  type: :development
374
396
  prerelease: false
375
397
  name: ruby-debug
376
- version_requirements: &id024 !ruby/object:Gem::Requirement
398
+ version_requirements: &id025 !ruby/object:Gem::Requirement
377
399
  none: false
378
400
  requirements:
379
401
  - - ">="
@@ -382,7 +404,7 @@ dependencies:
382
404
  segments:
383
405
  - 0
384
406
  version: "0"
385
- requirement: *id024
407
+ requirement: *id025
386
408
  description: ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.
387
409
  email: matt.zumwalt@yourmediashelf.com
388
410
  executables: []
@@ -554,6 +576,7 @@ files:
554
576
  - PostInstall.txt
555
577
  - README.textile
556
578
  - Rakefile
579
+ - USING_OM_DATASTREAMS.textile
557
580
  - VERSION
558
581
  - active-fedora.gemspec
559
582
  - config/fedora.yml