active-fedora 9.0.0.beta2 → 9.0.0.beta3
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/config/jetty.yml +1 -1
- data/lib/active_fedora.rb +11 -3
- data/lib/active_fedora/associations/association_scope.rb +2 -2
- data/lib/active_fedora/associations/belongs_to_association.rb +2 -2
- data/lib/active_fedora/associations/collection_association.rb +13 -13
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +2 -2
- data/lib/active_fedora/associations/rdf.rb +2 -2
- data/lib/active_fedora/cleaner.rb +2 -6
- data/lib/active_fedora/fedora.rb +18 -0
- data/lib/active_fedora/fedora_attributes.rb +4 -4
- data/lib/active_fedora/file.rb +7 -0
- data/lib/active_fedora/fixity_service.rb +9 -1
- data/lib/active_fedora/indexing_service.rb +2 -7
- data/lib/active_fedora/loadable_from_json.rb +4 -0
- data/lib/active_fedora/om_datastream.rb +0 -4
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
- data/lib/active_fedora/query_result_builder.rb +56 -0
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/rdf.rb +2 -1
- data/lib/active_fedora/rdf/fcrepo.rb +323 -9
- data/lib/active_fedora/rdf/fcrepo4.rb +7 -0
- data/lib/active_fedora/rdf/indexing.rb +1 -1
- data/lib/active_fedora/rdf/project_hydra.rb +12 -0
- data/lib/active_fedora/reflection.rb +4 -1
- data/lib/active_fedora/relation/finder_methods.rb +4 -4
- data/lib/active_fedora/simple_datastream.rb +11 -12
- data/lib/active_fedora/solr_instance_loader.rb +1 -1
- data/lib/active_fedora/solr_query_builder.rb +57 -0
- data/lib/active_fedora/solr_service.rb +22 -48
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/versionable.rb +12 -13
- data/spec/integration/associations_spec.rb +6 -6
- data/spec/integration/attributes_spec.rb +22 -6
- data/spec/integration/base_spec.rb +2 -2
- data/spec/integration/collection_association_spec.rb +9 -0
- data/spec/integration/file_spec.rb +30 -0
- data/spec/integration/full_featured_model_spec.rb +1 -1
- data/spec/integration/ntriples_datastream_spec.rb +5 -5
- data/spec/integration/om_datastream_spec.rb +1 -1
- data/spec/integration/{solr_service_spec.rb → query_result_builder_spec.rb} +5 -7
- data/spec/integration/relation_delegation_spec.rb +3 -3
- data/spec/integration/scoped_query_spec.rb +11 -11
- data/spec/integration/solr_instance_loader_spec.rb +8 -0
- data/spec/integration/versionable_spec.rb +32 -14
- data/spec/unit/base_spec.rb +3 -3
- data/spec/unit/indexing_service_spec.rb +2 -2
- data/spec/unit/ntriples_datastream_spec.rb +16 -16
- data/spec/unit/om_datastream_spec.rb +7 -7
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
- data/spec/unit/query_result_builder_spec.rb +39 -0
- data/spec/unit/query_spec.rb +2 -2
- data/spec/unit/rdf_vocab_spec.rb +30 -0
- data/spec/unit/simple_datastream_spec.rb +2 -2
- data/spec/unit/solr_config_options_spec.rb +1 -1
- data/spec/unit/solr_query_builder_spec.rb +20 -0
- data/spec/unit/solr_service_spec.rb +2 -53
- metadata +11 -4
@@ -103,7 +103,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
|
|
103
103
|
@test_ds = ActiveFedora::QualifiedDublinCoreDatastream.new
|
104
104
|
@test_ds.title = "War and Peace"
|
105
105
|
solr = @test_ds.to_solr
|
106
|
-
expect(solr[ActiveFedora::
|
106
|
+
expect(solr[ActiveFedora::SolrQueryBuilder.solr_name('title', type: :string)]).to eq "War and Peace"
|
107
107
|
end
|
108
108
|
|
109
109
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QueryResultBuilder do
|
4
|
+
describe "reify solr results" do
|
5
|
+
before(:all) do
|
6
|
+
class AudioRecord
|
7
|
+
attr_accessor :id
|
8
|
+
def self.connection_for_id(id)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
@sample_solr_hits = [{"id"=>"my:_ID1_", ActiveFedora::SolrQueryBuilder.solr_name("has_model", :symbol)=>["AudioRecord"]},
|
12
|
+
{"id"=>"my:_ID2_", ActiveFedora::SolrQueryBuilder.solr_name("has_model", :symbol)=>["AudioRecord"]},
|
13
|
+
{"id"=>"my:_ID3_", ActiveFedora::SolrQueryBuilder.solr_name("has_model", :symbol)=>["AudioRecord"]}]
|
14
|
+
end
|
15
|
+
describe ".reify_solr_result" do
|
16
|
+
it "should use .find to instantiate objects" do
|
17
|
+
expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
|
18
|
+
ActiveFedora::QueryResultBuilder.reify_solr_result(@sample_solr_hits.first)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe ".reify_solr_results" do
|
22
|
+
it "should use AudioRecord.find to instantiate objects" do
|
23
|
+
expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
|
24
|
+
expect(AudioRecord).to receive(:find).with("my:_ID2_", cast: true)
|
25
|
+
expect(AudioRecord).to receive(:find).with("my:_ID3_", cast: true)
|
26
|
+
ActiveFedora::QueryResultBuilder.reify_solr_results(@sample_solr_hits)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
describe ".lazy_reify_solr_results" do
|
30
|
+
it "should lazily reify solr results" do
|
31
|
+
expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
|
32
|
+
expect(AudioRecord).to receive(:find).with("my:_ID2_", cast: true)
|
33
|
+
expect(AudioRecord).to receive(:find).with("my:_ID3_", cast: true)
|
34
|
+
ActiveFedora::QueryResultBuilder.lazy_reify_solr_results(@sample_solr_hits).each {|r| r}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/spec/unit/query_spec.rb
CHANGED
@@ -7,8 +7,8 @@ describe ActiveFedora::Base do
|
|
7
7
|
class Basic < ActiveFedora::Base
|
8
8
|
end
|
9
9
|
end
|
10
|
-
@model_query = "_query_:\"{!raw f=" + ActiveFedora::
|
11
|
-
@sort_query = ActiveFedora::
|
10
|
+
@model_query = "_query_:\"{!raw f=" + ActiveFedora::SolrQueryBuilder.solr_name("has_model", :symbol) + "}SpecModel::Basic" + "\""
|
11
|
+
@sort_query = ActiveFedora::SolrQueryBuilder.solr_name("system_create", :stored_sortable, type: :date) + ' asc'
|
12
12
|
end
|
13
13
|
|
14
14
|
after(:all) do
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe ActiveFedora::RDF do
|
5
|
+
describe ActiveFedora::RDF::Fcrepo do
|
6
|
+
it "should register the vocabularies" do
|
7
|
+
namespaces = [
|
8
|
+
"info:fedora/fedora-system:def/model#",
|
9
|
+
"info:fedora/fedora-system:def/view#",
|
10
|
+
"info:fedora/fedora-system:def/relations-external#",
|
11
|
+
"info:fedora/fedora-system:"
|
12
|
+
]
|
13
|
+
namespaces.each do |namespace|
|
14
|
+
vocab = RDF::Vocabulary.find(namespace)
|
15
|
+
expect(vocab.superclass).to be(RDF::StrictVocabulary)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
describe ActiveFedora::RDF::ProjectHydra do
|
20
|
+
it "should register the vocabularies" do
|
21
|
+
namespaces = [
|
22
|
+
"http://projecthydra.org/ns/relations#"
|
23
|
+
]
|
24
|
+
namespaces.each do |namespace|
|
25
|
+
vocab = RDF::Vocabulary.find(namespace)
|
26
|
+
expect(vocab.superclass).to be(RDF::StrictVocabulary)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -58,8 +58,8 @@ describe ActiveFedora::SimpleDatastream do
|
|
58
58
|
describe "#to_solr" do
|
59
59
|
it "should have title" do
|
60
60
|
solr = @test_ds.to_solr
|
61
|
-
expect(solr[ActiveFedora::
|
62
|
-
expect(solr[ActiveFedora::
|
61
|
+
expect(solr[ActiveFedora::SolrQueryBuilder.solr_name('publisher', type: :string)]).to eq "publisher1"
|
62
|
+
expect(solr[ActiveFedora::SolrQueryBuilder.solr_name('creation_date', type: :date)]).to eq "2012-01-15"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -29,7 +29,7 @@ describe ActiveFedora do
|
|
29
29
|
|
30
30
|
it "should be used by ActiveFedora::Base#find_with_conditions" do
|
31
31
|
mock_response = double("SolrResponse")
|
32
|
-
expect(ActiveFedora::SolrService).to receive(:query).with("_query_:\"{!raw f=#{ActiveFedora::
|
32
|
+
expect(ActiveFedora::SolrService).to receive(:query).with("_query_:\"{!raw f=#{ActiveFedora::SolrQueryBuilder.solr_name("has_model", :symbol)}}SolrSpecModel::Basic\" AND " + SOLR_DOCUMENT_ID + ':changeme\\:30', {:sort => ["#{ActiveFedora::SolrQueryBuilder.solr_name("system_create", :stored_sortable, type: :date)} asc"]}).and_return(mock_response)
|
33
33
|
|
34
34
|
expect(SolrSpecModel::Basic.find_with_conditions(:id=>"changeme:30")).to equal(mock_response)
|
35
35
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SolrQueryBuilder do
|
4
|
+
describe "raw_query" do
|
5
|
+
it "should generate a raw query clause" do
|
6
|
+
expect(ActiveFedora::SolrQueryBuilder.raw_query('id', "my:_ID1_")).to eq '_query_:"{!raw f=id}my:_ID1_"'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#construct_query_for_ids' do
|
11
|
+
it "should generate a useable solr query from an array of Fedora ids" do
|
12
|
+
expect(ActiveFedora::SolrQueryBuilder.construct_query_for_ids(["my:_ID1_", "my:_ID2_", "my:_ID3_"])).to eq '_query_:"{!raw f=id}my:_ID1_" OR _query_:"{!raw f=id}my:_ID2_" OR _query_:"{!raw f=id}my:_ID3_"'
|
13
|
+
|
14
|
+
end
|
15
|
+
it "should return a valid solr query even if given an empty array as input" do
|
16
|
+
expect(ActiveFedora::SolrQueryBuilder.construct_query_for_ids([""])).to eq "id:NEVER_USE_THIS_ID"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -4,11 +4,11 @@ describe ActiveFedora::SolrService do
|
|
4
4
|
before do
|
5
5
|
Thread.current[:solr_service]=nil
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
after(:all) do
|
9
9
|
ActiveFedora::SolrService.register(ActiveFedora.solr_config[:url])
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should take a n-arg constructor and configure for localhost" do
|
13
13
|
expect(RSolr).to receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr')
|
14
14
|
ActiveFedora::SolrService.register
|
@@ -34,57 +34,6 @@ describe ActiveFedora::SolrService do
|
|
34
34
|
expect(proc{ActiveFedora::SolrService.instance}).to raise_error(ActiveFedora::SolrNotInitialized)
|
35
35
|
end
|
36
36
|
|
37
|
-
describe "reify solr results" do
|
38
|
-
before(:all) do
|
39
|
-
class AudioRecord
|
40
|
-
attr_accessor :id
|
41
|
-
def self.connection_for_id(id)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
@sample_solr_hits = [{"id"=>"my:_ID1_", ActiveFedora::SolrService.solr_name("has_model", :symbol)=>["AudioRecord"]},
|
45
|
-
{"id"=>"my:_ID2_", ActiveFedora::SolrService.solr_name("has_model", :symbol)=>["AudioRecord"]},
|
46
|
-
{"id"=>"my:_ID3_", ActiveFedora::SolrService.solr_name("has_model", :symbol)=>["AudioRecord"]}]
|
47
|
-
end
|
48
|
-
describe ".reify_solr_result" do
|
49
|
-
it "should use .find to instantiate objects" do
|
50
|
-
expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
|
51
|
-
ActiveFedora::SolrService.reify_solr_result(@sample_solr_hits.first)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
describe ".reify_solr_results" do
|
55
|
-
it "should use AudioRecord.find to instantiate objects" do
|
56
|
-
expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
|
57
|
-
expect(AudioRecord).to receive(:find).with("my:_ID2_", cast: true)
|
58
|
-
expect(AudioRecord).to receive(:find).with("my:_ID3_", cast: true)
|
59
|
-
ActiveFedora::SolrService.reify_solr_results(@sample_solr_hits)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
describe ".lazy_reify_solr_results" do
|
63
|
-
it "should lazily reify solr results" do
|
64
|
-
expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
|
65
|
-
expect(AudioRecord).to receive(:find).with("my:_ID2_", cast: true)
|
66
|
-
expect(AudioRecord).to receive(:find).with("my:_ID3_", cast: true)
|
67
|
-
ActiveFedora::SolrService.lazy_reify_solr_results(@sample_solr_hits).each {|r| r}
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "raw_query" do
|
73
|
-
it "should generate a raw query clause" do
|
74
|
-
expect(ActiveFedora::SolrService.raw_query('id', "my:_ID1_")).to eq '_query_:"{!raw f=id}my:_ID1_"'
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#construct_query_for_ids' do
|
79
|
-
it "should generate a useable solr query from an array of Fedora ids" do
|
80
|
-
expect(ActiveFedora::SolrService.construct_query_for_ids(["my:_ID1_", "my:_ID2_", "my:_ID3_"])).to eq '_query_:"{!raw f=id}my:_ID1_" OR _query_:"{!raw f=id}my:_ID2_" OR _query_:"{!raw f=id}my:_ID3_"'
|
81
|
-
|
82
|
-
end
|
83
|
-
it "should return a valid solr query even if given an empty array as input" do
|
84
|
-
expect(ActiveFedora::SolrService.construct_query_for_ids([""])).to eq "id:NEVER_USE_THIS_ID"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
37
|
describe '#construct_query_for_pids' do
|
89
38
|
it "should generate a useable solr query from an array of Fedora ids" do
|
90
39
|
expect(Deprecation).to receive(:warn)
|
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: 9.0.0.
|
4
|
+
version: 9.0.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -347,15 +347,18 @@ files:
|
|
347
347
|
- lib/active_fedora/predicates.rb
|
348
348
|
- lib/active_fedora/property.rb
|
349
349
|
- lib/active_fedora/qualified_dublin_core_datastream.rb
|
350
|
+
- lib/active_fedora/query_result_builder.rb
|
350
351
|
- lib/active_fedora/querying.rb
|
351
352
|
- lib/active_fedora/railtie.rb
|
352
353
|
- lib/active_fedora/rdf.rb
|
353
354
|
- lib/active_fedora/rdf/datastream_indexing.rb
|
354
355
|
- lib/active_fedora/rdf/fcrepo.rb
|
356
|
+
- lib/active_fedora/rdf/fcrepo4.rb
|
355
357
|
- lib/active_fedora/rdf/indexing.rb
|
356
358
|
- lib/active_fedora/rdf/ldp.rb
|
357
359
|
- lib/active_fedora/rdf/ntriples_rdf_datastream.rb
|
358
360
|
- lib/active_fedora/rdf/persistence.rb
|
361
|
+
- lib/active_fedora/rdf/project_hydra.rb
|
359
362
|
- lib/active_fedora/rdf/rdf_datastream.rb
|
360
363
|
- lib/active_fedora/rdf/rdfxml_datastream.rb
|
361
364
|
- lib/active_fedora/rdf/rels_ext.rb
|
@@ -377,6 +380,7 @@ files:
|
|
377
380
|
- lib/active_fedora/serialization.rb
|
378
381
|
- lib/active_fedora/simple_datastream.rb
|
379
382
|
- lib/active_fedora/solr_instance_loader.rb
|
383
|
+
- lib/active_fedora/solr_query_builder.rb
|
380
384
|
- lib/active_fedora/solr_service.rb
|
381
385
|
- lib/active_fedora/sparql_insert.rb
|
382
386
|
- lib/active_fedora/test_support.rb
|
@@ -443,12 +447,12 @@ files:
|
|
443
447
|
- spec/integration/ntriples_datastream_spec.rb
|
444
448
|
- spec/integration/om_datastream_spec.rb
|
445
449
|
- spec/integration/persistence_spec.rb
|
450
|
+
- spec/integration/query_result_builder_spec.rb
|
446
451
|
- spec/integration/rdf_nested_attributes_spec.rb
|
447
452
|
- spec/integration/relation_delegation_spec.rb
|
448
453
|
- spec/integration/relation_spec.rb
|
449
454
|
- spec/integration/scoped_query_spec.rb
|
450
455
|
- spec/integration/solr_instance_loader_spec.rb
|
451
|
-
- spec/integration/solr_service_spec.rb
|
452
456
|
- spec/integration/versionable_spec.rb
|
453
457
|
- spec/integration/with_metadata_spec.rb
|
454
458
|
- spec/rcov.opts
|
@@ -503,9 +507,11 @@ files:
|
|
503
507
|
- spec/unit/predicates_spec.rb
|
504
508
|
- spec/unit/property_spec.rb
|
505
509
|
- spec/unit/qualified_dublin_core_datastream_spec.rb
|
510
|
+
- spec/unit/query_result_builder_spec.rb
|
506
511
|
- spec/unit/query_spec.rb
|
507
512
|
- spec/unit/rdf_datastream_spec.rb
|
508
513
|
- spec/unit/rdf_resource_datastream_spec.rb
|
514
|
+
- spec/unit/rdf_vocab_spec.rb
|
509
515
|
- spec/unit/rdfxml_datastream_spec.rb
|
510
516
|
- spec/unit/readonly_spec.rb
|
511
517
|
- spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
|
@@ -514,6 +520,7 @@ files:
|
|
514
520
|
- spec/unit/serializers_spec.rb
|
515
521
|
- spec/unit/simple_datastream_spec.rb
|
516
522
|
- spec/unit/solr_config_options_spec.rb
|
523
|
+
- spec/unit/solr_query_builder_spec.rb
|
517
524
|
- spec/unit/solr_service_spec.rb
|
518
525
|
- spec/unit/sparql_insert_spec.rb
|
519
526
|
- spec/unit/validations_spec.rb
|
@@ -537,7 +544,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
537
544
|
version: 1.3.1
|
538
545
|
requirements: []
|
539
546
|
rubyforge_project:
|
540
|
-
rubygems_version: 2.
|
547
|
+
rubygems_version: 2.2.2
|
541
548
|
signing_key:
|
542
549
|
specification_version: 4
|
543
550
|
summary: A convenience libary for manipulating documents in the Fedora Repository.
|