active-fedora 5.0.0.rc2 → 5.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -9
- data/active-fedora.gemspec +1 -1
- data/lib/active_fedora.rb +1 -0
- data/lib/active_fedora/callbacks.rb +5 -6
- data/lib/active_fedora/model.rb +0 -149
- data/lib/active_fedora/persistence.rb +4 -0
- data/lib/active_fedora/rdf_datastream.rb +0 -2
- data/lib/active_fedora/rdf_xml_writer.rb +0 -1
- data/lib/active_fedora/rels_ext_datastream.rb +0 -1
- data/lib/active_fedora/semantic_node.rb +0 -1
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora_dev.rake +3 -5
- data/solr/conf/schema.xml +5 -5
- data/solr/conf/solrconfig.xml +221 -767
- data/spec/integration/base_spec.rb +0 -8
- data/spec/integration/model_spec.rb +0 -10
- data/spec/samples/models/hydrangea_article.rb +2 -2
- data/spec/unit/base_spec.rb +0 -17
- data/spec/unit/callback_spec.rb +10 -3
- data/spec/unit/model_spec.rb +0 -23
- metadata +18 -23
- data/solr/config/schema-1.5.xml +0 -468
- data/solr/config/schema.xml +0 -191
- data/solr/config/solrconfig-1.5.xml +0 -1069
- data/spec/integration/base_find_by_fields_spec.rb +0 -225
@@ -1,225 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class MockAFBaseQuerySolr < ActiveFedora::Base
|
4
|
-
has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream do |m|
|
5
|
-
m.field "holding_id", :string
|
6
|
-
end
|
7
|
-
|
8
|
-
has_metadata :name => "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream do |m|
|
9
|
-
m.field "created", :date, :xml_node => "created"
|
10
|
-
m.field "language", :string, :xml_node => "language"
|
11
|
-
m.field "creator", :string, :xml_node => "creator"
|
12
|
-
# Created remaining fields
|
13
|
-
m.field "geography", :string, :xml_node => "geography"
|
14
|
-
m.field "title", :string, :xml_node => "title"
|
15
|
-
end
|
16
|
-
|
17
|
-
has_metadata :name=>'ng_metadata', :type=> Hydra::ModsArticleDatastream
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ActiveFedora::Base do
|
21
|
-
|
22
|
-
before(:all) do
|
23
|
-
@test_object = ActiveFedora::Base.new
|
24
|
-
#get objects into fedora and solr
|
25
|
-
@test_object2 = MockAFBaseQuerySolr.new
|
26
|
-
attributes = {[:holding_id]=>{0=>"Holding 1"},
|
27
|
-
[:language]=>{0=>"Italian"},
|
28
|
-
[:creator]=>{0=>"Linguist, A."},
|
29
|
-
[:geography]=>{0=>"Italy"},
|
30
|
-
[:title]=>{0=>"Italian and Spanish: A Comparison of Common Phrases"}}
|
31
|
-
@test_object2.update_indexed_attributes(attributes)
|
32
|
-
@test_object2.save
|
33
|
-
slr = @test_object2.to_solr
|
34
|
-
# puts "PID: #{@test_object2.pid}"
|
35
|
-
# puts "ID: #{slr[:id]} #{slr["active_fedora_model_s"]}"
|
36
|
-
sleep(1)
|
37
|
-
|
38
|
-
@test_object3 = MockAFBaseQuerySolr.new
|
39
|
-
attributes = {[:holding_id]=>{0=>"Holding 2"},
|
40
|
-
[:language]=>{0=>"Spanish;Latin"},
|
41
|
-
[:creator]=>{0=>"Linguist, A."},
|
42
|
-
[:geography]=>{0=>"Spain"},
|
43
|
-
[:title]=>{0=>"A study of the evolution of Spanish from Latin"}}
|
44
|
-
@test_object3.update_indexed_attributes(attributes)
|
45
|
-
@test_object3.save
|
46
|
-
sleep(1)
|
47
|
-
|
48
|
-
@test_object4 = MockAFBaseQuerySolr.new
|
49
|
-
attributes = {[:holding_id]=>{0=>"Holding 3"},
|
50
|
-
[:language]=>{0=>"Spanish;Latin"},
|
51
|
-
[:creator]=>{0=>"Linguist, A."},
|
52
|
-
[:geography]=>{0=>"Spain"},
|
53
|
-
[:title]=>{0=>"An obscure look into early nomadic tribes of Spain"}}
|
54
|
-
@test_object4.update_indexed_attributes(attributes)
|
55
|
-
@test_object4.save
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
after(:all) do
|
60
|
-
begin
|
61
|
-
@test_object.delete
|
62
|
-
rescue
|
63
|
-
end
|
64
|
-
begin
|
65
|
-
@test_object2.delete
|
66
|
-
rescue
|
67
|
-
end
|
68
|
-
begin
|
69
|
-
@test_object3.delete
|
70
|
-
rescue
|
71
|
-
end
|
72
|
-
begin
|
73
|
-
@test_object4.delete
|
74
|
-
rescue
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#find_by_fields_by_solr' do
|
79
|
-
it 'should return fedora objects of the correct class' do
|
80
|
-
#query based on just model
|
81
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({})
|
82
|
-
found_pids = []
|
83
|
-
results.each do |hit|
|
84
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
85
|
-
end
|
86
|
-
|
87
|
-
found_pids.should == [@test_object2.pid,@test_object3.pid,@test_object4.pid]
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should match a query against multiple result fields' do
|
91
|
-
#query on certain fields
|
92
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"language"=>"Latin"})
|
93
|
-
found_pids = []
|
94
|
-
results.each do |hit|
|
95
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
96
|
-
end
|
97
|
-
|
98
|
-
found_pids.should == [@test_object3.pid,@test_object4.pid]
|
99
|
-
|
100
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"language"=>"Italian"})
|
101
|
-
found_pids = []
|
102
|
-
results.each do |hit|
|
103
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
104
|
-
end
|
105
|
-
|
106
|
-
found_pids.should== [@test_object2.pid]
|
107
|
-
|
108
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"language"=>"Spanish"})
|
109
|
-
found_pids = []
|
110
|
-
results.each do |hit|
|
111
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
112
|
-
end
|
113
|
-
|
114
|
-
found_pids.should == [@test_object3.pid,@test_object4.pid]
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'should query against many fields' do
|
118
|
-
#assume spaces removed at index time so query by 'Linguist,A.' instead of 'Linguist, A.'
|
119
|
-
|
120
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A.","title"=>"latin"})
|
121
|
-
found_pids = []
|
122
|
-
results.each do |hit|
|
123
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
124
|
-
end
|
125
|
-
|
126
|
-
found_pids.should == [@test_object3.pid]
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'should query by id' do
|
130
|
-
|
131
|
-
#query with value with embedded ':' (pid)
|
132
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"id"=>@test_object3.pid})
|
133
|
-
found_pids = []
|
134
|
-
results.each do |hit|
|
135
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
136
|
-
end
|
137
|
-
|
138
|
-
found_pids.should == [@test_object3.pid]
|
139
|
-
end
|
140
|
-
|
141
|
-
|
142
|
-
it "should sort by default by system_create_date" do
|
143
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A.","language"=>"Spanish"})
|
144
|
-
found_pids = []
|
145
|
-
results.each do |hit|
|
146
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
147
|
-
end
|
148
|
-
|
149
|
-
found_pids.should == [@test_object3.pid,@test_object4.pid]
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should be able to change the sort direction" do
|
153
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:sort=>[{"system_create"=>"desc"}]})
|
154
|
-
found_pids = []
|
155
|
-
results.each do |hit|
|
156
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
157
|
-
end
|
158
|
-
|
159
|
-
found_pids.should == [@test_object4.pid,@test_object3.pid,@test_object2.pid]
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should default the sort direction to ascending" do
|
163
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:sort=>["system_create"]})
|
164
|
-
found_pids = []
|
165
|
-
results.each do |hit|
|
166
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
167
|
-
end
|
168
|
-
|
169
|
-
found_pids.should == [@test_object2.pid,@test_object3.pid,@test_object4.pid]
|
170
|
-
end
|
171
|
-
|
172
|
-
|
173
|
-
it "should sort by multiple fields" do
|
174
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:sort=>["geography",{"system_create"=>"desc"}]})
|
175
|
-
found_pids = []
|
176
|
-
results.each do |hit|
|
177
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
178
|
-
end
|
179
|
-
|
180
|
-
found_pids.should == [@test_object2.pid,@test_object4.pid,@test_object3.pid]
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should transform system_modified_date" do
|
184
|
-
#check appropriate logic for system_modified_date field name transformation
|
185
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:sort=>["geography",{"system_mod"=>"desc"}]})
|
186
|
-
found_pids = []
|
187
|
-
results.each do |hit|
|
188
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
189
|
-
end
|
190
|
-
|
191
|
-
found_pids.should == [@test_object2.pid,@test_object4.pid,@test_object3.pid]
|
192
|
-
end
|
193
|
-
|
194
|
-
it "should accept rows as a parameter" do
|
195
|
-
#check pass in rows values
|
196
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:rows=>2})
|
197
|
-
found_pids = []
|
198
|
-
results.each do |hit|
|
199
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
200
|
-
end
|
201
|
-
|
202
|
-
found_pids.should == [@test_object2.pid,@test_object3.pid]
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should accept a solr field (geography_t) that is not an object field name(e.g. geography)" do
|
206
|
-
#check query with field mapping to solr field and with solr field that is not a field in object
|
207
|
-
#should be able to query by either active fedora model field name or solr key name
|
208
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"geography_t"=>"Italy"})
|
209
|
-
found_pids = results.map{|h| h[SOLR_DOCUMENT_ID]}
|
210
|
-
found_pids.should == [@test_object2.pid]
|
211
|
-
end
|
212
|
-
|
213
|
-
describe "with Nokogiri based datastreams" do
|
214
|
-
before do
|
215
|
-
@test_object2.ng_metadata.journal_title = "foo"
|
216
|
-
@test_object2.save
|
217
|
-
end
|
218
|
-
it "should query Nokogiri based datastreams if you use the solr field names (doesn't do mapping)" do
|
219
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"journal_title_t" => "foo"})
|
220
|
-
found_pids = results.map{|h| h[SOLR_DOCUMENT_ID]}
|
221
|
-
found_pids.should == [@test_object2.pid]
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|