active-fedora 7.0.0.rc2 → 7.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -3
  3. data/CONTRIBUTORS.md +1 -0
  4. data/Gemfile +2 -3
  5. data/active-fedora.gemspec +4 -3
  6. data/gemfiles/rails3.gemfile +1 -7
  7. data/gemfiles/rails4.1.gemfile +5 -0
  8. data/gemfiles/rails4.gemfile +1 -6
  9. data/lib/active_fedora.rb +6 -6
  10. data/lib/active_fedora/associations/association_scope.rb +1 -1
  11. data/lib/active_fedora/base.rb +2 -0
  12. data/lib/active_fedora/datastream.rb +29 -2
  13. data/lib/active_fedora/datastream_collections.rb +2 -2
  14. data/lib/active_fedora/datastream_hash.rb +1 -1
  15. data/lib/active_fedora/datastreams.rb +4 -23
  16. data/lib/active_fedora/file_configurator.rb +8 -7
  17. data/lib/active_fedora/om_datastream.rb +1 -1
  18. data/lib/active_fedora/rdf.rb +9 -0
  19. data/lib/active_fedora/rdf/configurable.rb +59 -0
  20. data/lib/active_fedora/rdf/identifiable.rb +59 -0
  21. data/lib/active_fedora/rdf/indexing.rb +24 -23
  22. data/lib/active_fedora/rdf/list.rb +154 -0
  23. data/lib/active_fedora/{ntriples_rdf_datastream.rb → rdf/ntriples_rdf_datastream.rb} +0 -0
  24. data/lib/active_fedora/rdf/object_resource.rb +20 -0
  25. data/lib/active_fedora/rdf/properties.rb +108 -0
  26. data/lib/active_fedora/rdf/rdf_datastream.rb +113 -0
  27. data/lib/active_fedora/{rdfxml_rdf_datastream.rb → rdf/rdfxml_rdf_datastream.rb} +0 -0
  28. data/lib/active_fedora/rdf/repositories.rb +36 -0
  29. data/lib/active_fedora/rdf/resource.rb +324 -0
  30. data/lib/active_fedora/rdf/term.rb +188 -0
  31. data/lib/active_fedora/relation.rb +1 -0
  32. data/lib/active_fedora/relation/finder_methods.rb +16 -17
  33. data/lib/active_fedora/relation/merger.rb +1 -1
  34. data/lib/active_fedora/relation/query_methods.rb +13 -5
  35. data/lib/active_fedora/reload_on_save.rb +16 -0
  36. data/lib/active_fedora/rubydora_connection.rb +0 -1
  37. data/lib/active_fedora/sharding.rb +1 -1
  38. data/lib/active_fedora/version.rb +1 -1
  39. data/script/console +10 -11
  40. data/spec/config_helper.rb +1 -1
  41. data/spec/fixtures/solr_rdf_descMetadata.nt +1 -1
  42. data/spec/integration/auditable_spec.rb +1 -1
  43. data/spec/integration/base_spec.rb +21 -3
  44. data/spec/integration/complex_rdf_datastream_spec.rb +32 -55
  45. data/spec/integration/field_to_solr_name_spec.rb +6 -8
  46. data/spec/integration/has_many_associations_spec.rb +10 -3
  47. data/spec/integration/load_from_solr_spec.rb +15 -17
  48. data/spec/integration/ntriples_datastream_spec.rb +19 -23
  49. data/spec/integration/om_datastream_spec.rb +1 -1
  50. data/spec/integration/rdf_nested_attributes_spec.rb +51 -70
  51. data/spec/integration/relation_spec.rb +24 -11
  52. data/spec/integration/scoped_query_spec.rb +5 -1
  53. data/spec/samples/hydra-mods_article_datastream.rb +4 -0
  54. data/spec/samples/hydra-rights_metadata_datastream.rb +5 -0
  55. data/spec/samples/marpa-dc_datastream.rb +6 -1
  56. data/spec/samples/special_thing.rb +5 -5
  57. data/spec/spec_helper.rb +0 -3
  58. data/spec/support/an_active_model.rb +5 -12
  59. data/spec/unit/active_fedora_spec.rb +2 -2
  60. data/spec/unit/attributes_spec.rb +4 -8
  61. data/spec/unit/base_datastream_management_spec.rb +5 -29
  62. data/spec/unit/base_spec.rb +4 -0
  63. data/spec/unit/code_configurator_spec.rb +2 -2
  64. data/spec/unit/config_spec.rb +2 -2
  65. data/spec/unit/core_spec.rb +2 -4
  66. data/spec/unit/datastream_spec.rb +15 -0
  67. data/spec/unit/datastreams_spec.rb +1 -12
  68. data/spec/unit/file_configurator_spec.rb +1 -1
  69. data/spec/unit/ntriples_datastream_spec.rb +52 -57
  70. data/spec/unit/om_datastream_spec.rb +3 -3
  71. data/spec/unit/query_spec.rb +3 -4
  72. data/spec/unit/rdf_configurable_spec.rb +37 -0
  73. data/spec/unit/rdf_datastream_spec.rb +5 -7
  74. data/spec/unit/rdf_list_nested_attributes_spec.rb +22 -36
  75. data/spec/unit/rdf_list_spec.rb +26 -38
  76. data/spec/unit/rdf_properties_spec.rb +70 -0
  77. data/spec/unit/rdf_repositories_spec.rb +28 -0
  78. data/spec/unit/rdf_resource_datastream_spec.rb +287 -0
  79. data/spec/unit/rdf_resource_spec.rb +341 -0
  80. data/spec/unit/rdfxml_rdf_datastream_spec.rb +10 -26
  81. data/spec/unit/reload_on_save_spec.rb +24 -0
  82. data/spec/unit/solr_service_spec.rb +3 -3
  83. metadata +45 -16
  84. data/lib/active_fedora/rdf_datastream.rb +0 -113
  85. data/lib/active_fedora/rdf_list.rb +0 -162
  86. data/lib/active_fedora/rdf_node.rb +0 -332
  87. data/lib/active_fedora/rdf_node/term_proxy.rb +0 -141
  88. data/lib/active_fedora/rdf_object.rb +0 -24
  89. data/lib/active_fedora/yaml_adaptor.rb +0 -12
  90. data/spec/unit/rdf_node_spec.rb +0 -36
@@ -3,22 +3,20 @@ require 'spec_helper'
3
3
  describe "Loading from solr" do
4
4
  before do
5
5
  class MyRdfDatastream < ActiveFedora::NtriplesRDFDatastream
6
- map_predicates do |map|
7
- map.title(in: RDF::DC) do |index|
8
- index.as :stored_searchable, :facetable
9
- end
10
- map.date_uploaded(to: "dateSubmitted", in: RDF::DC) do |index|
11
- index.type :date
12
- index.as :stored_searchable, :sortable
13
- end
14
- map.identifier(in: RDF::DC) do |index|
15
- index.type :integer
16
- index.as :stored_searchable, :sortable
17
- end
18
- map.part(to: "hasPart", in: RDF::DC)
19
- map.based_near(in: RDF::FOAF)
20
- map.related_url(to: "seeAlso", in: RDF::RDFS)
6
+ property :title, predicate: RDF::DC.title do |index|
7
+ index.as :stored_searchable, :facetable
21
8
  end
9
+ property :date_uploaded, predicate: RDF::DC.dateSubmitted do |index|
10
+ index.type :date
11
+ index.as :stored_searchable, :sortable
12
+ end
13
+ property :identifier, predicate: RDF::DC.identifier do |index|
14
+ index.type :integer
15
+ index.as :stored_searchable, :sortable
16
+ end
17
+ property :part, predicate: RDF::DC.hasPart
18
+ property :based_near, predicate: RDF::FOAF.based_near
19
+ property :related_url, predicate: RDF::RDFS.seeAlso
22
20
  end
23
21
  class MyOmDatastream < ActiveFedora::OmDatastream
24
22
  set_terminology do |t|
@@ -48,13 +46,13 @@ describe "Loading from solr" do
48
46
  end
49
47
 
50
48
  it "should be able to get indexed properties without loading from fedora" do
51
- expect(RdfTest.connection_for_pid('1')).to receive(:datastream_dissemination).never
49
+ RdfTest.connection_for_pid('1').should_not_receive(:datastream_dissemination)
52
50
  obj = RdfTest.load_instance_from_solr original.pid
53
51
  expect(obj.title).to eq "PLAN 9 FROM OUTER SPACE"
54
52
  expect(obj.date_uploaded).to eq [Date.parse('1959-01-01')]
55
53
  expect(obj.identifier).to eq 12345
56
54
  expect{obj.part}.to raise_error KeyError, "Tried to fetch `part' from solr, but it isn't indexed."
57
- expect(ActiveFedora::DatastreamAttribute.logger).to receive(:info).with "Couldn't get duck out of solr, because the datastream 'MyOmDatastream' doesn't respond to 'primary_solr_name'. Trying another way."
55
+ ActiveFedora::DatastreamAttribute.logger.should_receive(:info).with "Couldn't get duck out of solr, because the datastream 'MyOmDatastream' doesn't respond to 'primary_solr_name'. Trying another way."
58
56
  expect(obj.duck).to eq 'quack'
59
57
  end
60
58
 
@@ -8,25 +8,23 @@ describe ActiveFedora::NtriplesRDFDatastream do
8
8
  end
9
9
 
10
10
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
11
- map_predicates do |map|
12
- map.title(in: RDF::DC) do |index|
13
- index.as :stored_searchable, :facetable
14
- end
15
- map.date_uploaded(to: "dateSubmitted", in: RDF::DC) do |index|
16
- index.type :date
17
- index.as :stored_searchable, :sortable
18
- end
19
- map.size(in: FileVocabulary) do |index|
20
- index.type :integer
21
- index.as :stored_sortable
22
- end
23
- map.part(to: "hasPart", in: RDF::DC)
24
- map.based_near(in: RDF::FOAF)
25
- map.related_url(to: "seeAlso", in: RDF::RDFS)
11
+ property :title, predicate: RDF::DC.title do |index|
12
+ index.as :stored_searchable, :facetable
26
13
  end
14
+ property :date_uploaded, predicate: RDF::DC.dateSubmitted do |index|
15
+ index.type :date
16
+ index.as :stored_searchable, :sortable
17
+ end
18
+ property :size, predicate: FileVocabulary.size do |index|
19
+ index.type :integer
20
+ index.as :stored_sortable
21
+ end
22
+ property :part, predicate: RDF::DC.hasPart
23
+ property :based_near, predicate: RDF::FOAF.based_near
24
+ property :related_url, predicate: RDF::RDFS.seeAlso
27
25
  end
28
26
  class RdfTest < ActiveFedora::Base
29
- has_metadata :name=>'rdf', :type=>MyDatastream
27
+ has_metadata 'rdf', type: MyDatastream
30
28
  has_attributes :based_near, :related_url, :part, :date_uploaded, datastream: 'rdf', multiple: true
31
29
  has_attributes :title, :size, datastream: 'rdf', multiple: false
32
30
  end
@@ -48,7 +46,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
48
46
  end
49
47
 
50
48
  it "should save content properly upon save" do
51
- foo = RdfTest.new(:pid=>'test:1') #Pid needs to match the subject in the loaded file
49
+ foo = RdfTest.new(pid: 'test:1') #Pid needs to match the subject in the loaded file
52
50
  foo.title = 'Hamlet'
53
51
  foo.save
54
52
  foo.title.should == 'Hamlet'
@@ -154,10 +152,8 @@ describe ActiveFedora::NtriplesRDFDatastream do
154
152
  # reopening existing class
155
153
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
156
154
  rdf_subject { |ds| RDF::URI.new("http://oregondigital.org/ns/#{ds.pid.split(':')[1]}") }
157
- map_predicates do |map|
158
- map.type(:in => RDF::DC)
159
- map.spatial(:in => RDF::DC)
160
- end
155
+ property :type, predicate: RDF::DC.type
156
+ property :spatial, predicate: RDF::DC.spatial
161
157
  end
162
158
  end
163
159
  after do
@@ -212,10 +208,10 @@ describe ActiveFedora::NtriplesRDFDatastream do
212
208
  describe "term proxy methods" do
213
209
  before(:each) do
214
210
  class TitleDatastream < ActiveFedora::NtriplesRDFDatastream
215
- map_predicates { |map| map.title(:in => RDF::DC) }
211
+ property :title, predicate: RDF::DC.title
216
212
  end
217
213
  class Foobar < ActiveFedora::Base
218
- has_metadata :name=>'rdf', :type=>TitleDatastream
214
+ has_metadata 'rdf', type: TitleDatastream
219
215
  has_attributes :title, datastream: 'rdf', multiple: true
220
216
  end
221
217
  @subject = Foobar.new
@@ -161,7 +161,7 @@ describe ActiveFedora::OmDatastream do
161
161
  @obj.reload
162
162
  end
163
163
  it "should solrize terms with :type=>'date' to *_dt solr terms" do
164
- @obj.to_solr[ActiveFedora::SolrService.solr_name('journal_issue_publication_date', type: :date)].should == ['2012-11-02T00:00:00Z']
164
+ @obj.to_solr[ActiveFedora::SolrService.solr_name('desc_metadata__journal_issue_publication_date', type: :date)].should == ['2012-11-02T00:00:00Z']
165
165
  end
166
166
  end
167
167
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "Nesting attribute behavior of RDFDatastream" do
4
4
  describe ".attributes=" do
5
5
  describe "complex properties" do
6
- before do
6
+ before do
7
7
  class DummyMADS < RDF::Vocabulary("http://www.loc.gov/mads/rdf/v1#")
8
8
  # componentList and Types of components
9
9
  property :componentList
@@ -12,8 +12,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
12
12
  property :PersonalName
13
13
  property :CorporateName
14
14
  property :ComplexSubject
15
-
16
-
15
+
16
+
17
17
  # elementList and elementList values
18
18
  property :elementList
19
19
  property :elementValue
@@ -25,48 +25,35 @@ describe "Nesting attribute behavior of RDFDatastream" do
25
25
  end
26
26
 
27
27
  class ComplexRDFDatastream < ActiveFedora::NtriplesRDFDatastream
28
- map_predicates do |map|
29
- map.topic(in: DummyMADS, to: "Topic", class_name:"Topic")
30
- map.personalName(in: DummyMADS, to: "PersonalName", class_name:"PersonalName")
31
- map.title(in: RDF::DC)
32
- end
28
+ property :topic, predicate: DummyMADS.Topic, class_name: "Topic"
29
+ property :personalName, predicate: DummyMADS.PersonalName, class_name: "PersonalName"
30
+ property :title, predicate: RDF::DC.title
31
+
33
32
 
34
33
  accepts_nested_attributes_for :topic, :personalName
35
34
 
36
- class Topic
37
- include ActiveFedora::RdfObject
38
- map_predicates do |map|
39
- map.elementList(in: DummyMADS, class_name:"ComplexRDFDatastream::ElementList")
40
- end
35
+ class Topic < ActiveFedora::Rdf::Resource
36
+ property :elementList, predicate: DummyMADS.elementList, class_name: "ComplexRDFDatastream::ElementList"
41
37
  accepts_nested_attributes_for :elementList
42
38
  end
43
- class PersonalName
44
- include ActiveFedora::RdfObject
45
- map_predicates do |map|
46
- map.elementList(in: DummyMADS, to: "elementList", class_name:"ComplexRDFDatastream::ElementList")
47
- map.extraProperty(in: DummyMADS, to: "elementValue", class_name:"ComplexRDFDatastream::Topic")
48
- end
39
+ class PersonalName < ActiveFedora::Rdf::Resource
40
+ property :elementList, predicate: DummyMADS.elementList, class_name: "ComplexRDFDatastream::ElementList"
41
+ property :extraProperty, predicate: DummyMADS.elementValue, class_name: "ComplexRDFDatastream::Topic"
49
42
  accepts_nested_attributes_for :elementList, :extraProperty
50
43
  end
51
- class ElementList
52
- include ActiveFedora::RdfList
53
- rdf_type DummyMADS.elementList
54
- map_predicates do |map|
55
- map.topicElement(in: DummyMADS, to: "TopicElement", :class_name => "MadsTopicElement")
56
- map.temporalElement(in: DummyMADS, to: "TemporalElement")
57
- map.fullNameElement(in: DummyMADS, to: "FullNameElement")
58
- map.dateNameElement(in: DummyMADS, to: "DateNameElement")
59
- map.nameElement(in: DummyMADS, to: "NameElement")
60
- map.elementValue(in: DummyMADS)
61
- end
44
+ class ElementList < ActiveFedora::Rdf::List
45
+ configure type: DummyMADS.elementList
46
+ property :topicElement, predicate: DummyMADS.TopicElement, class_name: "ComplexRDFDatastream::MadsTopicElement"
47
+ property :temporalElement, predicate: DummyMADS.TemporalElement
48
+ property :fullNameElement, predicate: DummyMADS.FullNameElement
49
+ property :dateNameElement, predicate: DummyMADS.DateNameElement
50
+ property :nameElement, predicate: DummyMADS.NameElement
51
+ property :elementValue, predicate: DummyMADS.elementValue
62
52
  accepts_nested_attributes_for :topicElement
63
53
  end
64
- class MadsTopicElement
65
- include ActiveFedora::RdfObject
66
- rdf_type DummyMADS.TopicElement
67
- map_predicates do |map|
68
- map.elementValue(in: DummyMADS)
69
- end
54
+ class MadsTopicElement < ActiveFedora::Rdf::Resource
55
+ configure :type => DummyMADS.TopicElement
56
+ property :elementValue, predicate: DummyMADS.elementValue
70
57
  end
71
58
  end
72
59
  end
@@ -75,8 +62,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
75
62
  Object.send(:remove_const, :DummyMADS)
76
63
  end
77
64
  subject { ComplexRDFDatastream.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMetadata') }
78
- let(:params) do
79
- { myResource:
65
+ let(:params) do
66
+ { myResource:
80
67
  {
81
68
  topic_attributes: {
82
69
  '0' =>
@@ -93,12 +80,12 @@ describe "Nesting attribute behavior of RDFDatastream" do
93
80
  }
94
81
  },
95
82
  personalName_attributes: [
96
- {
83
+ {
97
84
  elementList_attributes: [{
98
85
  fullNameElement: "Jefferson, Thomas",
99
- dateNameElement: "1743-1826"
86
+ dateNameElement: "1743-1826"
100
87
  }]
101
- }
88
+ }
102
89
  #, "Hemings, Sally"
103
90
  ],
104
91
  }
@@ -106,7 +93,7 @@ describe "Nesting attribute behavior of RDFDatastream" do
106
93
  end
107
94
 
108
95
  describe "on lists" do
109
- subject { ComplexRDFDatastream::PersonalName.new(RDF::Graph.new) }
96
+ subject { ComplexRDFDatastream::PersonalName.new(RDF::Graph.new) }
110
97
  it "should accept a hash" do
111
98
  subject.elementList_attributes = [{ topicElement_attributes: {'0' => { elementValue:"Quantum Behavior" }, '1' => { elementValue:"Wave Function" }}}]
112
99
  subject.elementList.first[0].elementValue.should == ["Quantum Behavior"]
@@ -121,43 +108,37 @@ describe "Nesting attribute behavior of RDFDatastream" do
121
108
  end
122
109
 
123
110
  it "should create nested objects" do
124
- # Replace the graph's contents with the Hash
125
- subject.attributes = params[:myResource]
126
-
127
- # Here's how this would happen if we didn't have attributes=
128
- # personal_name = subject.personalName.build
129
- # elem_list = personal_name.elementList.build
130
- # elem_list.fullNameElement = "Jefferson, Thomas"
131
- # elem_list.dateNameElement = "1743-1826"
132
- # topic = subject.topic.build
133
- # elem_list = topic.elementList.build
134
- # elem_list.fullNameElement = 'Cosmology'
135
-
136
- subject.topic[0].elementList.first[0].elementValue.should == ["Cosmology"]
137
- subject.topic[1].elementList.first[0].elementValue.should == ["Quantum Behavior"]
138
- subject.personalName.first.elementList.first.fullNameElement.should == ["Jefferson, Thomas"]
139
- subject.personalName.first.elementList.first.dateNameElement.should == ["1743-1826"]
111
+ # Replace the graph's contents with the Hash
112
+ subject.attributes = params[:myResource]
113
+
114
+ # Here's how this would happen if we didn't have attributes=
115
+ # personal_name = subject.personalName.build
116
+ # elem_list = personal_name.elementList.build
117
+ # elem_list.fullNameElement = "Jefferson, Thomas"
118
+ # elem_list.dateNameElement = "1743-1826"
119
+ # topic = subject.topic.build
120
+ # elem_list = topic.elementList.build
121
+ # elem_list.fullNameElement = 'Cosmology'
122
+ subject.topic[0].elementList.first[0].elementValue.should == ["Cosmology"]
123
+ subject.topic[1].elementList.first[0].elementValue.should == ["Quantum Behavior"]
124
+ subject.personalName.first.elementList.first.fullNameElement.should == ["Jefferson, Thomas"]
125
+ subject.personalName.first.elementList.first.dateNameElement.should == ["1743-1826"]
140
126
  end
141
127
  end
142
128
 
143
129
  describe "with an existing object" do
144
- before(:each) do
130
+ before(:each) do
145
131
  class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
146
- map_predicates do |map|
147
- map.parts(:in=> RDF::DC, :to=>'hasPart', :class_name=>'Component')
148
- end
132
+ property :parts, predicate: RDF::DC.hasPart, :class_name=>'Component'
149
133
  accepts_nested_attributes_for :parts, allow_destroy: true
150
134
 
151
- class Component
152
- include ActiveFedora::RdfObject
153
- map_predicates do |map|
154
- map.label(:in=> RDF::DC, :to=>'title')
155
- end
135
+ class Component < ActiveFedora::Rdf::ObjectResource
136
+ property :label, predicate: RDF::DC.title
156
137
  end
157
138
  end
158
139
 
159
140
  end
160
-
141
+
161
142
  after(:each) do
162
143
  Object.send(:remove_const, :SpecDatastream)
163
144
  end
@@ -180,8 +161,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
180
161
  end
181
162
  it "create a new object when the id is provided" do
182
163
  subject.parts_attributes= [{id: 'http://example.com/part#1', label: "Universal Joint"}]
183
- subject.parts.last.rdf_subject.should == 'http://example.com/part#1'
164
+ expect(subject.parts.last.rdf_subject).to eq RDF::URI('http://example.com/part#1')
184
165
  end
185
- end
166
+ end
186
167
  end
187
168
  end
@@ -13,29 +13,42 @@ describe ActiveFedora::Base do
13
13
  Object.send(:remove_const, :Book)
14
14
  end
15
15
 
16
- subject {Library.all}
16
+ subject { Library.all }
17
17
  its(:class) {should eq ActiveFedora::Relation }
18
18
 
19
- describe "#find" do
19
+ before :all do
20
+ Library.create
21
+ @library = Library.create
22
+ end
23
+
24
+ let(:library1) { @library }
25
+
26
+ describe "is cached" do
20
27
  before do
21
- Library.create
22
- @library = Library.create
28
+ subject.to_a # trigger initial load
29
+ end
30
+
31
+ it "should be loaded" do
32
+ expect(subject).to be_loaded
23
33
  end
34
+ it "shouldn't reload" do
35
+ ActiveFedora::Relation.any_instance.should_not_receive :find_each
36
+ subject[0]
37
+ end
38
+ end
39
+
40
+ describe "#find" do
24
41
  it "should find one of them" do
25
- expect(subject.find(@library.id)).to eq @library
42
+ expect(subject.find(library1.id)).to eq library1
26
43
  end
27
44
  it "should find with a block" do
28
- expect(subject.find { |l| l.id == @library.id}).to eq @library
45
+ expect(subject.find { |l| l.id == library1.id}).to eq library1
29
46
  end
30
47
  end
31
48
 
32
49
  describe "#select" do
33
- before do
34
- Library.create
35
- @library = Library.create
36
- end
37
50
  it "should find with a block" do
38
- expect(subject.select { |l| l.id == @library.id}).to eq [@library]
51
+ expect(subject.select { |l| l.id == library1.id}).to eq [library1]
39
52
  end
40
53
  end
41
54
  end
@@ -81,8 +81,12 @@ describe "scoped queries" do
81
81
  ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1).should == [test_instance2]
82
82
  end
83
83
 
84
+ it "should wrap string conditions with parentheses" do
85
+ ModelIntegrationSpec::Basic.where("foo:bar OR bar:baz").where_values.should == ["(foo:bar OR bar:baz)"]
86
+ end
87
+
84
88
  it "should chain where queries" do
85
- ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').where(ActiveFedora::SolrService.solr_name('foo', type: :string) => 'bar').where_values.should == {ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts', ActiveFedora::SolrService.solr_name('foo', type: :string) => 'bar'}
89
+ ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').where("#{ActiveFedora::SolrService.solr_name('foo', type: :string)}:bar").where_values.should == ["#{ActiveFedora::SolrService.solr_name('bar', type: :string)}:Peanuts", "(#{ActiveFedora::SolrService.solr_name('foo', type: :string)}:bar)"]
86
90
  end
87
91
 
88
92
  it "should chain count" do
@@ -153,6 +153,10 @@ module Hydra
153
153
  end
154
154
  return builder.doc
155
155
  end
156
+
157
+ def prefix
158
+ "#{dsid.underscore}__"
159
+ end
156
160
 
157
161
  # Generates a new Person node
158
162
  def self.person_template
@@ -79,6 +79,11 @@ module Hydra
79
79
  end
80
80
  return builder.doc
81
81
  end
82
+
83
+ def prefix
84
+ "#{dsid.underscore}__"
85
+ end
86
+
82
87
 
83
88
  # Returns the permissions for the selected person/group
84
89
  # If new_access_level is provided, updates the selected person/group access_level to the one specified
@@ -92,6 +92,11 @@ module Marpa
92
92
  end
93
93
  return builder.doc
94
94
  end
95
+
96
+ def prefix
97
+ "#{dsid.underscore}__"
98
+ end
99
+
95
100
 
96
101
  end
97
- end
102
+ end
@@ -21,15 +21,15 @@ class SpecialThing < ActiveFedora::Base
21
21
  # This declares a datastream with Datastream ID (dsid) of "descMetadata"
22
22
  # The descMetadata datastream is bound to the Hydra::ModsArticleDatastream class that's defined in lib/active_fedora/samples
23
23
  # Any time you load a Fedora object using an instance of SampleModel, the instance will assume its descMetadata datastream conforms to the assumptions in Hydra::ModsArticleDatastream class
24
- has_metadata :name => "descMetadata", :type=> Hydra::ModsArticleDatastream
24
+ has_metadata "descMetadata", type: Hydra::ModsArticleDatastream
25
25
 
26
26
  # This declares a datastream with Datastream ID (dsid) of "rightsMetadata"
27
27
  # Like the descMetadata datastream, any time you load a Fedora object using an instance of SampleModel, the instance will assume its descMetadata datastream conforms to the assumptions in Hydra::RightsMetadataDatastream class
28
- has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadataDatastream
28
+ has_metadata "rightsMetadata", type: Hydra::RightsMetadataDatastream
29
29
 
30
30
  # This is not part of the Hydra conventions
31
31
  # Adding an extra datastream called "extraMetadataForFun" that is bound to the Marpa::DcDatastream class
32
- has_metadata :name => "extraMetadataForFun", :type => Marpa::DcDatastream
32
+ has_metadata "extraMetadataForFun", type: Marpa::DcDatastream
33
33
 
34
34
  #
35
35
  # RELATIONSHIPS
@@ -37,8 +37,8 @@ class SpecialThing < ActiveFedora::Base
37
37
 
38
38
  # This is an example of how you can add a custom relationship to a model
39
39
  # This will allow you to call .derivation on instances of the model to get the _outbound_ "hasDerivation" relationship in the RELS-EXT datastream
40
- belongs_to :derivation, :property=>:has_derivation
40
+ belongs_to :derivation, property: :has_derivation, class_name: 'SpecialThing'
41
41
 
42
42
  # This will allow you to call .inspirations on instances of the model to get a list of all of the objects that assert "hasDerivation" relationships pointing at this object
43
- has_many :inspirations, :property=>:has_derivation
43
+ has_many :inspirations, property: :has_derivation, class_name: 'SpecialThing'
44
44
  end