ld4l-ore_rdf 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +8 -6
- data/CHANGES.md +4 -0
- data/Gemfile +2 -0
- data/README.md +6 -0
- data/ld4l-ore_rdf.gemspec +5 -4
- data/lib/ld4l/ore_rdf.rb +2 -16
- data/lib/ld4l/ore_rdf/models/aggregation.rb +23 -24
- data/lib/ld4l/ore_rdf/models/aggregation_resource.rb +74 -7
- data/lib/ld4l/ore_rdf/models/proxy_resource.rb +66 -11
- data/lib/ld4l/ore_rdf/services/aggregation/add_aggregated_resource.rb +2 -10
- data/lib/ld4l/ore_rdf/services/aggregation/find.rb +2 -2
- data/lib/ld4l/ore_rdf/services/aggregation/load_from_solr.rb +39 -0
- data/lib/ld4l/ore_rdf/services/aggregation/persist.rb +17 -2
- data/lib/ld4l/ore_rdf/version.rb +1 -1
- data/spec/ld4l/ore_rdf/configuration_spec.rb +1 -1
- data/spec/ld4l/ore_rdf/models/aggregation_resource_spec.rb +61 -2
- data/spec/ld4l/ore_rdf/models/proxy_resource_spec.rb +122 -25
- data/spec/ld4l/ore_rdf/services/aggregation/add_aggregated_resource_spec.rb +2 -2
- data/spec/ld4l/ore_rdf/services/aggregation/add_aggregated_resources_spec.rb +2 -2
- data/spec/ld4l/ore_rdf/services/aggregation/destroy_spec.rb +6 -4
- data/spec/ld4l/ore_rdf/services/aggregation/find_spec.rb +6 -6
- data/spec/ld4l/ore_rdf/services/proxy/create_spec.rb +12 -12
- data/spec/ld4l/ore_rdf/services/proxy/find_spec.rb +10 -10
- data/spec/ld4l/ore_rdf_spec.rb +1 -1
- metadata +33 -31
@@ -0,0 +1,39 @@
|
|
1
|
+
module LD4L
|
2
|
+
module OreRDF
|
3
|
+
class LoadAggregationFromSolr
|
4
|
+
|
5
|
+
##
|
6
|
+
# Load the aggregation and all associated proxies from the solr.
|
7
|
+
#
|
8
|
+
# @param [RDF::URI] uri of aggregation resource to load
|
9
|
+
#
|
10
|
+
# @returns
|
11
|
+
def self.call( uri )
|
12
|
+
raise ArgumentError, 'uri must be an RDF::URI' unless
|
13
|
+
uri && uri.kind_of?(RDF::URI)
|
14
|
+
|
15
|
+
query = ActiveTriples::Solrizer::SolrQueryBuilder.id_query(uri.to_s)
|
16
|
+
results = ActiveTriples::Solrizer::SolrService.query(query)
|
17
|
+
return nil unless results.size > 0
|
18
|
+
|
19
|
+
solr_doc = results.first
|
20
|
+
aggregation_resource = ActiveTriples::Solrizer::IndexingService.load_from_solr_document(solr_doc, true)
|
21
|
+
return nil if aggregation_resource.nil?
|
22
|
+
|
23
|
+
proxy_resources = []
|
24
|
+
proxy_ids = solr_doc[LD4L::OreRDF::AggregationResource.item_proxies_solr_name.to_s]
|
25
|
+
query = ActiveTriples::Solrizer::SolrQueryBuilder.construct_query_for_ids(proxy_ids)
|
26
|
+
results = ActiveTriples::Solrizer::SolrService.query(query)
|
27
|
+
results.each do |solr_doc|
|
28
|
+
proxy_resource = ActiveTriples::Solrizer::IndexingService.load_from_solr_document(solr_doc)
|
29
|
+
proxy_resources << proxy_resource
|
30
|
+
end
|
31
|
+
|
32
|
+
LD4L::OreRDF::Aggregation.new(
|
33
|
+
:aggregation_resource => aggregation_resource,
|
34
|
+
:proxy_resources => proxy_resources)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -12,7 +12,7 @@ module LD4L
|
|
12
12
|
# returns Hash with
|
13
13
|
# :aggregation_resource_persisted is true if aggregation_resource successfully persisted; otherwise, false
|
14
14
|
# :percent_proxies_persisted is % of proxies successfully persisted
|
15
|
-
def self.call( aggregation )
|
15
|
+
def self.call( aggregation, index_into_solr=true )
|
16
16
|
raise ArgumentError, 'aggregation must be an LD4L::OreRDF::Aggregation' unless
|
17
17
|
aggregation && aggregation.kind_of?(LD4L::OreRDF::Aggregation)
|
18
18
|
|
@@ -22,7 +22,22 @@ module LD4L
|
|
22
22
|
|
23
23
|
count = 0
|
24
24
|
agg_persisted = aggregation.aggregation_resource.persist!
|
25
|
-
|
25
|
+
|
26
|
+
if agg_persisted && index_into_solr
|
27
|
+
aggregation.proxy_resources.each do |proxy|
|
28
|
+
count += 1 if proxy.persist!
|
29
|
+
doc = ActiveTriples::Solrizer::IndexingService.new(proxy).generate_solr_document
|
30
|
+
ActiveTriples::Solrizer::SolrService.add(doc)
|
31
|
+
ActiveTriples::Solrizer::SolrService.commit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
if index_into_solr
|
36
|
+
doc = aggregation.aggregation_resource.generate_solr_document
|
37
|
+
ActiveTriples::Solrizer::SolrService.add(doc)
|
38
|
+
ActiveTriples::Solrizer::SolrService.commit
|
39
|
+
end
|
40
|
+
|
26
41
|
percent_proxies = aggregation.proxy_resources.size > 0 ? count/aggregation.proxy_resources.size : 1
|
27
42
|
all_persisted = agg_persisted && (percent_proxies == 1)
|
28
43
|
ret = all_persisted ? all_persisted :
|
data/lib/ld4l/ore_rdf/version.rb
CHANGED
@@ -4,7 +4,7 @@ describe 'LD4L::OreRDF' do
|
|
4
4
|
|
5
5
|
describe '#configuration' do
|
6
6
|
after(:all) do
|
7
|
-
ActiveTriples::RDFSource.type_registry.keys.each { |k| ActiveTriples::RDFSource.type_registry.delete(k) } if Object.const_defined?("
|
7
|
+
ActiveTriples::RDFSource.type_registry.keys.each { |k| ActiveTriples::RDFSource.type_registry.delete(k) } if Object::ActiveTriples.const_defined?("RDFSource")
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "base_uri" do
|
@@ -212,6 +212,65 @@ describe 'LD4L::OreRDF::AggregationResource' do
|
|
212
212
|
# START -- Test helper methods specific to this model
|
213
213
|
# -----------------------------------------------------
|
214
214
|
|
215
|
+
describe '#generate_solr_document' do
|
216
|
+
before do
|
217
|
+
ActiveTriples::Repositories.add_repository :default, RDF::Repository.new
|
218
|
+
@person = LD4L::FoafRDF::Person.new('http://example.org/person1')
|
219
|
+
@aggregation = LD4L::OreRDF::CreateAggregation.call( :id=>'http://example.org/moomin', :title=>'My Resources',
|
220
|
+
:description=>'Resources that I like', :owner=>@person )
|
221
|
+
end
|
222
|
+
|
223
|
+
context 'when aggregation has 0 proxies' do
|
224
|
+
it 'should return a solr doc with all fields' do
|
225
|
+
expected_solr_doc = {:id=>"http://example.org/moomin",
|
226
|
+
:at_model_ssi=>"LD4L::OreRDF::AggregationResource",
|
227
|
+
:object_profile_ss=>
|
228
|
+
"{\"id\":\"http://example.org/moomin\",\"title\":[\"My Resources\"],\"description\":[\"Resources that I like\"],\"owner\":\"http://example.org/person1\",\"aggregates\":[],\"first_proxy_\":[],\"last_proxy_\":[]}",
|
229
|
+
:title_ti=>"My Resources",
|
230
|
+
:title_ssort=>"My Resources",
|
231
|
+
:description_ti=>"Resources that I like",
|
232
|
+
:owner_ssi=>"http://example.org/person1",
|
233
|
+
:item_proxies_ssm=>[]}
|
234
|
+
expect(@aggregation.aggregation_resource.generate_solr_document(@aggregation.proxy_resources)).to eq expected_solr_doc
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
context 'when aggregation has proxies' do
|
239
|
+
let(:proxies) do
|
240
|
+
[LD4L::OreRDF::AddAggregatedResource.call( @aggregation,'http://example.org/resource_1'),
|
241
|
+
LD4L::OreRDF::AddAggregatedResource.call( @aggregation,'http://example.org/resource_2'),
|
242
|
+
LD4L::OreRDF::AddAggregatedResource.call( @aggregation,'http://example.org/resource_3')]
|
243
|
+
end
|
244
|
+
|
245
|
+
it 'should return a solr doc with all fields' do
|
246
|
+
object_profile = "{\"id\":\"http://example.org/moomin\",\"title\":[\"My Resources\"],\"description\":[\"Resources that I like\"],\"owner\":\"http://example.org/person1\",\"aggregates\":[\"http://example.org/resource_1\",\"http://example.org/resource_2\",\"http://example.org/resource_3\"],\"first_proxy_\":\"#{proxies.first.id}\",\"last_proxy_\":\"#{proxies.last.id}\"}"
|
247
|
+
proxy_ids = proxies.collect { |p| p.id }
|
248
|
+
expected_solr_doc = {:id=>"http://example.org/moomin",
|
249
|
+
:at_model_ssi=>"LD4L::OreRDF::AggregationResource",
|
250
|
+
:object_profile_ss=>object_profile,
|
251
|
+
:title_ti=>"My Resources",
|
252
|
+
:title_ssort=>"My Resources",
|
253
|
+
:description_ti=>"Resources that I like",
|
254
|
+
:owner_ssi=>"http://example.org/person1",
|
255
|
+
:aggregates_tsim=>
|
256
|
+
["http://example.org/resource_1", "http://example.org/resource_2", "http://example.org/resource_3"],
|
257
|
+
:item_proxies_ssm=>proxy_ids }
|
258
|
+
expect(@aggregation.aggregation_resource.generate_solr_document(@aggregation.proxy_resources)).to eq expected_solr_doc
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
context 'when aggregation has no owner' do
|
263
|
+
xit 'should return without owner information' do
|
264
|
+
pending 'this needs to be implemented'
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
context 'when aggregation has owner' do
|
269
|
+
xit 'should return with owner information' do
|
270
|
+
pending 'this needs to be implemented'
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
215
274
|
|
216
275
|
########### NEED TO MOVE TO SERVICE OBJECT ####################
|
217
276
|
|
@@ -379,10 +438,10 @@ describe 'LD4L::OreRDF::AggregationResource' do
|
|
379
438
|
vci_array = subject.get_items
|
380
439
|
vci_array.each do |vci|
|
381
440
|
expect(vci).to be_a(LD4L::OreRDF::ProxyResource)
|
382
|
-
expect(vci.
|
441
|
+
expect(vci.proxy_in_.first).to eq subject
|
383
442
|
end
|
384
443
|
results = []
|
385
|
-
vci_array.each { |vci| results << vci.
|
444
|
+
vci_array.each { |vci| results << vci.proxy_for_.first }
|
386
445
|
expect(results).to include "http://example.org/individual/b1"
|
387
446
|
expect(results).to include "http://example.org/individual/b2"
|
388
447
|
expect(results).to include "http://example.org/individual/b3"
|
@@ -62,14 +62,33 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
describe '
|
65
|
+
describe 'proxy_for_' do
|
66
66
|
it "should be empty array if we haven't set it" do
|
67
|
-
expect(subject.
|
67
|
+
expect(subject.proxy_for_).to match_array([])
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be settable" do
|
71
|
+
subject.proxy_for_ = "http://example.org/b1"
|
72
|
+
expect(subject.proxy_for_.first).to eq "http://example.org/b1"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should be changeable" do
|
76
|
+
orig_proxy_for = "http://example.org/b1"
|
77
|
+
new_proxy_for = "http://example.org/b1_NEW"
|
78
|
+
subject.proxy_for_ = orig_proxy_for
|
79
|
+
subject.proxy_for_ = new_proxy_for
|
80
|
+
expect(subject.proxy_for_.first).to eq new_proxy_for
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'proxy_for' do
|
85
|
+
it "should be nil if we haven't set it" do
|
86
|
+
expect(subject.proxy_for).to be_nil
|
68
87
|
end
|
69
88
|
|
70
89
|
it "should be settable" do
|
71
90
|
subject.proxy_for = "http://example.org/b1"
|
72
|
-
expect(subject.proxy_for
|
91
|
+
expect(subject.proxy_for).to eq "http://example.org/b1"
|
73
92
|
end
|
74
93
|
|
75
94
|
it "should be changeable" do
|
@@ -77,19 +96,39 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
77
96
|
new_proxy_for = "http://example.org/b1_NEW"
|
78
97
|
subject.proxy_for = orig_proxy_for
|
79
98
|
subject.proxy_for = new_proxy_for
|
80
|
-
expect(subject.proxy_for
|
99
|
+
expect(subject.proxy_for).to eq new_proxy_for
|
81
100
|
end
|
82
101
|
end
|
83
102
|
|
84
|
-
describe '
|
103
|
+
describe 'proxy_in_' do
|
85
104
|
it "should be empty array if we haven't set it" do
|
86
|
-
expect(subject.
|
105
|
+
expect(subject.proxy_in_).to match_array([])
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should be settable" do
|
109
|
+
an_aggregation = LD4L::OreRDF::AggregationResource.new('1')
|
110
|
+
subject.proxy_in_ = an_aggregation
|
111
|
+
expect(subject.proxy_in_.first).to eq an_aggregation
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should be changeable" do
|
115
|
+
orig_aggregation = LD4L::OreRDF::AggregationResource.new('1')
|
116
|
+
new_aggregation = LD4L::OreRDF::AggregationResource.new('2')
|
117
|
+
subject.proxy_in_ = orig_aggregation
|
118
|
+
subject.proxy_in_ = new_aggregation
|
119
|
+
expect(subject.proxy_in_.first).to eq new_aggregation
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe 'proxy_in' do
|
124
|
+
it "should be nil if we haven't set it" do
|
125
|
+
expect(subject.proxy_in).to be_nil
|
87
126
|
end
|
88
127
|
|
89
128
|
it "should be settable" do
|
90
129
|
an_aggregation = LD4L::OreRDF::AggregationResource.new('1')
|
91
130
|
subject.proxy_in = an_aggregation
|
92
|
-
expect(subject.proxy_in
|
131
|
+
expect(subject.proxy_in).to eq an_aggregation
|
93
132
|
end
|
94
133
|
|
95
134
|
it "should be changeable" do
|
@@ -97,19 +136,45 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
97
136
|
new_aggregation = LD4L::OreRDF::AggregationResource.new('2')
|
98
137
|
subject.proxy_in = orig_aggregation
|
99
138
|
subject.proxy_in = new_aggregation
|
100
|
-
expect(subject.proxy_in
|
139
|
+
expect(subject.proxy_in).to eq new_aggregation
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should be able to get rdf_subject" do
|
143
|
+
an_aggregation = LD4L::OreRDF::AggregationResource.new('http://www.example.org/agg1')
|
144
|
+
subject.proxy_in = an_aggregation
|
145
|
+
expect(subject.proxy_in_subject).to eq 'http://www.example.org/agg1'
|
101
146
|
end
|
102
147
|
end
|
103
148
|
|
104
|
-
describe '
|
149
|
+
describe 'next_proxy_' do
|
105
150
|
it "should be empty array if we haven't set it" do
|
106
|
-
expect(subject.
|
151
|
+
expect(subject.next_proxy_).to match_array([])
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should be settable" do
|
155
|
+
an_proxy = LD4L::OreRDF::ProxyResource.new('1')
|
156
|
+
subject.next_proxy_ = an_proxy
|
157
|
+
expect(subject.next_proxy_.first).to eq an_proxy
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should be changeable" do
|
161
|
+
orig_proxy = LD4L::OreRDF::ProxyResource.new('1')
|
162
|
+
new_proxy = LD4L::OreRDF::ProxyResource.new('2')
|
163
|
+
subject.next_proxy_ = orig_proxy
|
164
|
+
subject.next_proxy_ = new_proxy
|
165
|
+
expect(subject.next_proxy_.first).to eq new_proxy
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe 'next_proxy' do
|
170
|
+
it "should be nil if we haven't set it" do
|
171
|
+
expect(subject.next_proxy).to be_nil
|
107
172
|
end
|
108
173
|
|
109
174
|
it "should be settable" do
|
110
175
|
an_proxy = LD4L::OreRDF::ProxyResource.new('1')
|
111
176
|
subject.next_proxy = an_proxy
|
112
|
-
expect(subject.next_proxy
|
177
|
+
expect(subject.next_proxy).to eq an_proxy
|
113
178
|
end
|
114
179
|
|
115
180
|
it "should be changeable" do
|
@@ -117,19 +182,45 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
117
182
|
new_proxy = LD4L::OreRDF::ProxyResource.new('2')
|
118
183
|
subject.next_proxy = orig_proxy
|
119
184
|
subject.next_proxy = new_proxy
|
120
|
-
expect(subject.next_proxy
|
185
|
+
expect(subject.next_proxy).to eq new_proxy
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should be able to get subject" do
|
189
|
+
an_proxy = LD4L::OreRDF::ProxyResource.new('http://www.example.org/proxy1')
|
190
|
+
subject.next_proxy = an_proxy
|
191
|
+
expect(subject.next_proxy_subject).to eq 'http://www.example.org/proxy1'
|
121
192
|
end
|
122
193
|
end
|
123
194
|
|
124
|
-
describe '
|
195
|
+
describe 'prev_proxy_' do
|
125
196
|
it "should be empty array if we haven't set it" do
|
126
|
-
expect(subject.
|
197
|
+
expect(subject.prev_proxy_).to match_array([])
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should be settable" do
|
201
|
+
an_proxy = LD4L::OreRDF::ProxyResource.new('1')
|
202
|
+
subject.prev_proxy_ = an_proxy
|
203
|
+
expect(subject.prev_proxy_.first).to eq an_proxy
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should be changeable" do
|
207
|
+
orig_proxy = LD4L::OreRDF::ProxyResource.new('1')
|
208
|
+
new_proxy = LD4L::OreRDF::ProxyResource.new('2')
|
209
|
+
subject.prev_proxy_ = orig_proxy
|
210
|
+
subject.prev_proxy_ = new_proxy
|
211
|
+
expect(subject.prev_proxy_.first).to eq new_proxy
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe 'prev_proxy' do
|
216
|
+
it "should be nil if we haven't set it" do
|
217
|
+
expect(subject.prev_proxy).to be_nil
|
127
218
|
end
|
128
219
|
|
129
220
|
it "should be settable" do
|
130
221
|
an_proxy = LD4L::OreRDF::ProxyResource.new('1')
|
131
222
|
subject.prev_proxy = an_proxy
|
132
|
-
expect(subject.prev_proxy
|
223
|
+
expect(subject.prev_proxy).to eq an_proxy
|
133
224
|
end
|
134
225
|
|
135
226
|
it "should be changeable" do
|
@@ -137,7 +228,13 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
137
228
|
new_proxy = LD4L::OreRDF::ProxyResource.new('2')
|
138
229
|
subject.prev_proxy = orig_proxy
|
139
230
|
subject.prev_proxy = new_proxy
|
140
|
-
expect(subject.prev_proxy
|
231
|
+
expect(subject.prev_proxy).to eq new_proxy
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should be able to get subject" do
|
235
|
+
an_proxy = LD4L::OreRDF::ProxyResource.new('http://www.example.org/proxy1')
|
236
|
+
subject.prev_proxy = an_proxy
|
237
|
+
expect(subject.prev_proxy_subject).to eq 'http://www.example.org/proxy1'
|
141
238
|
end
|
142
239
|
end
|
143
240
|
|
@@ -288,7 +385,7 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
288
385
|
expect(vci.proxy_in.first).to eq vc
|
289
386
|
end
|
290
387
|
results = []
|
291
|
-
vci_array.each { |vci| results << vci.
|
388
|
+
vci_array.each { |vci| results << vci.proxy_for_.first }
|
292
389
|
expect(results).to include "http://example.org/individual/b1"
|
293
390
|
expect(results).to include "http://example.org/individual/b2"
|
294
391
|
expect(results).to include "http://example.org/individual/b3"
|
@@ -406,8 +503,8 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
406
503
|
subject.reload
|
407
504
|
expect(subject.contributor).to eq ["John Smith"]
|
408
505
|
subject.contributor = []
|
409
|
-
subject.
|
410
|
-
subject.
|
506
|
+
subject.proxy_in_ = []
|
507
|
+
subject.proxy_for_ = []
|
411
508
|
expect(subject.contributor).to eq []
|
412
509
|
subject.persist!
|
413
510
|
subject.reload
|
@@ -444,8 +541,8 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
444
541
|
subject.reload
|
445
542
|
expect(subject.contributor).to eq ["John Smith"]
|
446
543
|
subject.contributor = []
|
447
|
-
subject.
|
448
|
-
subject.
|
544
|
+
subject.proxy_in_ = []
|
545
|
+
subject.proxy_for_ = []
|
449
546
|
expect(subject.contributor).to eq []
|
450
547
|
subject.persist!
|
451
548
|
subject.reload
|
@@ -515,7 +612,7 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
515
612
|
end
|
516
613
|
|
517
614
|
it 'should contain data' do
|
518
|
-
expect(subject.attributes['
|
615
|
+
expect(subject.attributes['proxy_for_']).to eq ['Dummy Proxy']
|
519
616
|
end
|
520
617
|
|
521
618
|
it 'should contain child objects' do
|
@@ -562,8 +659,8 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
562
659
|
|
563
660
|
describe 'property methods' do
|
564
661
|
it 'should set and get properties' do
|
565
|
-
subject.
|
566
|
-
expect(subject.
|
662
|
+
subject.proxy_for_ = 'Comet in Moominland'
|
663
|
+
expect(subject.proxy_for_).to eq ['Comet in Moominland']
|
567
664
|
end
|
568
665
|
end
|
569
666
|
|
@@ -612,7 +709,7 @@ describe 'LD4L::OreRDF::ProxyResource' do
|
|
612
709
|
it 'should delete properties when statements are removed' do
|
613
710
|
subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::ORE.proxyFor, 'Comet in Moominland')
|
614
711
|
subject.delete RDF::Statement.new(subject.rdf_subject, RDFVocabularies::ORE.proxyFor, 'Comet in Moominland')
|
615
|
-
expect(subject.
|
712
|
+
expect(subject.proxy_for_).to eq []
|
616
713
|
end
|
617
714
|
end
|
618
715
|
|
@@ -28,8 +28,8 @@ describe 'LD4L::OreRDF::AggregationResource::AddAggregatedResource' do
|
|
28
28
|
|
29
29
|
it "should generate the resource instance for a single resource" do
|
30
30
|
proxy = LD4L::OreRDF::AddAggregatedResource.call( subject, RDF::URI("http://example.org/individual/b1" ))
|
31
|
-
expect(proxy.
|
32
|
-
expect(proxy.
|
31
|
+
expect(proxy.proxy_for_.first).to eq "http://example.org/individual/b1"
|
32
|
+
expect(proxy.proxy_in_.first).to eq subject.aggregation_resource
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -63,11 +63,11 @@ describe 'LD4L::OreRDF::AddAggregatedResources' do
|
|
63
63
|
RDF::URI("http://example.org/individual/b3")])
|
64
64
|
proxy_array.each do |proxy|
|
65
65
|
expect(proxy).to be_a(LD4L::OreRDF::ProxyResource)
|
66
|
-
expect(proxy.
|
66
|
+
expect(proxy.proxy_in_.first).to eq subject.aggregation_resource
|
67
67
|
end
|
68
68
|
results = []
|
69
69
|
proxy_array.each do |proxy|
|
70
|
-
results << proxy.
|
70
|
+
results << proxy.proxy_for_.first
|
71
71
|
end
|
72
72
|
expect(results).to include "http://example.org/individual/b1"
|
73
73
|
expect(results).to include "http://example.org/individual/b2"
|
@@ -27,12 +27,13 @@ describe 'LD4L::OreRDF::DestroyAggregation' do
|
|
27
27
|
context "when aggregation doesn't have proxies" do
|
28
28
|
before do
|
29
29
|
ActiveTriples::Repositories.add_repository :default, RDF::Repository.new
|
30
|
+
|
30
31
|
@id = "http::/example.org/NO_PROXIES"
|
31
32
|
@aggregation = LD4L::OreRDF::CreateAggregation.call(
|
32
33
|
id: @id,
|
33
34
|
title: "No Proxy Aggregation",
|
34
35
|
description: "Test aggregation with no proxies." )
|
35
|
-
LD4L::OreRDF::PersistAggregation.call(@aggregation)
|
36
|
+
LD4L::OreRDF::PersistAggregation.call(@aggregation,false)
|
36
37
|
expect( LD4L::OreRDF::ResumeAggregation.call(@id).rdf_subject.to_s ).to eq @id
|
37
38
|
end
|
38
39
|
after do
|
@@ -48,6 +49,7 @@ describe 'LD4L::OreRDF::DestroyAggregation' do
|
|
48
49
|
context "when aggregation has proxies" do
|
49
50
|
before do
|
50
51
|
ActiveTriples::Repositories.add_repository :default, RDF::Repository.new
|
52
|
+
|
51
53
|
@id1 = "http::/example.org/ag1"
|
52
54
|
@ag1 = LD4L::OreRDF::CreateAggregation.call(
|
53
55
|
id: @id1,
|
@@ -58,7 +60,7 @@ describe 'LD4L::OreRDF::DestroyAggregation' do
|
|
58
60
|
[RDF::URI("http://example.org/individual/b11"),
|
59
61
|
RDF::URI("http://example.org/individual/b12"),
|
60
62
|
RDF::URI("http://example.org/individual/b13")])
|
61
|
-
LD4L::OreRDF::PersistAggregation.call(@ag1)
|
63
|
+
LD4L::OreRDF::PersistAggregation.call(@ag1,false)
|
62
64
|
a1 = LD4L::OreRDF::ResumeAggregation.call(@id1)
|
63
65
|
expect( a1.aggregation_resource.rdf_subject.to_s ).to eq @id1
|
64
66
|
expect( a1.proxy_resources.length).to eq 3
|
@@ -74,7 +76,7 @@ describe 'LD4L::OreRDF::DestroyAggregation' do
|
|
74
76
|
[RDF::URI("http://example.org/individual/b21"),
|
75
77
|
RDF::URI("http://example.org/individual/b22"),
|
76
78
|
RDF::URI("http://example.org/individual/b23")])
|
77
|
-
LD4L::OreRDF::PersistAggregation.call(@ag2)
|
79
|
+
LD4L::OreRDF::PersistAggregation.call(@ag2,false)
|
78
80
|
a2 = LD4L::OreRDF::ResumeAggregation.call(@id2)
|
79
81
|
expect( a2.aggregation_resource.rdf_subject.to_s ).to eq @id2
|
80
82
|
expect( a2.proxy_resources.length).to eq 3
|
@@ -85,7 +87,7 @@ describe 'LD4L::OreRDF::DestroyAggregation' do
|
|
85
87
|
title: "Aggregation 3",
|
86
88
|
description: "Test description of aggregation 3.",
|
87
89
|
owner: p )
|
88
|
-
LD4L::OreRDF::PersistAggregation.call(@ag3)
|
90
|
+
LD4L::OreRDF::PersistAggregation.call(@ag3,false)
|
89
91
|
a3 = LD4L::OreRDF::ResumeAggregation.call(@id3)
|
90
92
|
expect( a3.aggregation_resource.rdf_subject.to_s ).to eq @id3
|
91
93
|
expect( a3.proxy_resources.length).to eq 0
|