active-fedora 5.5.0 → 5.5.1
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/.gitmodules +1 -1
- data/History.txt +3 -0
- data/active-fedora.gemspec +1 -1
- data/lib/active_fedora/base.rb +1 -1
- data/lib/active_fedora/nokogiri_datastream.rb +1 -1
- data/lib/active_fedora/querying.rb +17 -11
- data/lib/active_fedora/rdf_node.rb +1 -1
- data/lib/active_fedora/simple_datastream.rb +1 -1
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/base_spec.rb +4 -2
- data/spec/integration/complex_rdf_datastream_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +1 -1
- data/spec/integration/ntriples_datastream_spec.rb +4 -4
- data/spec/integration/om_datastream_spec.rb +1 -1
- data/spec/integration/scoped_query_spec.rb +5 -4
- data/spec/integration/semantic_node_spec.rb +11 -11
- data/spec/samples/hydra-mods_article_datastream.rb +2 -2
- data/spec/unit/base_spec.rb +10 -36
- data/spec/unit/ntriples_datastream_spec.rb +28 -26
- data/spec/unit/om_datastream_spec.rb +11 -6
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
- data/spec/unit/query_spec.rb +10 -9
- data/spec/unit/relationships_spec.rb +22 -22
- data/spec/unit/simple_datastream_spec.rb +2 -2
- data/spec/unit/solr_config_options_spec.rb +1 -17
- data/spec/unit/solr_service_spec.rb +3 -3
- metadata +5 -5
data/.gitmodules
CHANGED
data/History.txt
CHANGED
data/active-fedora.gemspec
CHANGED
@@ -18,7 +18,7 @@ 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', '
|
21
|
+
s.add_dependency('solrizer', '>=2.1.0') #can also use version 3
|
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')
|
data/lib/active_fedora/base.rb
CHANGED
@@ -398,7 +398,7 @@ module ActiveFedora
|
|
398
398
|
else
|
399
399
|
raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
|
400
400
|
end
|
401
|
-
klass = if class_str = solr_doc['
|
401
|
+
klass = if class_str = solr_doc[ActiveFedora::SolrService.solr_name('has_model', :symbol)]
|
402
402
|
ActiveFedora::SolrService.class_from_solr_document(solr_doc)
|
403
403
|
else
|
404
404
|
ActiveFedora::Base
|
@@ -115,22 +115,28 @@ module ActiveFedora
|
|
115
115
|
def create_query_from_hash(conditions)
|
116
116
|
clauses = search_model_clause ? [search_model_clause] : []
|
117
117
|
conditions.each_pair do |key,value|
|
118
|
-
|
119
|
-
if value.is_a? Array
|
120
|
-
value.each do |val|
|
121
|
-
clauses << "#{key}:#{quote_for_solr(val)}"
|
122
|
-
end
|
123
|
-
else
|
124
|
-
key = SOLR_DOCUMENT_ID if (key === :id || key === :pid)
|
125
|
-
escaped_value = quote_for_solr(value)
|
126
|
-
clauses << (key.to_s.eql?(SOLR_DOCUMENT_ID) ? "#{key}:#{escaped_value}" : "#{key}:#{escaped_value}")
|
127
|
-
end
|
128
|
-
end
|
118
|
+
clauses << condition_to_clauses(key, value)
|
129
119
|
end
|
130
120
|
return "*:*" if clauses.empty?
|
131
121
|
clauses.compact.join(" AND ")
|
132
122
|
end
|
133
123
|
|
124
|
+
def condition_to_clauses(key, value)
|
125
|
+
unless value.nil?
|
126
|
+
# if the key is a property name, turn it into a solr field
|
127
|
+
if self.delegate_registry.include?(key.to_sym)
|
128
|
+
key = ActiveFedora::SolrService.solr_name(key, :string, :searchable)
|
129
|
+
end
|
130
|
+
if value.is_a? Array
|
131
|
+
value.map { |val| "#{key}:#{quote_for_solr(val)}" }
|
132
|
+
else
|
133
|
+
key = SOLR_DOCUMENT_ID if (key === :id || key === :pid)
|
134
|
+
escaped_value = quote_for_solr(value)
|
135
|
+
key.to_s.eql?(SOLR_DOCUMENT_ID) ? "#{key}:#{escaped_value}" : "#{key}:#{escaped_value}"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
134
140
|
def create_query_from_string(conditions)
|
135
141
|
model_clause = search_model_clause
|
136
142
|
model_clause ? "#{model_clause} AND (#{conditions})" : conditions
|
@@ -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 = RDF::URI
|
191
|
+
uri = uri_or_string.kind_of?(RDF::URI) ? uri_or_string : RDF::URI.new(uri_or_string)
|
192
192
|
self.config[:type] = {predicate: RDF.type}
|
193
193
|
@rdf_type = uri
|
194
194
|
end
|
@@ -48,7 +48,7 @@ module ActiveFedora
|
|
48
48
|
#!! Careful: If you declare two fields that correspond to the same xml node without any qualifiers to differentiate them,
|
49
49
|
#you will end up replicating the values in the underlying datastream, resulting in mysterious dubling, quadrupling, etc.
|
50
50
|
#whenever you edit the field's values.
|
51
|
-
def field(name, datatype
|
51
|
+
def field(name, datatype=:string, opts={})
|
52
52
|
fields ||= {}
|
53
53
|
@fields[name.to_s.to_sym]={:type=>datatype, :values=>[]}.merge(opts)
|
54
54
|
# add term to template
|
@@ -20,7 +20,8 @@ describe "A base object with metadata" do
|
|
20
20
|
obj = ActiveFedora::Base.find(@obj.pid, :cast=>true)
|
21
21
|
obj.foo.should_not be_new
|
22
22
|
obj.foo.person.should == ['bob']
|
23
|
-
ActiveFedora::SolrService.
|
23
|
+
person_field = ActiveFedora::SolrService.solr_name('person', :string, :searchable)
|
24
|
+
ActiveFedora::SolrService.query("id:#{@obj.pid.gsub(":", "\\:")}", :fl=>"id #{person_field}").first.should == {"id"=>@obj.pid, person_field =>['bob']}
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -39,7 +40,8 @@ describe "A base object with metadata" do
|
|
39
40
|
end
|
40
41
|
it "should save the datastream." do
|
41
42
|
MockAFBaseRelationship.find(@release.pid).foo.person.should == ['frank']
|
42
|
-
ActiveFedora::SolrService.
|
43
|
+
person_field = ActiveFedora::SolrService.solr_name('person', :string, :searchable)
|
44
|
+
ActiveFedora::SolrService.query("id:#{@release.pid.gsub(":", "\\:")}", :fl=>"id #{person_field}").first.should == {"id"=>@release.pid, person_field =>['frank']}
|
43
45
|
end
|
44
46
|
end
|
45
47
|
describe "clone_into a new object" do
|
@@ -151,7 +151,7 @@ describe ActiveFedora::Base do
|
|
151
151
|
@properties_sample_values.each_pair do |field, value|
|
152
152
|
next if field == :hard_copy_availability #FIXME HYDRA-824
|
153
153
|
next if field == :location #FIXME HYDRA-825
|
154
|
-
(@solr_result[
|
154
|
+
(@solr_result[ActiveFedora::SolrService.solr_name(field, :string, :searchable)] || @solr_result[ActiveFedora::SolrService.solr_name(field, :date)]).should == [::Solrizer::Extractor.format_node_value(value)]
|
155
155
|
end
|
156
156
|
|
157
157
|
@dublin_core_sample_values.each_pair do |field, value|
|
@@ -68,15 +68,15 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
68
68
|
subject.date_uploaded = Date.parse('2012-11-02')
|
69
69
|
subject.date_uploaded.first.should be_kind_of Date
|
70
70
|
solr_document = subject.to_solr
|
71
|
-
solr_document[
|
71
|
+
solr_document[ActiveFedora::SolrService.solr_name('rdf__date_uploaded', :date, :searchable)].should == ['2012-11-02T00:00:00Z']
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should produce a solr document" do
|
75
75
|
@subject = RdfTest.new(title: "War and Peace")
|
76
76
|
solr_document = @subject.to_solr
|
77
|
-
solr_document[
|
78
|
-
solr_document[
|
79
|
-
solr_document[
|
77
|
+
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :string, :displayable)].should == ["War and Peace"]
|
78
|
+
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :string, :facetable)].should == ["War and Peace"]
|
79
|
+
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :string, :searchable)].should == ["War and Peace"]
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should set and recall values" do
|
@@ -119,7 +119,7 @@ describe ActiveFedora::OmDatastream do
|
|
119
119
|
|
120
120
|
end
|
121
121
|
it "should solrize terms with :type=>'date' to *_dt solr terms" do
|
122
|
-
@test_object.to_solr['
|
122
|
+
@test_object.to_solr[ActiveFedora::SolrService.solr_name('mods_journal_issue_publication_date', :date)].should == ['2012-11-02T00:00:00Z']
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
@@ -15,7 +15,7 @@ describe ActiveFedora::Model do
|
|
15
15
|
|
16
16
|
def to_solr(doc = {})
|
17
17
|
doc = super
|
18
|
-
doc['
|
18
|
+
doc[ActiveFedora::SolrService.solr_name('foo', :string, :sortable)] = doc[ActiveFedora::SolrService.solr_name('foo', :string, :searchable)]
|
19
19
|
doc
|
20
20
|
end
|
21
21
|
|
@@ -71,17 +71,18 @@ describe ActiveFedora::Model do
|
|
71
71
|
@test_instance3.delete
|
72
72
|
end
|
73
73
|
it "should query" do
|
74
|
-
ModelIntegrationSpec::Basic.where(:
|
74
|
+
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', :string, :searchable)=> 'Beta').should == [@test_instance1]
|
75
|
+
ModelIntegrationSpec::Basic.where('foo' => 'Beta').should == [@test_instance1]
|
75
76
|
end
|
76
77
|
it "should order" do
|
77
|
-
ModelIntegrationSpec::Basic.order('
|
78
|
+
ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :string, :sortable) + ' asc').should == [@test_instance2, @test_instance1, @test_instance3]
|
78
79
|
end
|
79
80
|
it "should limit" do
|
80
81
|
ModelIntegrationSpec::Basic.limit(1).should == [@test_instance1]
|
81
82
|
end
|
82
83
|
|
83
84
|
it "should chain them" do
|
84
|
-
ModelIntegrationSpec::Basic.where(:
|
85
|
+
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', :string, :searchable) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :string, :sortable) + ' asc').limit(1).should == [@test_instance2]
|
85
86
|
end
|
86
87
|
end
|
87
88
|
end
|
@@ -28,11 +28,11 @@ describe ActiveFedora::SemanticNode do
|
|
28
28
|
class SpecNodeSolrFilterQuery < ActiveFedora::Base
|
29
29
|
include ActiveFedora::Relationships
|
30
30
|
has_relationship("parts", :is_part_of, :inbound => true)
|
31
|
-
has_relationship("special_parts", :is_part_of, :inbound => true, :solr_fq=>"
|
31
|
+
has_relationship("special_parts", :is_part_of, :inbound => true, :solr_fq=>"#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:info\\:fedora\\/afmodel\\:SpecialPart")
|
32
32
|
has_relationship("containers", :is_member_of)
|
33
|
-
has_relationship("special_containers", :is_member_of, :solr_fq=>"
|
33
|
+
has_relationship("special_containers", :is_member_of, :solr_fq=>"#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:info\\:fedora\\/afmodel\\:SpecialContainer")
|
34
34
|
has_bidirectional_relationship("bi_containers", :is_member_of, :has_member)
|
35
|
-
has_bidirectional_relationship("bi_special_containers", :is_member_of, :has_member, :solr_fq=>"
|
35
|
+
has_bidirectional_relationship("bi_special_containers", :is_member_of, :has_member, :solr_fq=>"#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:info\\:fedora\\/afmodel\\:SpecialContainer")
|
36
36
|
end
|
37
37
|
|
38
38
|
@test_object = SNSpecModel.new
|
@@ -100,8 +100,8 @@ describe ActiveFedora::SemanticNode do
|
|
100
100
|
@special_part.add_relationship(:is_part_of, @test_object_query)
|
101
101
|
@special_part.save
|
102
102
|
|
103
|
-
@special_container_query = "
|
104
|
-
@special_part_query = "
|
103
|
+
@special_container_query = "#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:#{solr_uri("info:fedora/afmodel:SpecialContainer")}"
|
104
|
+
@special_part_query = "#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:#{solr_uri("info:fedora/afmodel:SpecialPart")}"
|
105
105
|
end
|
106
106
|
|
107
107
|
after(:all) do
|
@@ -263,17 +263,17 @@ describe ActiveFedora::SemanticNode do
|
|
263
263
|
end
|
264
264
|
|
265
265
|
it "should return a solr query for an inbound relationship" do
|
266
|
-
@test_object_query.special_parts_query.should == "#{@test_object_query.relationship_predicates[:inbound]['special_parts']}
|
266
|
+
@test_object_query.special_parts_query.should == "#{ActiveFedora::SolrService.solr_name(@test_object_query.relationship_predicates[:inbound]['special_parts'], :symbol)}:#{solr_uri(@test_object_query.internal_uri)} AND #{@special_part_query}"
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
270
270
|
describe "inbound relationship query" do
|
271
271
|
it "should return a properly formatted query for a relationship that has a solr filter query defined" do
|
272
|
-
SpecNodeSolrFilterQuery.inbound_relationship_query(@test_object_query.pid,"special_parts").should == "#{@test_object_query.relationship_predicates[:inbound]['special_parts']}
|
272
|
+
SpecNodeSolrFilterQuery.inbound_relationship_query(@test_object_query.pid,"special_parts").should == "#{ActiveFedora::SolrService.solr_name(@test_object_query.relationship_predicates[:inbound]['special_parts'], :symbol)}:#{solr_uri(@test_object_query.internal_uri)} AND #{@special_part_query}"
|
273
273
|
end
|
274
274
|
|
275
275
|
it "should return a properly formatted query for a relationship that does not have a solr filter query defined" do
|
276
|
-
SpecNodeSolrFilterQuery.inbound_relationship_query(@test_object_query.pid,"parts").should == "
|
276
|
+
SpecNodeSolrFilterQuery.inbound_relationship_query(@test_object_query.pid,"parts").should == "#{ActiveFedora::SolrService.solr_name('is_part_of', :symbol)}:#{solr_uri(@test_object_query.internal_uri)}"
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
@@ -305,7 +305,7 @@ describe ActiveFedora::SemanticNode do
|
|
305
305
|
expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND #{@special_container_query})"
|
306
306
|
end
|
307
307
|
expected_string << " OR "
|
308
|
-
expected_string << "(#{@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound']}
|
308
|
+
expected_string << "(#{ActiveFedora::SolrService.solr_name(@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound'], :symbol)}:#{solr_uri(@test_object_query.internal_uri)} AND #{@special_container_query})"
|
309
309
|
SpecNodeSolrFilterQuery.bidirectional_relationship_query(@test_object_query.pid,"bi_special_containers",@test_object_query.bi_containers_outbound_ids).should == expected_string
|
310
310
|
end
|
311
311
|
|
@@ -316,7 +316,7 @@ describe ActiveFedora::SemanticNode do
|
|
316
316
|
expected_string << "id:" + id.gsub(/(:)/, '\\:')
|
317
317
|
end
|
318
318
|
expected_string << " OR "
|
319
|
-
expected_string << "(#{@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound']}
|
319
|
+
expected_string << "(#{ActiveFedora::SolrService.solr_name(@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound'], :symbol)}:#{solr_uri(@test_object_query.internal_uri)})"
|
320
320
|
SpecNodeSolrFilterQuery.bidirectional_relationship_query(@test_object_query.pid,"bi_containers",@test_object_query.bi_containers_outbound_ids).should == expected_string
|
321
321
|
end
|
322
322
|
end
|
@@ -427,7 +427,7 @@ describe ActiveFedora::SemanticNode do
|
|
427
427
|
expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND #{@special_container_query})"
|
428
428
|
end
|
429
429
|
expected_string << " OR "
|
430
|
-
expected_string << "(#{@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound']}
|
430
|
+
expected_string << "(#{ActiveFedora::SolrService.solr_name(@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound'], :symbol)}:#{solr_uri(@test_object_query.internal_uri)} AND #{@special_container_query})"
|
431
431
|
@test_object_query.bi_special_containers_query.should == expected_string
|
432
432
|
end
|
433
433
|
end
|
@@ -508,8 +508,8 @@ module Hydra
|
|
508
508
|
def to_solr(solr_doc=Hash.new)
|
509
509
|
super(solr_doc)
|
510
510
|
|
511
|
-
::Solrizer::Extractor.insert_solr_field_value(solr_doc,
|
512
|
-
::Solrizer::Extractor.insert_solr_field_value(solr_doc,
|
511
|
+
::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('object_type', :string, :facetable), "Article")
|
512
|
+
::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('mods_journal_title_info', :string, :facetable), "Unknown") if solr_doc["mods_journal_title_info_facet"].nil?
|
513
513
|
|
514
514
|
solr_doc
|
515
515
|
end
|
data/spec/unit/base_spec.rb
CHANGED
@@ -392,18 +392,18 @@ describe ActiveFedora::Base do
|
|
392
392
|
@test_object.should_receive(:create_date).and_return("2012-03-04T03:12:02Z")
|
393
393
|
@test_object.should_receive(:modified_date).and_return("2012-03-07T03:12:02Z")
|
394
394
|
solr_doc = @test_object.to_solr
|
395
|
-
solr_doc["
|
396
|
-
solr_doc["
|
395
|
+
solr_doc[ActiveFedora::SolrService.solr_name("system_create", :date, :searchable)].should eql("2012-03-04T03:12:02Z")
|
396
|
+
solr_doc[ActiveFedora::SolrService.solr_name("system_modified", :date, :searchable)].should eql("2012-03-07T03:12:02Z")
|
397
397
|
solr_doc[:id].should eql("#{@test_object.pid}")
|
398
398
|
end
|
399
399
|
|
400
400
|
it "should omit base metadata and RELS-EXT if :model_only==true" do
|
401
401
|
@test_object.add_relationship(:has_part, "foo", true)
|
402
402
|
solr_doc = @test_object.to_solr(Hash.new, :model_only => true)
|
403
|
-
solr_doc["
|
404
|
-
solr_doc["
|
403
|
+
solr_doc[ActiveFedora::SolrService.solr_name("system_create", :date, :searchable)].should be_nil
|
404
|
+
solr_doc[ActiveFedora::SolrService.solr_name("system_modified", :date, :searchable)].should be_nil
|
405
405
|
solr_doc["id"].should be_nil
|
406
|
-
solr_doc["
|
406
|
+
solr_doc[ActiveFedora::SolrService.solr_name("has_part", :symbol)].should be_nil
|
407
407
|
end
|
408
408
|
|
409
409
|
it "should add self.class as the :active_fedora_model" do
|
@@ -411,35 +411,9 @@ describe ActiveFedora::Base do
|
|
411
411
|
stub_get_content(@this_pid, ['RELS-EXT', 'someData', 'withText2', 'withText'])
|
412
412
|
@test_history = FooHistory.new()
|
413
413
|
solr_doc = @test_history.to_solr
|
414
|
-
solr_doc["
|
414
|
+
solr_doc[ActiveFedora::SolrService.solr_name("active_fedora_model", :symbol)].should eql("FooHistory")
|
415
415
|
end
|
416
416
|
|
417
|
-
describe "using mappings.yml" do
|
418
|
-
before do
|
419
|
-
@old_mapper = ActiveFedora::SolrService.default_field_mapper.dup
|
420
|
-
ActiveFedora::SolrService.load_mappings(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings_af_0.1.yml"))
|
421
|
-
end
|
422
|
-
after do
|
423
|
-
ActiveFedora::SolrService.default_field_mapper = @old_mapper
|
424
|
-
end
|
425
|
-
|
426
|
-
it "should decide names of solr fields" do
|
427
|
-
cdate = "2008-07-02T05:09:42Z"
|
428
|
-
mdate = "2009-07-07T23:37:18Z"
|
429
|
-
@test_object.stub(:create_date).and_return(cdate)
|
430
|
-
@test_object.stub(:modified_date).and_return(mdate)
|
431
|
-
|
432
|
-
solr_doc = @test_object.to_solr
|
433
|
-
[:system_create_dt, :system_modified_dt, :active_fedora_model_s].each do |fn|
|
434
|
-
solr_doc[fn].should == nil
|
435
|
-
end
|
436
|
-
solr_doc["system_create_date"].should eql(cdate)
|
437
|
-
solr_doc["system_modified_date"].should eql(mdate)
|
438
|
-
solr_doc[:id].should eql("#{@test_object.pid}")
|
439
|
-
solr_doc["active_fedora_model_field"].should eql(@test_object.class.inspect)
|
440
|
-
end
|
441
|
-
end
|
442
|
-
|
443
417
|
it "should call .to_solr on all SimpleDatastreams and OmDatastreams, passing the resulting document to solr" do
|
444
418
|
mock1 = mock("ds1", :to_solr => {})
|
445
419
|
mock2 = mock("ds2", :to_solr => {})
|
@@ -660,10 +634,10 @@ pending "This is broken, and deprecated. I don't want to fix it - jcoyne"
|
|
660
634
|
|
661
635
|
@test_object.should_receive(:relationships).and_return(graph)
|
662
636
|
solr_doc = @test_object.solrize_relationships
|
663
|
-
solr_doc["
|
664
|
-
solr_doc["
|
665
|
-
solr_doc["
|
666
|
-
solr_doc["
|
637
|
+
solr_doc[ActiveFedora::SolrService.solr_name("is_member_of", :symbol)].should == ["info:fedora/demo:10"]
|
638
|
+
solr_doc[ActiveFedora::SolrService.solr_name("is_part_of", :symbol)].should == ["info:fedora/demo:11"]
|
639
|
+
solr_doc[ActiveFedora::SolrService.solr_name("has_part", :symbol)].should == ["info:fedora/demo:12"]
|
640
|
+
solr_doc[ActiveFedora::SolrService.solr_name("conforms_to", :symbol)].should == ["AnInterface"]
|
667
641
|
end
|
668
642
|
end
|
669
643
|
end
|
@@ -173,25 +173,19 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
173
173
|
end
|
174
174
|
it "should iterate through @fields hash" do
|
175
175
|
solr_doc = @subject.to_solr
|
176
|
-
solr_doc["
|
177
|
-
solr_doc["
|
178
|
-
solr_doc["
|
179
|
-
solr_doc["
|
180
|
-
solr_doc["
|
181
|
-
solr_doc["
|
182
|
-
solr_doc["
|
183
|
-
solr_doc["
|
184
|
-
solr_doc["
|
185
|
-
solr_doc["
|
186
|
-
solr_doc["
|
187
|
-
solr_doc["
|
188
|
-
solr_doc["
|
189
|
-
solr_doc["solr_rdf__empty_field_t"].should be_nil
|
190
|
-
|
191
|
-
#should NOT have these
|
192
|
-
solr_doc["solr_rdf__narrator"].should be_nil
|
193
|
-
solr_doc["solr_rdf__empty_field"].should be_nil
|
194
|
-
solr_doc["solr_rdf__creator"].should be_nil
|
176
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :string, :searchable)].should == ["publisher1"]
|
177
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :string, :sortable)].should == ["publisher1"]
|
178
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :string, :displayable)].should == ["publisher1"]
|
179
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :string, :facetable)].should == ["publisher1"]
|
180
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :string, :searchable)].should == ["coverage1", "coverage2"]
|
181
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :string, :displayable)].should == ["coverage1", "coverage2"]
|
182
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :string, :facetable)].should == ["coverage1", "coverage2"]
|
183
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :string, :sortable)].should == ["2009-10-10"]
|
184
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :string, :displayable)].should == ["2009-10-10"]
|
185
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :string, :searchable)].should == ["fake-title"]
|
186
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :string, :sortable)].should == ["fake-title"]
|
187
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :string, :displayable)].should == ["fake-title"]
|
188
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", :string, :searchable)].should == ["http://example.org/"]
|
195
189
|
end
|
196
190
|
|
197
191
|
describe "with an actual object" do
|
@@ -235,17 +229,25 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
235
229
|
end
|
236
230
|
describe ".to_solr()" do
|
237
231
|
it "should return the right fields" do
|
238
|
-
@obj.to_solr.keys.
|
239
|
-
|
240
|
-
"
|
241
|
-
"
|
242
|
-
"
|
232
|
+
@obj.to_solr.keys.should include(ActiveFedora::SolrService.solr_name("solr_rdf__related_url", :string, :searchable),
|
233
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :string, :searchable),
|
234
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :string, :sortable),
|
235
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :string, :displayable),
|
236
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :string, :facetable),
|
237
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__created", :string, :sortable),
|
238
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__created", :string, :displayable),
|
239
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__title", :string, :searchable),
|
240
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__title", :string, :sortable),
|
241
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__title", :string, :displayable),
|
242
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :string, :searchable),
|
243
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :string, :facetable),
|
244
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :string, :displayable))
|
243
245
|
|
244
246
|
end
|
245
247
|
|
246
248
|
it "should return the right values" do
|
247
|
-
@obj.to_solr["
|
248
|
-
@obj.to_solr["
|
249
|
+
@obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", :string, :searchable)].should == ["http://example.org/blogtastic/"]
|
250
|
+
@obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :string, :searchable)].should == ["Tacoma, WA","Renton, WA"]
|
249
251
|
end
|
250
252
|
end
|
251
253
|
end
|
@@ -9,7 +9,13 @@ describe ActiveFedora::OmDatastream do
|
|
9
9
|
:empty_field => {:values => {}}
|
10
10
|
}
|
11
11
|
@sample_raw_xml = "<foo><xmlelement/></foo>"
|
12
|
-
@solr_doc = {"id"=>"hydrange_article1",
|
12
|
+
@solr_doc = {"id"=>"hydrange_article1",
|
13
|
+
ActiveFedora::SolrService.solr_name("name_role_roleTerm", :string, :searchable) =>["creator","submitter","teacher"],
|
14
|
+
ActiveFedora::SolrService.solr_name("name_0_role", :string, :searchable)=>"\r\ncreator\r\nsubmitter\r\n",
|
15
|
+
ActiveFedora::SolrService.solr_name("name_1_role", :string, :searchable)=>"\r\n teacher \r\n",
|
16
|
+
ActiveFedora::SolrService.solr_name("name_0_role_0_roleTerm", :string, :searchable)=>"creator",
|
17
|
+
ActiveFedora::SolrService.solr_name("name_0_role_1_roleTerm", :string, :searchable)=>"submitter",
|
18
|
+
ActiveFedora::SolrService.solr_name("name_1_role_0_roleTerm", :string, :searchable)=>["teacher"]}
|
13
19
|
end
|
14
20
|
|
15
21
|
before(:each) do
|
@@ -47,7 +53,6 @@ describe ActiveFedora::OmDatastream do
|
|
47
53
|
it "should initialize from #xml_template if no xml is provided" do
|
48
54
|
ActiveFedora::OmDatastream.should_receive(:xml_template).and_return("<fake template/>")
|
49
55
|
n = ActiveFedora::OmDatastream.new
|
50
|
-
n.ensure_xml_loaded
|
51
56
|
n.ng_xml.should be_equivalent_to("<fake template/>")
|
52
57
|
end
|
53
58
|
end
|
@@ -303,11 +308,11 @@ describe ActiveFedora::OmDatastream do
|
|
303
308
|
|
304
309
|
describe '.has_solr_name?' do
|
305
310
|
it "should return true if the given key exists in the solr document passed in" do
|
306
|
-
@test_ds.has_solr_name?("
|
307
|
-
@test_ds.has_solr_name?(:
|
308
|
-
@test_ds.has_solr_name?("
|
311
|
+
@test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("name_0_role_0_roleTerm", :string, :searchable),@solr_doc).should == true
|
312
|
+
@test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("name_0_role_0_roleTerm", :string, :searchable).to_sym,@solr_doc).should == true
|
313
|
+
@test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("name_1_role_1_roleTerm", :string, :searchable),@solr_doc).should == false
|
309
314
|
#if not doc passed in should be new empty solr doc and always return false
|
310
|
-
@test_ds.has_solr_name?("
|
315
|
+
@test_ds.has_solr_name?(ActiveFedora::SolrService.solr_name("name_0_role_0_roleTerm", :string, :searchable)).should == false
|
311
316
|
end
|
312
317
|
end
|
313
318
|
|
@@ -110,7 +110,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
|
|
110
110
|
@test_ds = ActiveFedora::QualifiedDublinCoreDatastream.new(nil, 'qdc' )
|
111
111
|
@test_ds.title = "War and Peace"
|
112
112
|
solr = @test_ds.to_solr
|
113
|
-
solr[
|
113
|
+
solr[ActiveFedora::SolrService.solr_name('title', :string, :searchable)].should == ["War and Peace"]
|
114
114
|
end
|
115
115
|
|
116
116
|
end
|
data/spec/unit/query_spec.rb
CHANGED
@@ -7,7 +7,8 @@ describe ActiveFedora::Base do
|
|
7
7
|
class Basic < ActiveFedora::Base
|
8
8
|
end
|
9
9
|
end
|
10
|
-
@model_query = "
|
10
|
+
@model_query = ActiveFedora::SolrService.solr_name("has_model", :symbol) + ":#{solr_uri("info:fedora/afmodel:SpecModel_Basic")}"
|
11
|
+
@sort_query = ActiveFedora::SolrService.solr_name("system_create", :date, :searchable) + ' asc'
|
11
12
|
end
|
12
13
|
|
13
14
|
after(:all) do
|
@@ -23,7 +24,7 @@ describe ActiveFedora::Base do
|
|
23
24
|
SpecModel::Basic.should_receive(:find_one).with("changeme:22", nil).and_return("Fake Object2")
|
24
25
|
mock_docs = [{"id" => "changeme:30"}, {"id" => "changeme:22"}]
|
25
26
|
mock_docs.should_receive(:has_next?).and_return(false)
|
26
|
-
ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with(1, 1000, 'select', :params=>{:q=>@model_query, :qt => 'standard', :sort => [
|
27
|
+
ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with(1, 1000, 'select', :params=>{:q=>@model_query, :qt => 'standard', :sort => [@sort_query], :fl=> 'id', }).and_return('response'=>{'docs'=>mock_docs})
|
27
28
|
SpecModel::Basic.find(:all).should == ["Fake Object1", "Fake Object2"]
|
28
29
|
end
|
29
30
|
end
|
@@ -33,7 +34,7 @@ describe ActiveFedora::Base do
|
|
33
34
|
ActiveFedora::Base.should_receive(:find_one).with("changeme:22", nil).and_return("Fake Object2")
|
34
35
|
mock_docs = [{"id" => "changeme:30"},{"id" => "changeme:22"}]
|
35
36
|
mock_docs.should_receive(:has_next?).and_return(false)
|
36
|
-
ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with(1, 1000, 'select', :params=>{:q=>'*:*', :qt => 'standard', :sort => [
|
37
|
+
ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with(1, 1000, 'select', :params=>{:q=>'*:*', :qt => 'standard', :sort => [@sort_query], :fl=> 'id', }).and_return('response'=>{'docs'=>mock_docs})
|
37
38
|
ActiveFedora::Base.find(:all).should == ["Fake Object1", "Fake Object2"]
|
38
39
|
end
|
39
40
|
end
|
@@ -71,7 +72,7 @@ describe ActiveFedora::Base do
|
|
71
72
|
rows == 1000 &&
|
72
73
|
method == 'select' &&
|
73
74
|
hash[:params] &&
|
74
|
-
hash[:params][:sort] == [
|
75
|
+
hash[:params][:sort] == [@sort_query] &&
|
75
76
|
hash[:params][:fl] == 'id' &&
|
76
77
|
hash[:params][:q].split(" AND ").include?(@model_query) &&
|
77
78
|
hash[:params][:q].split(" AND ").include?("foo:\"bar\"") &&
|
@@ -88,7 +89,7 @@ describe ActiveFedora::Base do
|
|
88
89
|
it "should query solr for all objects with :active_fedora_model_s of self.class" do
|
89
90
|
mock_docs = [{"id" => "changeme:30"},{"id" => "changeme:22"}]
|
90
91
|
mock_docs.should_receive(:has_next?).and_return(false)
|
91
|
-
ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with(1, 1000, 'select', :params=>{:q=>@model_query, :qt => 'standard', :sort => [
|
92
|
+
ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with(1, 1000, 'select', :params=>{:q=>@model_query, :qt => 'standard', :sort => [@sort_query], :fl=> 'id', }).and_return('response'=>{'docs'=>mock_docs})
|
92
93
|
|
93
94
|
SpecModel::Basic.should_receive(:find_one).with("changeme:30", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:30'))
|
94
95
|
SpecModel::Basic.should_receive(:find_one).with("changeme:22", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:22'))
|
@@ -108,7 +109,7 @@ describe ActiveFedora::Base do
|
|
108
109
|
rows == 1000 &&
|
109
110
|
method == 'select' &&
|
110
111
|
hash[:params] &&
|
111
|
-
hash[:params][:sort] == [
|
112
|
+
hash[:params][:sort] == [@sort_query] &&
|
112
113
|
hash[:params][:fl] == 'id' &&
|
113
114
|
hash[:params][:q].split(" AND ").include?(@model_query) &&
|
114
115
|
hash[:params][:q].split(" AND ").include?("foo:\"bar\"") &&
|
@@ -132,7 +133,7 @@ describe ActiveFedora::Base do
|
|
132
133
|
rows == 1002 &&
|
133
134
|
method == 'select' &&
|
134
135
|
hash[:params] &&
|
135
|
-
hash[:params][:sort] == [
|
136
|
+
hash[:params][:sort] == [@sort_query] &&
|
136
137
|
hash[:params][:fl] == 'id' &&
|
137
138
|
hash[:params][:q].split(" AND ").include?(@model_query) &&
|
138
139
|
hash[:params][:q].split(" AND ").include?("foo:\"bar\"") &&
|
@@ -196,12 +197,12 @@ describe ActiveFedora::Base do
|
|
196
197
|
|
197
198
|
it "shouldn't use the class if it's called on AF:Base " do
|
198
199
|
mock_result = stub('Result')
|
199
|
-
ActiveFedora::SolrService.should_receive(:query).with('baz:"quack"', {:sort => [
|
200
|
+
ActiveFedora::SolrService.should_receive(:query).with('baz:"quack"', {:sort => [@sort_query]}).and_return(mock_result)
|
200
201
|
ActiveFedora::Base.find_with_conditions(:baz=>'quack').should == mock_result
|
201
202
|
end
|
202
203
|
it "should use the query string if it's provided" do
|
203
204
|
mock_result = stub('Result')
|
204
|
-
ActiveFedora::SolrService.should_receive(:query).with('chunky:monkey', {:sort => [
|
205
|
+
ActiveFedora::SolrService.should_receive(:query).with('chunky:monkey', {:sort => [@sort_query]}).and_return(mock_result)
|
205
206
|
ActiveFedora::Base.find_with_conditions('chunky:monkey').should == mock_result
|
206
207
|
end
|
207
208
|
end
|
@@ -20,9 +20,9 @@ describe ActiveFedora::Relationships do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
before(:all) do
|
23
|
-
@part_of_sample = "
|
24
|
-
@constituent_of_sample = "
|
25
|
-
@is_part_query = "
|
23
|
+
@part_of_sample = ActiveFedora::SolrService.solr_name("is_part_of", :symbol) + ":#{solr_uri("info:fedora/test:sample_pid")}"
|
24
|
+
@constituent_of_sample = ActiveFedora::SolrService.solr_name("is_constituent_of", :symbol) + ":#{solr_uri("info:fedora/test:sample_pid")}"
|
25
|
+
@is_part_query = ActiveFedora::SolrService.solr_name("has_model", :symbol) + ":#{solr_uri("info:fedora/SpecialPart")}"
|
26
26
|
end
|
27
27
|
|
28
28
|
before(:each) do
|
@@ -181,9 +181,9 @@ describe ActiveFedora::Relationships do
|
|
181
181
|
end
|
182
182
|
|
183
183
|
it "resulting finder should search against solr and use Model#find to build an array of objects" do
|
184
|
-
@sample_solr_hits = [{"id"=>"_PID1_",
|
185
|
-
{"id"=>"_PID2_",
|
186
|
-
{"id"=>"_PID3_",
|
184
|
+
@sample_solr_hits = [{"id"=>"_PID1_", ActiveFedora::SolrService.solr_name('has_model', :symbol)=>["info:fedora/afmodel:AudioRecord"]},
|
185
|
+
{"id"=>"_PID2_", ActiveFedora::SolrService.solr_name('has_model', :symbol)=>["info:fedora/afmodel:AudioRecord"]},
|
186
|
+
{"id"=>"_PID3_", ActiveFedora::SolrService.solr_name('has_model', :symbol)=>["info:fedora/afmodel:AudioRecord"]}]
|
187
187
|
SpecNode.create_inbound_relationship_finders("parts", :is_part_of, :inbound => true)
|
188
188
|
local_node = SpecNode.new()
|
189
189
|
local_node.should_receive(:pid).and_return("test:sample_pid")
|
@@ -256,9 +256,9 @@ describe ActiveFedora::Relationships do
|
|
256
256
|
local_node.should_receive(:ids_for_outbound).with(:is_member_of).and_return(["my:_PID1_", "my:_PID2_", "my:_PID3_"])
|
257
257
|
|
258
258
|
#ActiveFedora::ContentModel.should_receive(:known_models_for).and_return([SpecNode]).times(3)
|
259
|
-
ActiveFedora::SolrService.should_receive(:query).with("id:my\\:_PID1_ OR id:my\\:_PID2_ OR id:my\\:_PID3_").and_return([{"id"=> "my:_PID1_",
|
260
|
-
{"id"=> "my:_PID2_",
|
261
|
-
{"id"=> "my:_PID3_",
|
259
|
+
ActiveFedora::SolrService.should_receive(:query).with("id:my\\:_PID1_ OR id:my\\:_PID2_ OR id:my\\:_PID3_").and_return([{"id"=> "my:_PID1_", ActiveFedora::SolrService.solr_name('has_model', :symbol)=>["info:fedora/afmodel:SpecNode"]},
|
260
|
+
{"id"=> "my:_PID2_", ActiveFedora::SolrService.solr_name('has_model', :symbol)=>["info:fedora/afmodel:SpecNode"]},
|
261
|
+
{"id"=> "my:_PID3_", ActiveFedora::SolrService.solr_name('has_model', :symbol)=>["info:fedora/afmodel:SpecNode"]}])
|
262
262
|
ActiveFedora::DigitalObject.should_receive(:find).with(SpecNode, 'my:_PID1_').and_return(stub("inner obj", :'new?'=>false, :pid=>'my:_PID1_'))
|
263
263
|
ActiveFedora::DigitalObject.should_receive(:find).with(SpecNode, 'my:_PID2_').and_return(stub("inner obj", :'new?'=>false, :pid=>'my:_PID2_'))
|
264
264
|
ActiveFedora::DigitalObject.should_receive(:find).with(SpecNode, 'my:_PID3_').and_return(stub("inner obj", :'new?'=>false, :pid=>'my:_PID3_'))
|
@@ -462,13 +462,13 @@ describe ActiveFedora::Relationships do
|
|
462
462
|
describe "relationship_query" do
|
463
463
|
before do
|
464
464
|
class MockNamedRelationshipQuery < SpecNode
|
465
|
-
register_relationship_desc(:inbound, "testing_inbound_query", :is_part_of, :type=>SpecNode, :solr_fq=>"
|
465
|
+
register_relationship_desc(:inbound, "testing_inbound_query", :is_part_of, :type=>SpecNode, :solr_fq=>"#{ActiveFedora::SolrService.solr_name('has_model', :symbol)}:info\\:fedora/SpecialPart")
|
466
466
|
register_relationship_desc(:inbound, "testing_inbound_no_solr_fq", :is_part_of, :type=>SpecNode)
|
467
|
-
register_relationship_desc(:self, "testing_outbound_query", :is_part_of, :type=>SpecNode, :solr_fq=>"
|
467
|
+
register_relationship_desc(:self, "testing_outbound_query", :is_part_of, :type=>SpecNode, :solr_fq=>"#{ActiveFedora::SolrService.solr_name('has_model', :symbol)}:info\\:fedora/SpecialPart")
|
468
468
|
register_relationship_desc(:self, "testing_outbound_no_solr_fq", :is_part_of, :type=>SpecNode)
|
469
469
|
#for bidirectional relationship testing need to register both outbound and inbound names
|
470
|
-
register_relationship_desc(:self, "testing_bi_query_outbound", :has_part, :type=>SpecNode, :solr_fq=>"
|
471
|
-
register_relationship_desc(:inbound, "testing_bi_query_inbound", :is_part_of, :type=>SpecNode, :solr_fq=>"
|
470
|
+
register_relationship_desc(:self, "testing_bi_query_outbound", :has_part, :type=>SpecNode, :solr_fq=>"#{ActiveFedora::SolrService.solr_name('has_model', :symbol)}:info\\:fedora/SpecialPart")
|
471
|
+
register_relationship_desc(:inbound, "testing_bi_query_inbound", :is_part_of, :type=>SpecNode, :solr_fq=>"#{ActiveFedora::SolrService.solr_name('has_model', :symbol)}:info\\:fedora/SpecialPart")
|
472
472
|
register_relationship_desc(:self, "testing_bi_no_solr_fq_outbound", :has_part, :type=>SpecNode)
|
473
473
|
register_relationship_desc(:inbound, "testing_bi_no_solr_fq_inbound", :is_part_of, :type=>SpecNode)
|
474
474
|
end
|
@@ -766,8 +766,8 @@ describe ActiveFedora::Relationships do
|
|
766
766
|
describe "bidirectional_relationship_query" do
|
767
767
|
before do
|
768
768
|
class MockBiNamedRelationshipQuery < SpecNode
|
769
|
-
register_relationship_desc(:self, "testing_query_outbound", :has_part, :type=>SpecNode, :solr_fq=>"
|
770
|
-
register_relationship_desc(:inbound, "testing_query_inbound", :is_part_of, :type=>SpecNode, :solr_fq=>"
|
769
|
+
register_relationship_desc(:self, "testing_query_outbound", :has_part, :type=>SpecNode, :solr_fq=>"#{ActiveFedora::SolrService.solr_name('has_model', :symbol)}:info\\:fedora\\/SpecialPart")
|
770
|
+
register_relationship_desc(:inbound, "testing_query_inbound", :is_part_of, :type=>SpecNode, :solr_fq=>"#{ActiveFedora::SolrService.solr_name('has_model', :symbol)}:info\\:fedora\\/SpecialPart")
|
771
771
|
create_bidirectional_relationship_name_methods("testing","testing_outbound")
|
772
772
|
register_relationship_desc(:self, "testing_no_solr_fq_outbound", :has_part, :type=>SpecNode)
|
773
773
|
register_relationship_desc(:inbound, "testing_no_solr_fq_inbound", :is_part_of, :type=>SpecNode)
|
@@ -796,7 +796,7 @@ describe ActiveFedora::Relationships do
|
|
796
796
|
expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND #{@is_part_query})"
|
797
797
|
end
|
798
798
|
expected_string << " OR "
|
799
|
-
expected_string << "(
|
799
|
+
expected_string << "(#{ActiveFedora::SolrService.solr_name('is_part_of', :symbol)}:info\\:fedora\\/changeme\\:6 AND #{@is_part_query})"
|
800
800
|
MockBiNamedRelationshipQuery.bidirectional_relationship_query("changeme:6","testing_query",ids).should == expected_string
|
801
801
|
end
|
802
802
|
|
@@ -808,7 +808,7 @@ describe ActiveFedora::Relationships do
|
|
808
808
|
expected_string << "id:" + id.gsub(/(:)/, '\\:')
|
809
809
|
end
|
810
810
|
expected_string << " OR "
|
811
|
-
expected_string << "(
|
811
|
+
expected_string << "(#{ActiveFedora::SolrService.solr_name('is_part_of', :symbol)}:info\\:fedora\\/changeme\\:6)"
|
812
812
|
MockBiNamedRelationshipQuery.bidirectional_relationship_query("changeme:6","testing_no_solr_fq",ids).should == expected_string
|
813
813
|
end
|
814
814
|
end
|
@@ -816,7 +816,7 @@ describe ActiveFedora::Relationships do
|
|
816
816
|
describe "inbound_relationship_query" do
|
817
817
|
before do
|
818
818
|
class MockInboundNamedRelationshipQuery < SpecNode
|
819
|
-
register_relationship_desc(:inbound, "testing_inbound_query", :is_part_of, :type=>SpecNode, :solr_fq=>"
|
819
|
+
register_relationship_desc(:inbound, "testing_inbound_query", :is_part_of, :type=>SpecNode, :solr_fq=>"#{ActiveFedora::SolrService.solr_name('has_model', :symbol)}:#{solr_uri("info:fedora/SpecialPart")}")
|
820
820
|
register_relationship_desc(:inbound, "testing_inbound_no_solr_fq", :is_part_of, :type=>SpecNode)
|
821
821
|
end
|
822
822
|
end
|
@@ -825,11 +825,11 @@ describe ActiveFedora::Relationships do
|
|
825
825
|
end
|
826
826
|
|
827
827
|
it "should return a properly formatted query for a relationship that has a solr filter query defined" do
|
828
|
-
MockInboundNamedRelationshipQuery.inbound_relationship_query("changeme:1","testing_inbound_query").should == "
|
828
|
+
MockInboundNamedRelationshipQuery.inbound_relationship_query("changeme:1","testing_inbound_query").should == "#{ActiveFedora::SolrService.solr_name('is_part_of', :symbol)}:info\\:fedora\\/changeme\\:1 AND #{@is_part_query}"
|
829
829
|
end
|
830
830
|
|
831
831
|
it "should return a properly formatted query for a relationship that does not have a solr filter query defined" do
|
832
|
-
MockInboundNamedRelationshipQuery.inbound_relationship_query("changeme:1","testing_inbound_no_solr_fq").should == "
|
832
|
+
MockInboundNamedRelationshipQuery.inbound_relationship_query("changeme:1","testing_inbound_no_solr_fq").should == "#{ActiveFedora::SolrService.solr_name('is_part_of', :symbol)}:info\\:fedora\\/changeme\\:1"
|
833
833
|
end
|
834
834
|
end
|
835
835
|
|
@@ -839,7 +839,7 @@ describe ActiveFedora::Relationships do
|
|
839
839
|
describe "outbound_relationship_query" do
|
840
840
|
before do
|
841
841
|
class MockOutboundNamedRelationshipQuery < SpecNode
|
842
|
-
register_relationship_desc(:self, "testing_query", :is_part_of, :type=>SpecNode, :solr_fq=>"
|
842
|
+
register_relationship_desc(:self, "testing_query", :is_part_of, :type=>SpecNode, :solr_fq=>"#{ActiveFedora::SolrService.solr_name('has_model', :symbol)}:#{solr_uri("info:fedora/SpecialPart")}")
|
843
843
|
register_relationship_desc(:self,"testing_no_solr_fq", :is_part_of, :type=>SpecNode)
|
844
844
|
end
|
845
845
|
end
|
@@ -852,7 +852,7 @@ describe ActiveFedora::Relationships do
|
|
852
852
|
expected_string = ""
|
853
853
|
ids.each_with_index do |id,index|
|
854
854
|
expected_string << " OR " if index > 0
|
855
|
-
expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND
|
855
|
+
expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND #{ActiveFedora::SolrService.solr_name('has_model', :symbol)}:#{solr_uri("info:fedora/SpecialPart")})"
|
856
856
|
end
|
857
857
|
MockOutboundNamedRelationshipQuery.outbound_relationship_query("testing_query",ids).should == expected_string
|
858
858
|
end
|
@@ -54,8 +54,8 @@ describe ActiveFedora::SimpleDatastream do
|
|
54
54
|
describe "#to_solr" do
|
55
55
|
it "should have title" do
|
56
56
|
solr = @test_ds.to_solr
|
57
|
-
solr[
|
58
|
-
solr[
|
57
|
+
solr[ActiveFedora::SolrService.solr_name('publisher', :string, :searchable)].should == ["publisher1"]
|
58
|
+
solr[ActiveFedora::SolrService.solr_name('creation_date', :date)].should == ["2012-01-15"]
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -19,22 +19,6 @@ describe ActiveFedora do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
|
22
|
-
describe "field name mappings" do
|
23
|
-
after(:all) do
|
24
|
-
# Revert to default mappings after running tests
|
25
|
-
# ActiveFedora::SolrService.load_mappings
|
26
|
-
end
|
27
|
-
# it "should default to using the mappings for the current schema" do
|
28
|
-
# from_default_yml = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings.yml")))
|
29
|
-
# ActiveFedora::SolrService.mappings[:searchable].data_types[:date].opts[:suffix].should == from_default_yml["searchable"]["date"]
|
30
|
-
# end
|
31
|
-
# it "should allow you to provide your own mappings file" do
|
32
|
-
# ActiveFedora::SolrService.load_mappings(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings_af_0.1.yml"))
|
33
|
-
# ActiveFedora::SolrService.mappings[:searchable].data_types[:date].opts[:suffix].should == "_date"
|
34
|
-
# ActiveFedora::SolrService.mappings[:searchable].data_types[:default].opts[:suffix].should == "_field"
|
35
|
-
# end
|
36
|
-
end
|
37
|
-
|
38
22
|
describe "SOLR_DOCUMENT_ID" do
|
39
23
|
before(:all) do
|
40
24
|
SOLR_DOCUMENT_ID = "MY_SAMPLE_ID"
|
@@ -50,7 +34,7 @@ describe ActiveFedora do
|
|
50
34
|
|
51
35
|
it "should be used by ActiveFedora::Base#find_with_conditions" do
|
52
36
|
mock_response = mock("SolrResponse")
|
53
|
-
ActiveFedora::SolrService.should_receive(:query).with("
|
37
|
+
ActiveFedora::SolrService.should_receive(:query).with("#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:info\\:fedora\\/afmodel\\:SolrSpecModel_Basic AND " + SOLR_DOCUMENT_ID + ':"changeme\\:30"', {:sort => ["#{ActiveFedora::SolrService.solr_name("system_create", :date)} asc"]}).and_return(mock_response)
|
54
38
|
|
55
39
|
SolrSpecModel::Basic.find_with_conditions(:id=>"changeme:30").should equal(mock_response)
|
56
40
|
end
|
@@ -45,9 +45,9 @@ describe ActiveFedora::SolrService do
|
|
45
45
|
def self.connection_for_pid(pid)
|
46
46
|
end
|
47
47
|
end
|
48
|
-
@sample_solr_hits = [{"id"=>"my:_PID1_", "
|
49
|
-
{"id"=>"my:_PID2_", "
|
50
|
-
{"id"=>"my:_PID3_", "
|
48
|
+
@sample_solr_hits = [{"id"=>"my:_PID1_", ActiveFedora::SolrService.solr_name("has_model", :symbol)=>["info:fedora/afmodel:AudioRecord"]},
|
49
|
+
{"id"=>"my:_PID2_", ActiveFedora::SolrService.solr_name("has_model", :symbol)=>["info:fedora/afmodel:AudioRecord"]},
|
50
|
+
{"id"=>"my:_PID3_", ActiveFedora::SolrService.solr_name("has_model", :symbol)=>["info:fedora/afmodel:AudioRecord"]}]
|
51
51
|
end
|
52
52
|
it "should use Repository.find to instantiate objects" do
|
53
53
|
AudioRecord.should_receive(:find).with("my:_PID1_")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.5.
|
4
|
+
version: 5.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-01-
|
14
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rsolr
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
67
67
|
none: false
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - ! '>='
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: 2.1.0
|
72
72
|
type: :runtime
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
version_requirements: !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
|
-
- -
|
77
|
+
- - ! '>='
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: 2.1.0
|
80
80
|
- !ruby/object:Gem::Dependency
|
@@ -565,7 +565,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
565
565
|
version: '0'
|
566
566
|
segments:
|
567
567
|
- 0
|
568
|
-
hash:
|
568
|
+
hash: 2863321787483919709
|
569
569
|
requirements: []
|
570
570
|
rubyforge_project: rubyfedora
|
571
571
|
rubygems_version: 1.8.24
|