active-fedora 6.8.0 → 7.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +15 -5
  4. data/CONTRIBUTING.md +2 -0
  5. data/Gemfile +0 -2
  6. data/History.txt +2 -32
  7. data/README.md +143 -0
  8. data/Rakefile +5 -7
  9. data/active-fedora.gemspec +9 -9
  10. data/gemfiles/rails3.gemfile +11 -0
  11. data/gemfiles/rails4.gemfile +10 -0
  12. data/lib/active_fedora.rb +31 -4
  13. data/lib/active_fedora/association_relation.rb +18 -0
  14. data/lib/active_fedora/associations.rb +38 -171
  15. data/lib/active_fedora/associations/association.rb +163 -0
  16. data/lib/active_fedora/associations/association_scope.rb +39 -0
  17. data/lib/active_fedora/associations/belongs_to_association.rb +47 -25
  18. data/lib/active_fedora/associations/builder/association.rb +55 -0
  19. data/lib/active_fedora/associations/builder/belongs_to.rb +100 -0
  20. data/lib/active_fedora/associations/builder/collection_association.rb +56 -0
  21. data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +30 -0
  22. data/lib/active_fedora/associations/builder/has_many.rb +63 -0
  23. data/lib/active_fedora/associations/builder/singular_association.rb +32 -0
  24. data/lib/active_fedora/associations/{association_collection.rb → collection_association.rb} +203 -53
  25. data/lib/active_fedora/associations/collection_proxy.rb +862 -0
  26. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +35 -25
  27. data/lib/active_fedora/associations/has_many_association.rb +36 -11
  28. data/lib/active_fedora/associations/singular_association.rb +62 -0
  29. data/lib/active_fedora/attributes.rb +43 -139
  30. data/lib/active_fedora/autosave_association.rb +317 -0
  31. data/lib/active_fedora/base.rb +10 -327
  32. data/lib/active_fedora/callbacks.rb +1 -3
  33. data/lib/active_fedora/content_model.rb +16 -0
  34. data/lib/active_fedora/core.rb +151 -0
  35. data/lib/active_fedora/datastream_attribute.rb +76 -0
  36. data/lib/active_fedora/datastream_hash.rb +8 -13
  37. data/lib/active_fedora/datastreams.rb +39 -26
  38. data/lib/active_fedora/digital_object.rb +2 -2
  39. data/lib/active_fedora/fedora_attributes.rb +45 -0
  40. data/lib/active_fedora/fixture_loader.rb +1 -1
  41. data/lib/active_fedora/indexing.rb +6 -1
  42. data/lib/active_fedora/model.rb +0 -17
  43. data/lib/active_fedora/nested_attributes.rb +2 -2
  44. data/lib/active_fedora/null_relation.rb +7 -0
  45. data/lib/active_fedora/om_datastream.rb +3 -4
  46. data/lib/active_fedora/persistence.rb +41 -29
  47. data/lib/active_fedora/querying.rb +2 -163
  48. data/lib/active_fedora/rdf.rb +1 -0
  49. data/lib/active_fedora/rdf/indexing.rb +67 -0
  50. data/lib/active_fedora/rdf_datastream.rb +2 -50
  51. data/lib/active_fedora/rdf_node.rb +12 -7
  52. data/lib/active_fedora/rdf_node/term_proxy.rb +30 -21
  53. data/lib/active_fedora/rdfxml_rdf_datastream.rb +1 -1
  54. data/lib/active_fedora/reflection.rb +163 -20
  55. data/lib/active_fedora/relation.rb +33 -130
  56. data/lib/active_fedora/relation/calculations.rb +19 -0
  57. data/lib/active_fedora/relation/delegation.rb +22 -0
  58. data/lib/active_fedora/relation/finder_methods.rb +247 -0
  59. data/lib/active_fedora/relation/merger.rb +22 -0
  60. data/lib/active_fedora/relation/query_methods.rb +58 -0
  61. data/lib/active_fedora/relation/spawn_methods.rb +46 -0
  62. data/lib/active_fedora/relationship_graph.rb +0 -2
  63. data/lib/active_fedora/rels_ext_datastream.rb +1 -4
  64. data/lib/active_fedora/rubydora_connection.rb +1 -1
  65. data/lib/active_fedora/scoping.rb +20 -0
  66. data/lib/active_fedora/scoping/default.rb +38 -0
  67. data/lib/active_fedora/scoping/named.rb +32 -0
  68. data/lib/active_fedora/semantic_node.rb +54 -106
  69. data/lib/active_fedora/serialization.rb +19 -0
  70. data/lib/active_fedora/sharding.rb +58 -0
  71. data/lib/active_fedora/solr_digital_object.rb +15 -5
  72. data/lib/active_fedora/solr_instance_loader.rb +1 -1
  73. data/lib/active_fedora/solr_service.rb +1 -1
  74. data/lib/active_fedora/unsaved_digital_object.rb +6 -4
  75. data/lib/active_fedora/version.rb +1 -1
  76. data/lib/tasks/active_fedora.rake +3 -0
  77. data/lib/tasks/active_fedora_dev.rake +6 -5
  78. data/spec/config_helper.rb +14 -14
  79. data/spec/integration/associations_spec.rb +168 -455
  80. data/spec/integration/attributes_spec.rb +12 -11
  81. data/spec/integration/auditable_spec.rb +11 -11
  82. data/spec/integration/autosave_association_spec.rb +25 -0
  83. data/spec/integration/base_spec.rb +163 -163
  84. data/spec/integration/belongs_to_association_spec.rb +166 -0
  85. data/spec/integration/bug_spec.rb +7 -7
  86. data/spec/integration/collection_association_spec.rb +58 -0
  87. data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
  88. data/spec/integration/datastream_collections_spec.rb +69 -69
  89. data/spec/integration/datastream_spec.rb +43 -43
  90. data/spec/integration/datastreams_spec.rb +63 -63
  91. data/spec/integration/delete_all_spec.rb +46 -39
  92. data/spec/integration/fedora_solr_sync_spec.rb +5 -5
  93. data/spec/integration/field_to_solr_name_spec.rb +34 -0
  94. data/spec/integration/full_featured_model_spec.rb +100 -101
  95. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +341 -0
  96. data/spec/integration/has_many_associations_spec.rb +172 -24
  97. data/spec/integration/json_serialization_spec.rb +31 -0
  98. data/spec/integration/load_from_solr_spec.rb +48 -0
  99. data/spec/integration/model_spec.rb +35 -40
  100. data/spec/integration/nested_attribute_spec.rb +42 -43
  101. data/spec/integration/ntriples_datastream_spec.rb +131 -113
  102. data/spec/integration/om_datastream_spec.rb +67 -67
  103. data/spec/integration/persistence_spec.rb +7 -7
  104. data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
  105. data/spec/integration/relation_delegation_spec.rb +26 -25
  106. data/spec/integration/relation_spec.rb +42 -0
  107. data/spec/integration/rels_ext_datastream_spec.rb +20 -20
  108. data/spec/integration/scoped_query_spec.rb +61 -51
  109. data/spec/integration/solr_instance_loader_spec.rb +5 -5
  110. data/spec/integration/solr_service_spec.rb +46 -46
  111. data/spec/samples/hydra-mods_article_datastream.rb +334 -334
  112. data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
  113. data/spec/samples/marpa-dc_datastream.rb +17 -17
  114. data/spec/samples/models/audio_record.rb +16 -16
  115. data/spec/samples/models/image.rb +2 -2
  116. data/spec/samples/models/mods_article.rb +5 -5
  117. data/spec/samples/models/oral_history.rb +18 -18
  118. data/spec/samples/models/seminar.rb +24 -24
  119. data/spec/samples/models/seminar_audio_file.rb +17 -17
  120. data/spec/samples/oral_history_sample_model.rb +21 -21
  121. data/spec/samples/special_thing.rb +14 -14
  122. data/spec/spec_helper.rb +11 -7
  123. data/spec/support/an_active_model.rb +2 -8
  124. data/spec/support/freeze_mocks.rb +12 -0
  125. data/spec/support/mock_fedora.rb +17 -16
  126. data/spec/unit/active_fedora_spec.rb +58 -60
  127. data/spec/unit/attributes_spec.rb +314 -0
  128. data/spec/unit/base_active_model_spec.rb +28 -27
  129. data/spec/unit/base_cma_spec.rb +5 -5
  130. data/spec/unit/base_datastream_management_spec.rb +27 -27
  131. data/spec/unit/base_extra_spec.rb +76 -48
  132. data/spec/unit/base_spec.rb +277 -348
  133. data/spec/unit/callback_spec.rb +18 -19
  134. data/spec/unit/code_configurator_spec.rb +17 -17
  135. data/spec/unit/config_spec.rb +8 -16
  136. data/spec/unit/content_model_spec.rb +79 -60
  137. data/spec/unit/datastream_collections_spec.rb +229 -229
  138. data/spec/unit/datastream_spec.rb +51 -63
  139. data/spec/unit/datastreams_spec.rb +87 -87
  140. data/spec/unit/file_configurator_spec.rb +217 -217
  141. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +44 -25
  142. data/spec/unit/has_many_collection_spec.rb +26 -8
  143. data/spec/unit/inheritance_spec.rb +13 -12
  144. data/spec/unit/model_spec.rb +39 -45
  145. data/spec/unit/nom_datastream_spec.rb +15 -15
  146. data/spec/unit/ntriples_datastream_spec.rb +123 -118
  147. data/spec/unit/om_datastream_spec.rb +227 -233
  148. data/spec/unit/persistence_spec.rb +34 -15
  149. data/spec/unit/predicates_spec.rb +73 -73
  150. data/spec/unit/property_spec.rb +17 -9
  151. data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
  152. data/spec/unit/query_spec.rb +222 -198
  153. data/spec/unit/rdf_datastream_spec.rb +21 -28
  154. data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
  155. data/spec/unit/rdf_list_spec.rb +65 -64
  156. data/spec/unit/rdf_node_spec.rb +7 -7
  157. data/spec/unit/rdf_xml_writer_spec.rb +10 -10
  158. data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
  159. data/spec/unit/relationship_graph_spec.rb +51 -51
  160. data/spec/unit/rels_ext_datastream_spec.rb +68 -74
  161. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
  162. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
  163. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
  164. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
  165. data/spec/unit/rubydora_connection_spec.rb +5 -5
  166. data/spec/unit/semantic_node_spec.rb +48 -107
  167. data/spec/unit/serializers_spec.rb +4 -4
  168. data/spec/unit/service_definitions_spec.rb +26 -26
  169. data/spec/unit/simple_datastream_spec.rb +17 -17
  170. data/spec/unit/solr_config_options_spec.rb +29 -28
  171. data/spec/unit/solr_digital_object_spec.rb +17 -25
  172. data/spec/unit/solr_service_spec.rb +95 -82
  173. data/spec/unit/unsaved_digital_object_spec.rb +24 -23
  174. data/spec/unit/validations_spec.rb +21 -21
  175. metadata +110 -159
  176. data/.rspec +0 -1
  177. data/.rubocop.yml +0 -1
  178. data/.rubocop_todo.yml +0 -938
  179. data/CONSOLE_GETTING_STARTED.textile +0 -1
  180. data/NOKOGIRI_DATASTREAMS.textile +0 -1
  181. data/README.textile +0 -116
  182. data/lib/active_fedora/associations/association_proxy.rb +0 -178
  183. data/lib/active_fedora/delegating.rb +0 -72
  184. data/lib/active_fedora/nokogiri_datastream.rb +0 -11
  185. data/spec/integration/delegating_spec.rb +0 -59
  186. data/spec/rails3_test_app/.gitignore +0 -4
  187. data/spec/rails3_test_app/.rspec +0 -1
  188. data/spec/rails3_test_app/Gemfile +0 -40
  189. data/spec/rails3_test_app/Rakefile +0 -7
  190. data/spec/rails3_test_app/app/controllers/application_controller.rb +0 -3
  191. data/spec/rails3_test_app/app/helpers/application_helper.rb +0 -2
  192. data/spec/rails3_test_app/app/views/layouts/application.html.erb +0 -14
  193. data/spec/rails3_test_app/config.ru +0 -4
  194. data/spec/rails3_test_app/config/application.rb +0 -42
  195. data/spec/rails3_test_app/config/boot.rb +0 -6
  196. data/spec/rails3_test_app/config/database.yml +0 -22
  197. data/spec/rails3_test_app/config/environment.rb +0 -5
  198. data/spec/rails3_test_app/config/environments/development.rb +0 -25
  199. data/spec/rails3_test_app/config/environments/production.rb +0 -49
  200. data/spec/rails3_test_app/config/environments/test.rb +0 -35
  201. data/spec/rails3_test_app/config/initializers/backtrace_silencers.rb +0 -7
  202. data/spec/rails3_test_app/config/initializers/inflections.rb +0 -10
  203. data/spec/rails3_test_app/config/initializers/mime_types.rb +0 -5
  204. data/spec/rails3_test_app/config/initializers/secret_token.rb +0 -7
  205. data/spec/rails3_test_app/config/initializers/session_store.rb +0 -8
  206. data/spec/rails3_test_app/config/locales/en.yml +0 -5
  207. data/spec/rails3_test_app/config/routes.rb +0 -58
  208. data/spec/rails3_test_app/db/seeds.rb +0 -7
  209. data/spec/rails3_test_app/run_tests +0 -3
  210. data/spec/rails3_test_app/script/rails +0 -6
  211. data/spec/rails3_test_app/spec/spec_helper.rb +0 -27
  212. data/spec/rails3_test_app/spec/unit/rails_3_init.rb +0 -15
  213. data/spec/unit/association_proxy_spec.rb +0 -12
  214. data/spec/unit/base_delegate_spec.rb +0 -197
  215. data/spec/unit/base_delegate_to_spec.rb +0 -73
@@ -1,97 +1,107 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'scoped queries' do
4
-
5
- before(:each) do
3
+ describe "scoped queries" do
4
+
5
+ before(:each) do
6
6
  module ModelIntegrationSpec
7
7
  class Basic < ActiveFedora::Base
8
- has_metadata :name => 'properties', :type => ActiveFedora::SimpleDatastream do |m|
9
- m.field 'foo', :string
10
- m.field 'bar', :string
11
- m.field 'baz', :string
8
+ has_metadata "properties", type: ActiveFedora::SimpleDatastream do |m|
9
+ m.field "foo", :string
10
+ m.field "bar", :string
11
+ m.field "baz", :string
12
12
  end
13
13
 
14
- delegate_to :properties, [:foo, :bar, :baz], multiple: true
14
+ has_attributes :foo, :bar, :baz, datastream: 'properties', multiple: true
15
15
 
16
16
  def to_solr(doc = {})
17
17
  doc = super
18
18
  doc[ActiveFedora::SolrService.solr_name('foo', :sortable)] = doc[ActiveFedora::SolrService.solr_name('foo', type: :string)]
19
19
  doc
20
20
  end
21
-
21
+
22
22
  end
23
23
  end
24
24
 
25
25
  end
26
-
26
+
27
27
  after(:each) do
28
28
  Object.send(:remove_const, :ModelIntegrationSpec)
29
29
  end
30
30
 
31
31
 
32
- describe 'When there is one object in the store' do
32
+ describe "When there is one object in the store" do
33
33
  let!(:test_instance) { ModelIntegrationSpec::Basic.create!()}
34
34
 
35
35
  after do
36
36
  test_instance.delete
37
37
  end
38
-
39
- describe '.all' do
40
- it 'should return an array of instances of the calling Class' do
41
- result = ModelIntegrationSpec::Basic.all
42
- expect(result).to be_instance_of(Array)
38
+
39
+ describe ".all" do
40
+ it "should return an array of instances of the calling Class" do
41
+ result = ModelIntegrationSpec::Basic.all.to_a
42
+ result.should be_instance_of(Array)
43
43
  # this test is meaningless if the array length is zero
44
- expect(result.length).to be > 0
44
+ result.length.should > 0
45
45
  result.each do |obj|
46
- expect(obj.class).to eq(ModelIntegrationSpec::Basic)
46
+ obj.class.should == ModelIntegrationSpec::Basic
47
47
  end
48
48
  end
49
49
  end
50
50
 
51
- describe '.first' do
52
- it 'should return one instance of the calling class' do
53
- expect(ModelIntegrationSpec::Basic.first).to eq(test_instance)
51
+ describe ".first" do
52
+ it "should return one instance of the calling class" do
53
+ ModelIntegrationSpec::Basic.first.should == test_instance
54
54
  end
55
55
  end
56
56
  end
57
57
 
58
- describe 'with multiple objects' do
59
- let!(:test_instance1) { ModelIntegrationSpec::Basic.create!(:foo => 'Beta', :bar => 'Chips')}
60
- let!(:test_instance2) { ModelIntegrationSpec::Basic.create!(:foo => 'Alpha', :bar => 'Peanuts')}
61
- let!(:test_instance3) { ModelIntegrationSpec::Basic.create!(:foo => 'Sigma', :bar => 'Peanuts')}
58
+ describe "with multiple objects" do
59
+ let!(:test_instance1) { ModelIntegrationSpec::Basic.create!(:foo=>'Beta', :bar=>'Chips')}
60
+ let!(:test_instance2) { ModelIntegrationSpec::Basic.create!(:foo=>'Alpha', :bar=>'Peanuts')}
61
+ let!(:test_instance3) { ModelIntegrationSpec::Basic.create!(:foo=>'Sigma', :bar=>'Peanuts')}
62
62
 
63
- after do
64
- test_instance1.delete
65
- test_instance2.delete
66
- test_instance3.delete
67
- end
68
- it 'should query' do
69
- expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string) => 'Beta')).to eq([test_instance1])
70
- expect(ModelIntegrationSpec::Basic.where('foo' => 'Beta')).to eq([test_instance1])
71
- end
72
- it 'should order' do
73
- expect(ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc')).to eq([test_instance2, test_instance1, test_instance3])
74
- end
75
- it 'should limit' do
76
- expect(ModelIntegrationSpec::Basic.limit(1)).to eq([test_instance1])
77
- end
63
+ describe "when the objects are in fedora" do
64
+ after do
65
+ test_instance1.delete
66
+ test_instance2.delete
67
+ test_instance3.delete
68
+ end
69
+ it "should query" do
70
+ ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string)=> 'Beta').should == [test_instance1]
71
+ ModelIntegrationSpec::Basic.where('foo' => 'Beta').should == [test_instance1]
72
+ end
73
+ it "should order" do
74
+ ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').should == [test_instance2, test_instance1, test_instance3]
75
+ end
76
+ it "should limit" do
77
+ ModelIntegrationSpec::Basic.limit(1).should == [test_instance1]
78
+ end
78
79
 
79
- it 'should chain queries' do
80
- expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1)).to eq([test_instance2])
81
- end
80
+ it "should chain queries" do
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
+ end
82
83
 
83
- it 'should chain count' do
84
- expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').count).to eq(2)
84
+ it "should chain count" do
85
+ ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').count.should == 2
86
+ end
85
87
  end
86
88
 
87
89
  describe "when one of the objects in solr isn't in fedora" do
88
- it 'should log an error' do
89
- expect(ModelIntegrationSpec::Basic).to receive(:find_one).with(test_instance1.pid, nil).and_call_original
90
- expect(ModelIntegrationSpec::Basic).to receive(:find_one).with(test_instance2.pid, nil).and_raise(ActiveFedora::ObjectNotFoundError)
91
- expect(ModelIntegrationSpec::Basic).to receive(:find_one).with(test_instance3.pid, nil).and_call_original
92
- expect(ActiveFedora::Relation.logger).to receive(:error).with("When trying to find_each #{test_instance2.pid}, encountered an ObjectNotFoundError. Solr may be out of sync with Fedora")
93
- expect(ModelIntegrationSpec::Basic.all).to eq([test_instance1, test_instance3])
90
+ let!(:pid) { test_instance2.pid }
91
+ before { test_instance2.inner_object.delete }
92
+ after do
93
+ ActiveFedora::SolrService.instance.conn.tap do |conn|
94
+ conn.delete_by_query "id:\"#{pid}\""
95
+ conn.commit
96
+ end
97
+ test_instance1.delete
98
+ test_instance3.delete
99
+ end
100
+ it "should log an error" do
101
+ ActiveFedora::Relation.logger.should_receive(:error).with("Although #{pid} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch.")
102
+ ModelIntegrationSpec::Basic.all.should == [test_instance1, test_instance3]
94
103
  end
95
104
  end
96
105
  end
97
106
  end
107
+
@@ -11,7 +11,7 @@ describe ActiveFedora::SolrInstanceLoader do
11
11
  let(:context) { ActiveFedora::Base }
12
12
  let(:pid) { nil }
13
13
  let(:solr_doc) { nil }
14
- let(:active_fedora_object) { ActiveFedora::Base.find(pid, :cast => true) }
14
+ let(:active_fedora_object) { ActiveFedora::Base.find(pid) }
15
15
  subject { ActiveFedora::SolrInstanceLoader.new(context, pid, solr_doc) }
16
16
 
17
17
  describe 'existing pid' do
@@ -22,14 +22,14 @@ describe ActiveFedora::SolrInstanceLoader do
22
22
  end
23
23
  end
24
24
  describe 'with matching solr document' do
25
- let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id => pid).first }
25
+ let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>pid).first }
26
26
  it 'it casts the SOLR document and casts into an AF::Base object' do
27
27
  expect(subject.object).to eq(active_fedora_object)
28
28
  end
29
29
  end
30
30
  describe 'with a mismatching solr document' do
31
31
  let(:mismatching_pid) { @test_object2.pid }
32
- let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id => mismatching_pid).first }
32
+ let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>mismatching_pid).first }
33
33
  it 'it raise ObjectNotFoundError' do
34
34
  expect {
35
35
  subject
@@ -47,7 +47,7 @@ describe ActiveFedora::SolrInstanceLoader do
47
47
  end
48
48
  end
49
49
  describe 'with matching solr document' do
50
- let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id => pid).first }
50
+ let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>pid).first }
51
51
  it 'it raise ObjectNotFoundError' do
52
52
  expect {
53
53
  subject.object
@@ -56,7 +56,7 @@ describe ActiveFedora::SolrInstanceLoader do
56
56
  end
57
57
  describe 'with a mismatching solr document' do
58
58
  let(:mismatching_pid) { @test_object2.pid }
59
- let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id => mismatching_pid).first }
59
+ let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>mismatching_pid).first }
60
60
  it 'it raise ObjectNotFoundError' do
61
61
  expect {
62
62
  subject
@@ -3,23 +3,23 @@ require 'spec_helper'
3
3
  require 'active_fedora'
4
4
 
5
5
  describe ActiveFedora::SolrService do
6
- describe '#reify_solr_results' do
6
+ describe "#reify_solr_results" do
7
7
  before(:all) do
8
8
  class FooObject < ActiveFedora::Base
9
9
  def self.pid_namespace
10
- 'foo'
10
+ "foo"
11
11
  end
12
-
13
- has_metadata :name => 'descMetadata', :type => ActiveFedora::QualifiedDublinCoreDatastream
12
+
13
+ has_metadata :name => "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream
14
14
  end
15
15
  @test_object = ActiveFedora::Base.new
16
16
  @test_object.label = 'test_object'
17
17
  @foo_object = FooObject.new
18
18
  @foo_object.label = 'foo_object'
19
- attributes = {'language' => {0 => 'Italian'},
20
- 'creator' => {0 => 'Linguist, A.'},
21
- 'geography' => {0 => 'Italy'},
22
- 'title' => {0 => 'Italian and Spanish: A Comparison of Common Phrases'}}
19
+ attributes = {"language"=>{0=>"Italian"},
20
+ "creator"=>{0=>"Linguist, A."},
21
+ "geography"=>{0=>"Italy"},
22
+ "title"=>{0=>"Italian and Spanish: A Comparison of Common Phrases"}}
23
23
  @foo_object.descMetadata.update_indexed_attributes(attributes)
24
24
  @test_object.save
25
25
  @foo_object.save
@@ -35,78 +35,78 @@ describe ActiveFedora::SolrService do
35
35
  @foo_object.delete
36
36
  Object.send(:remove_const, :FooObject)
37
37
  end
38
- it 'should return an array of objects that are of the class stored in active_fedora_model_s' do
38
+ it "should return an array of objects that are of the class stored in active_fedora_model_s" do
39
39
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@test_object.pid)} OR id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
40
40
  solr_result = ActiveFedora::SolrService.query(query)
41
41
  result = ActiveFedora::SolrService.reify_solr_results(solr_result)
42
- expect(result.length).to eq(2)
42
+ result.length.should == 2
43
43
  result.each do |r|
44
- expect(r.class == ActiveFedora::Base || r.class == FooObject).to be_truthy
44
+ (r.class == ActiveFedora::Base || r.class == FooObject).should be_true
45
45
  end
46
46
  end
47
-
47
+
48
48
  it 'should load objects from solr data if a :load_from_solr option is passed in' do
49
49
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@test_object.pid)} OR id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
50
50
  solr_result = ActiveFedora::SolrService.query(query)
51
- result = ActiveFedora::SolrService.reify_solr_results(solr_result, {:load_from_solr => true})
52
- expect(result.length).to eq(2)
51
+ result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
52
+ result.length.should == 2
53
53
  result.each do |r|
54
- expect(r.inner_object).to be_a(ActiveFedora::SolrDigitalObject)
55
- expect([ActiveFedora::Base, FooObject]).to include(r.class)
56
- expect(['test_object', 'foo_object']).to include(r.label)
57
- expect(@test_object.inner_object.profile).to eq(@profiles['test'])
58
- expect(@foo_object.inner_object.profile).to eq(@profiles['foo'])
59
- expect(@foo_object.datastreams['descMetadata'].profile).to eq(@profiles['foo_descMetadata'])
60
- expect(@foo_object.datastreams['descMetadata'].content).to be_equivalent_to(@foo_content)
54
+ r.inner_object.should be_a(ActiveFedora::SolrDigitalObject)
55
+ [ActiveFedora::Base, FooObject].should include(r.class)
56
+ ['test_object','foo_object'].should include(r.label)
57
+ @test_object.inner_object.profile.should == @profiles['test']
58
+ @foo_object.inner_object.profile.should == @profiles['foo']
59
+ @foo_object.datastreams['descMetadata'].profile.should == @profiles['foo_descMetadata']
60
+ @foo_object.datastreams['descMetadata'].content.should be_equivalent_to(@foo_content)
61
61
  end
62
62
  end
63
-
63
+
64
64
  it 'should instantiate all datastreams in the solr doc, even ones undeclared by the class' do
65
- obj = ActiveFedora::Base.load_instance_from_solr @foo_object.pid
66
- expect(obj.datastreams.keys).to include('descMetadata')
65
+ obj = ActiveFedora::Base.load_instance_from_solr @foo_object.pid
66
+ obj.datastreams.keys.should include('descMetadata')
67
67
  end
68
-
68
+
69
69
  it 'should #reify a lightweight object as a new instance' do
70
70
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
71
71
  solr_result = ActiveFedora::SolrService.query(query)
72
- result = ActiveFedora::SolrService.reify_solr_results(solr_result, {:load_from_solr => true})
72
+ result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
73
73
  solr_foo = result.first
74
74
  real_foo = solr_foo.reify
75
- expect(solr_foo.inner_object).to be_a(ActiveFedora::SolrDigitalObject)
76
- expect(real_foo.inner_object).to be_a(ActiveFedora::DigitalObject)
77
- expect(solr_foo.label).to eq('foo_object')
78
- expect(real_foo.label).to eq('foo_object')
75
+ solr_foo.inner_object.should be_a(ActiveFedora::SolrDigitalObject)
76
+ real_foo.inner_object.should be_a(ActiveFedora::DigitalObject)
77
+ solr_foo.label.should == 'foo_object'
78
+ real_foo.label.should == 'foo_object'
79
79
  end
80
-
80
+
81
81
  it 'should #reify! a lightweight object within the same instance' do
82
82
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
83
83
  solr_result = ActiveFedora::SolrService.query(query)
84
- result = ActiveFedora::SolrService.reify_solr_results(solr_result, {:load_from_solr => true})
84
+ result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
85
85
  solr_foo = result.first
86
- expect(solr_foo.inner_object).to be_a(ActiveFedora::SolrDigitalObject)
86
+ solr_foo.inner_object.should be_a(ActiveFedora::SolrDigitalObject)
87
87
  solr_foo.reify!
88
- expect(solr_foo.inner_object).to be_a(ActiveFedora::DigitalObject)
89
- expect(solr_foo.label).to eq('foo_object')
88
+ solr_foo.inner_object.should be_a(ActiveFedora::DigitalObject)
89
+ solr_foo.label.should == 'foo_object'
90
90
  end
91
-
91
+
92
92
  it 'should raise an exception when attempting to reify a first-class object' do
93
93
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
94
94
  solr_result = ActiveFedora::SolrService.query(query)
95
- result = ActiveFedora::SolrService.reify_solr_results(solr_result, {:load_from_solr => true})
95
+ result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
96
96
  solr_foo = result.first
97
- expect {solr_foo.reify}.not_to raise_exception
98
- expect {solr_foo.reify!}.not_to raise_exception
99
- expect {solr_foo.reify!}.to raise_exception(/already a full/)
100
- expect {solr_foo.reify}.to raise_exception(/already a full/)
97
+ lambda {solr_foo.reify}.should_not raise_exception
98
+ lambda {solr_foo.reify!}.should_not raise_exception
99
+ lambda {solr_foo.reify!}.should raise_exception(/already a full/)
100
+ lambda {solr_foo.reify}.should raise_exception(/already a full/)
101
101
  end
102
-
102
+
103
103
  it 'should call load_instance_from_solr if :load_from_solr option passed in' do
104
104
  query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@test_object.pid)} OR id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
105
105
  solr_result = ActiveFedora::SolrService.query(query)
106
- expect(ActiveFedora::Base).to receive(:load_instance_from_solr).once
107
- expect(FooObject).to receive(:load_instance_from_solr).once
108
- result = ActiveFedora::SolrService.reify_solr_results(solr_result, {:load_from_solr => true})
106
+ ActiveFedora::Base.should_receive(:load_instance_from_solr).once
107
+ FooObject.should_receive(:load_instance_from_solr).once
108
+ result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
109
109
  end
110
-
110
+
111
111
  end
112
112
  end
@@ -1,6 +1,6 @@
1
- require 'active-fedora'
1
+ require "active-fedora"
2
2
  module Hydra
3
-
3
+
4
4
  # This is an example of a OmDatastream that defines an OM terminology for MODS xml
5
5
  # It focuses on the aspects of MODS that deal with descriptive metadata for published articles
6
6
  # This is not the hydra-head plugin version of this OM Terminology; See https://github.com/projecthydra/hydra-head/blob/master/lib/hydra/mods_article.rb
@@ -11,135 +11,135 @@ module Hydra
11
11
  # * Defines a term lang_code that maps to "languageTerm[@type=code]"
12
12
  # * Defines a variety of terms, date, last_name, first_name & terms_of_address, that all map to mods:namePart but use varying attributes to distinguish themselves
13
13
  # * Uses proxy terms to define familar terms like start_page and end_page that map to non-intuitive xml structures "extent[@unit=pages]/start" and "extent[@unit=pages]/end"
14
- # * Uses proxy terms, publication_url, peer_reviewed, and title, to allow convenient access to frequently used terms
14
+ # * Uses proxy terms, publication_url, peer_reviewed, and title, to allow convenient access to frequently used terms
15
15
  #
16
16
  # Things to note about the additional methods it defines:
17
- #
17
+ #
18
18
  # * Defines a series of templates, person_template, organization_template, etc. for generating a whole set of xml nodes to insert into the document (note: the new OM::TemplateRegistry provides an even better way to do this)
19
19
  # * Defines a custom method, insert_contributor, that uses the Terminology to manipulate xml documents in specialized ways
20
20
  # * Defines a series of relator_term Hashes that can then be used when generating views, etc. In this case, the Hashes are hard-coded into the Class. Ideally, they might be read from a configuration file or mixed into the class using a module
21
- class ModsArticleDatastream < ActiveFedora::OmDatastream
21
+ class ModsArticleDatastream < ActiveFedora::OmDatastream
22
22
 
23
23
  set_terminology do |t|
24
- t.root(:path => 'mods', :xmlns => 'http://www.loc.gov/mods/v3', :schema => 'http://www.loc.gov/standards/mods/v3/mods-3-2.xsd')
24
+ t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
25
25
 
26
26
 
27
- t.title_info(:path => 'titleInfo') {
28
- t.main_title(:index_as => [:facetable], :path => 'title', :label => 'title')
29
- t.language(:index_as => [:facetable], :path => {:attribute => 'lang'})
30
- }
27
+ t.title_info(:path=>"titleInfo") {
28
+ t.main_title(:index_as=>[:facetable],:path=>"title", :label=>"title")
29
+ t.language(:index_as=>[:facetable],:path=>{:attribute=>"lang"})
30
+ }
31
31
  t.language{
32
- t.lang_code(:index_as => [:facetable], :path => 'languageTerm', :attributes => {:type => 'code'})
32
+ t.lang_code(:index_as=>[:facetable], :path=>"languageTerm", :attributes=>{:type=>"code"})
33
33
  }
34
- t.abstract
34
+ t.abstract
35
35
  t.subject {
36
- t.topic(:index_as => [:facetable])
37
- }
38
- t.topic_tag(:proxy => [:subject, :topic])
36
+ t.topic(:index_as=>[:facetable])
37
+ }
38
+ t.topic_tag(:proxy=>[:subject, :topic])
39
39
  # t.topic_tag(:index_as=>[:facetable],:path=>"subject", :default_content_path=>"topic")
40
40
  # This is a mods:name. The underscore is purely to avoid namespace conflicts.
41
- t.name_(:index_as => [:searchable]) {
41
+ t.name_(:index_as=>[:searchable]) {
42
42
  # this is a namepart
43
- t.namePart(:type => :string, :label => 'generic name')
43
+ t.namePart(:type=>:string, :label=>"generic name")
44
44
  # affiliations are great
45
45
  t.affiliation
46
- t.institution(:path => 'affiliation', :index_as => [:facetable], :label => 'organization')
46
+ t.institution(:path=>"affiliation", :index_as=>[:facetable], :label=>"organization")
47
47
  t.displayForm
48
- t.role(:ref => [:role])
49
- t.description(:index_as => [:facetable])
50
- t.date(:path => 'namePart', :attributes => {:type => 'date'})
51
- t.last_name(:path => 'namePart', :attributes => {:type => 'family'})
52
- t.first_name(:path => 'namePart', :attributes => {:type => 'given'}, :label => 'first name')
53
- t.terms_of_address(:path => 'namePart', :attributes => {:type => 'termsOfAddress'})
48
+ t.role(:ref=>[:role])
49
+ t.description(:index_as=>[:facetable])
50
+ t.date(:path=>"namePart", :attributes=>{:type=>"date"})
51
+ t.last_name(:path=>"namePart", :attributes=>{:type=>"family"})
52
+ t.first_name(:path=>"namePart", :attributes=>{:type=>"given"}, :label=>"first name")
53
+ t.terms_of_address(:path=>"namePart", :attributes=>{:type=>"termsOfAddress"})
54
54
  t.computing_id
55
55
  }
56
- # lookup :person, :first_name
57
- t.person(:ref => :name, :attributes => {:type => 'personal'}, :index_as => [:facetable, :stored_searchable])
58
- t.department(:proxy => [:person, :description], :index_as => [:facetable])
59
- t.organization(:ref => :name, :attributes => {:type => 'corporate'}, :index_as => [:facetable])
60
- t.conference(:ref => :name, :attributes => {:type => 'conference'}, :index_as => [:facetable])
61
- t.role(:index_as => [:stored_searchable]) {
62
- t.text(:path => 'roleTerm', :attributes => {:type => 'text'}, :index_as => [:stored_searchable])
63
- t.code(:path => 'roleTerm', :attributes => {:type => 'code'})
56
+ # lookup :person, :first_name
57
+ t.person(:ref=>:name, :attributes=>{:type=>"personal"}, :index_as=>[:facetable, :stored_searchable])
58
+ t.department(:proxy=>[:person,:description],:index_as=>[:facetable])
59
+ t.organization(:ref=>:name, :attributes=>{:type=>"corporate"}, :index_as=>[:facetable])
60
+ t.conference(:ref=>:name, :attributes=>{:type=>"conference"}, :index_as=>[:facetable])
61
+ t.role(:index_as=>[:stored_searchable]) {
62
+ t.text(:path=>"roleTerm",:attributes=>{:type=>"text"}, :index_as=>[:stored_searchable])
63
+ t.code(:path=>"roleTerm",:attributes=>{:type=>"code"})
64
64
  }
65
- t.journal(:path => 'relatedItem', :attributes => {:type => 'host'}) {
66
- t.title_info(:index_as => [:facetable], :ref => [:title_info])
67
- t.origin_info(:path => 'originInfo') {
65
+ t.journal(:path=>'relatedItem', :attributes=>{:type=>"host"}) {
66
+ t.title_info(:index_as=>[:facetable],:ref=>[:title_info])
67
+ t.origin_info(:path=>"originInfo") {
68
68
  t.publisher
69
- t.date_issued(:path => 'dateIssued')
70
- t.issuance(:index_as => [:facetable])
69
+ t.date_issued(:path=>"dateIssued")
70
+ t.issuance(:index_as=>[:facetable])
71
71
  }
72
- t.issn(:path => 'identifier', :attributes => {:type => 'issn'})
73
- t.issue(:path => 'part') {
74
- t.volume(:path => 'detail', :attributes => {:type => 'volume'}, :default_content_path => 'number')
75
- t.level(:path => 'detail', :attributes => {:type => 'number'}, :default_content_path => 'number')
72
+ t.issn(:path=>"identifier", :attributes=>{:type=>"issn"})
73
+ t.issue(:path=>"part") {
74
+ t.volume(:path=>"detail", :attributes=>{:type=>"volume"}, :default_content_path=>"number")
75
+ t.level(:path=>"detail", :attributes=>{:type=>"number"}, :default_content_path=>"number")
76
76
  t.extent
77
- t.pages(:path => 'extent', :attributes => {:unit => 'pages'}) {
77
+ t.pages(:path=>"extent", :attributes=>{:unit=>"pages"}) {
78
78
  t.start
79
79
  t.end
80
80
  }
81
- t.start_page(:proxy => [:pages, :start])
82
- t.end_page(:proxy => [:pages, :end])
83
- t.publication_date(:path => 'date', :type => :date, :index_as => [:stored_searchable])
81
+ t.start_page(:proxy=>[:pages, :start])
82
+ t.end_page(:proxy=>[:pages, :end])
83
+ t.publication_date(:path=>"date", :type=>:date, :index_as=>[:stored_searchable])
84
84
  }
85
85
  }
86
86
  t.note
87
- t.location(:path => 'location') {
88
- t.url(:path => 'url')
87
+ t.location(:path=>"location") {
88
+ t.url(:path=>"url")
89
89
  }
90
- t.publication_url(:proxy => [:location, :url])
91
- t.peer_reviewed(:proxy => [:journal, :origin_info, :issuance], :index_as => [:facetable])
92
- t.title(:proxy => [:title_info, :main_title])
93
- t.journal_title(:proxy => [:journal, :title_info, :main_title])
90
+ t.publication_url(:proxy=>[:location,:url])
91
+ t.peer_reviewed(:proxy=>[:journal,:origin_info,:issuance], :index_as=>[:facetable])
92
+ t.title(:proxy=>[:title_info, :main_title])
93
+ t.journal_title(:proxy=>[:journal, :title_info, :main_title])
94
94
  end
95
-
95
+
96
96
  # Generates an empty Mods Article (used when you call ModsArticle.new without passing in existing xml)
97
97
  def self.xml_template
98
98
  builder = Nokogiri::XML::Builder.new do |xml|
99
- xml.mods(:version => '3.3', 'xmlns:xlink' => 'http://www.w3.org/1999/xlink',
100
- 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
101
- 'xmlns' => 'http://www.loc.gov/mods/v3',
102
- 'xsi:schemaLocation' => 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd') {
103
- xml.titleInfo(:lang => '') {
99
+ xml.mods(:version=>"3.3", "xmlns:xlink"=>"http://www.w3.org/1999/xlink",
100
+ "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
101
+ "xmlns"=>"http://www.loc.gov/mods/v3",
102
+ "xsi:schemaLocation"=>"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd") {
103
+ xml.titleInfo(:lang=>"") {
104
104
  xml.title
105
105
  }
106
- xml.name(:type => 'personal') {
107
- xml.namePart(:type => 'given')
108
- xml.namePart(:type => 'family')
106
+ xml.name(:type=>"personal") {
107
+ xml.namePart(:type=>"given")
108
+ xml.namePart(:type=>"family")
109
109
  xml.affiliation
110
110
  xml.computing_id
111
111
  xml.description
112
112
  xml.role {
113
- xml.roleTerm('Author', :authority => 'marcrelator', :type => 'text')
113
+ xml.roleTerm("Author", :authority=>"marcrelator", :type=>"text")
114
114
  }
115
115
  }
116
116
  xml.typeOfResource
117
- xml.genre(:authority => 'marcgt')
117
+ xml.genre(:authority=>"marcgt")
118
118
  xml.language {
119
- xml.languageTerm(:authority => 'iso639-2b', :type => 'code')
119
+ xml.languageTerm(:authority=>"iso639-2b", :type=>"code")
120
120
  }
121
121
  xml.abstract
122
122
  xml.subject {
123
123
  xml.topic
124
124
  }
125
- xml.relatedItem(:type => 'host') {
125
+ xml.relatedItem(:type=>"host") {
126
126
  xml.titleInfo {
127
127
  xml.title
128
128
  }
129
- xml.identifier(:type => 'issn')
129
+ xml.identifier(:type=>"issn")
130
130
  xml.originInfo {
131
131
  xml.publisher
132
132
  xml.dateIssued
133
133
  xml.issuance
134
134
  }
135
135
  xml.part {
136
- xml.detail(:type => 'volume') {
136
+ xml.detail(:type=>"volume") {
137
137
  xml.number
138
138
  }
139
- xml.detail(:type => 'number') {
139
+ xml.detail(:type=>"number") {
140
140
  xml.number
141
141
  }
142
- xml.extent(:unit => 'pages') {
142
+ xml.extent(:unit=>"pages") {
143
143
  xml.start
144
144
  xml.end
145
145
  }
@@ -153,18 +153,18 @@ module Hydra
153
153
  end
154
154
  return builder.doc
155
155
  end
156
-
156
+
157
157
  # Generates a new Person node
158
158
  def self.person_template
159
159
  builder = Nokogiri::XML::Builder.new do |xml|
160
- xml.name(:type => 'personal') {
161
- xml.namePart(:type => 'family')
162
- xml.namePart(:type => 'given')
160
+ xml.name(:type=>"personal") {
161
+ xml.namePart(:type=>"family")
162
+ xml.namePart(:type=>"given")
163
163
  xml.affiliation
164
164
  xml.computing_id
165
165
  xml.description
166
166
  xml.role {
167
- xml.roleTerm('Author', :type => 'text')
167
+ xml.roleTerm("Author", :type=>"text")
168
168
  }
169
169
  }
170
170
  end
@@ -173,7 +173,7 @@ module Hydra
173
173
 
174
174
  def self.full_name_template
175
175
  builder = Nokogiri::XML::Builder.new do |xml|
176
- xml.full_name(:type => 'personal')
176
+ xml.full_name(:type => "personal")
177
177
  end
178
178
  return builder.doc.root
179
179
  end
@@ -182,33 +182,33 @@ module Hydra
182
182
  # Uses mods:name[@type="corporate"]
183
183
  def self.organization_template
184
184
  builder = Nokogiri::XML::Builder.new do |xml|
185
- xml.name(:type => 'corporate') {
185
+ xml.name(:type=>"corporate") {
186
186
  xml.namePart
187
187
  xml.role {
188
- xml.roleTerm(:authority => 'marcrelator', :type => 'text')
189
- }
188
+ xml.roleTerm(:authority=>"marcrelator", :type=>"text")
189
+ }
190
190
  }
191
191
  end
192
192
  return builder.doc.root
193
193
  end
194
-
194
+
195
195
  # Generates a new Conference node
196
196
  def self.conference_template
197
197
  builder = Nokogiri::XML::Builder.new do |xml|
198
- xml.name(:type => 'conference') {
198
+ xml.name(:type=>"conference") {
199
199
  xml.namePart
200
200
  xml.role {
201
- xml.roleTerm(:authority => 'marcrelator', :type => 'text')
202
- }
201
+ xml.roleTerm(:authority=>"marcrelator", :type=>"text")
202
+ }
203
203
  }
204
204
  end
205
205
  return builder.doc.root
206
206
  end
207
-
207
+
208
208
  # Inserts a new contributor (mods:name) into the mods document
209
209
  # creates contributors of type :person, :organization, or :conference
210
- def insert_contributor(type, opts = {})
211
- case type.to_sym
210
+ def insert_contributor(type, opts={})
211
+ case type.to_sym
212
212
  when :person
213
213
  node = Hydra::ModsArticleDatastream.person_template
214
214
  nodeset = self.find_by_terms(:person)
@@ -223,7 +223,7 @@ module Hydra
223
223
  node = nil
224
224
  index = nil
225
225
  end
226
-
226
+
227
227
  unless nodeset.nil?
228
228
  if nodeset.empty?
229
229
  self.ng_xml.root.add_child(node)
@@ -234,282 +234,282 @@ module Hydra
234
234
  end
235
235
  self.dirty = true
236
236
  end
237
-
237
+
238
238
  return node, index
239
239
  end
240
-
240
+
241
241
  # Remove the contributor entry identified by @contributor_type and @index
242
242
  def remove_contributor(contributor_type, index)
243
243
  self.find_by_terms( {contributor_type.to_sym => index.to_i} ).first.remove
244
244
  self.dirty = true
245
245
  end
246
-
246
+
247
247
  def self.common_relator_terms
248
- {'aut' => 'Author',
249
- 'clb' => 'Collaborator',
250
- 'com' => 'Compiler',
251
- 'ctb' => 'Contributor',
252
- 'cre' => 'Creator',
253
- 'edt' => 'Editor',
254
- 'ill' => 'Illustrator',
255
- 'oth' => 'Other',
256
- 'trl' => 'Translator'
248
+ {"aut" => "Author",
249
+ "clb" => "Collaborator",
250
+ "com" => "Compiler",
251
+ "ctb" => "Contributor",
252
+ "cre" => "Creator",
253
+ "edt" => "Editor",
254
+ "ill" => "Illustrator",
255
+ "oth" => "Other",
256
+ "trl" => "Translator",
257
257
  }
258
258
  end
259
-
259
+
260
260
  def self.person_relator_terms
261
- {'aut' => 'Author',
262
- 'clb' => 'Collaborator',
263
- 'com' => 'Compiler',
264
- 'cre' => 'Creator',
265
- 'ctb' => 'Contributor',
266
- 'edt' => 'Editor',
267
- 'ill' => 'Illustrator',
268
- 'res' => 'Researcher',
269
- 'rth' => 'Research team head',
270
- 'rtm' => 'Research team member',
271
- 'trl' => 'Translator'
261
+ {"aut" => "Author",
262
+ "clb" => "Collaborator",
263
+ "com" => "Compiler",
264
+ "cre" => "Creator",
265
+ "ctb" => "Contributor",
266
+ "edt" => "Editor",
267
+ "ill" => "Illustrator",
268
+ "res" => "Researcher",
269
+ "rth" => "Research team head",
270
+ "rtm" => "Research team member",
271
+ "trl" => "Translator"
272
272
  }
273
273
  end
274
-
274
+
275
275
  def self.conference_relator_terms
276
276
  {
277
- 'hst' => 'Host'
277
+ "hst" => "Host"
278
278
  }
279
279
  end
280
-
280
+
281
281
  def self.organization_relator_terms
282
282
  {
283
- 'fnd' => 'Funder',
284
- 'hst' => 'Host'
283
+ "fnd" => "Funder",
284
+ "hst" => "Host"
285
285
  }
286
286
  end
287
-
287
+
288
288
  def self.dc_relator_terms
289
- {'acp' => 'Art copyist',
290
- 'act' => 'Actor',
291
- 'adp' => 'Adapter',
292
- 'aft' => 'Author of afterword, colophon, etc.',
293
- 'anl' => 'Analyst',
294
- 'anm' => 'Animator',
295
- 'ann' => 'Annotator',
296
- 'ant' => 'Bibliographic antecedent',
297
- 'app' => 'Applicant',
298
- 'aqt' => 'Author in quotations or text abstracts',
299
- 'arc' => 'Architect',
300
- 'ard' => 'Artistic director ',
301
- 'arr' => 'Arranger',
302
- 'art' => 'Artist',
303
- 'asg' => 'Assignee',
304
- 'asn' => 'Associated name',
305
- 'att' => 'Attributed name',
306
- 'auc' => 'Auctioneer',
307
- 'aud' => 'Author of dialog',
308
- 'aui' => 'Author of introduction',
309
- 'aus' => 'Author of screenplay',
310
- 'aut' => 'Author',
311
- 'bdd' => 'Binding designer',
312
- 'bjd' => 'Bookjacket designer',
313
- 'bkd' => 'Book designer',
314
- 'bkp' => 'Book producer',
315
- 'bnd' => 'Binder',
316
- 'bpd' => 'Bookplate designer',
317
- 'bsl' => 'Bookseller',
318
- 'ccp' => 'Conceptor',
319
- 'chr' => 'Choreographer',
320
- 'clb' => 'Collaborator',
321
- 'cli' => 'Client',
322
- 'cll' => 'Calligrapher',
323
- 'clt' => 'Collotyper',
324
- 'cmm' => 'Commentator',
325
- 'cmp' => 'Composer',
326
- 'cmt' => 'Compositor',
327
- 'cng' => 'Cinematographer',
328
- 'cnd' => 'Conductor',
329
- 'cns' => 'Censor',
330
- 'coe' => 'Contestant -appellee',
331
- 'col' => 'Collector',
332
- 'com' => 'Compiler',
333
- 'cos' => 'Contestant',
334
- 'cot' => 'Contestant -appellant',
335
- 'cov' => 'Cover designer',
336
- 'cpc' => 'Copyright claimant',
337
- 'cpe' => 'Complainant-appellee',
338
- 'cph' => 'Copyright holder',
339
- 'cpl' => 'Complainant',
340
- 'cpt' => 'Complainant-appellant',
341
- 'cre' => 'Creator',
342
- 'crp' => 'Correspondent',
343
- 'crr' => 'Corrector',
344
- 'csl' => 'Consultant',
345
- 'csp' => 'Consultant to a project',
346
- 'cst' => 'Costume designer',
347
- 'ctb' => 'Contributor',
348
- 'cte' => 'Contestee-appellee',
349
- 'ctg' => 'Cartographer',
350
- 'ctr' => 'Contractor',
351
- 'cts' => 'Contestee',
352
- 'ctt' => 'Contestee-appellant',
353
- 'cur' => 'Curator',
354
- 'cwt' => 'Commentator for written text',
355
- 'dfd' => 'Defendant',
356
- 'dfe' => 'Defendant-appellee',
357
- 'dft' => 'Defendant-appellant',
358
- 'dgg' => 'Degree grantor',
359
- 'dis' => 'Dissertant',
360
- 'dln' => 'Delineator',
361
- 'dnc' => 'Dancer',
362
- 'dnr' => 'Donor',
363
- 'dpc' => 'Depicted',
364
- 'dpt' => 'Depositor',
365
- 'drm' => 'Draftsman',
366
- 'drt' => 'Director',
367
- 'dsr' => 'Designer',
368
- 'dst' => 'Distributor',
369
- 'dtc' => 'Data contributor ',
370
- 'dte' => 'Dedicatee',
371
- 'dtm' => 'Data manager ',
372
- 'dto' => 'Dedicator',
373
- 'dub' => 'Dubious author',
374
- 'edt' => 'Editor',
375
- 'egr' => 'Engraver',
376
- 'elg' => 'Electrician ',
377
- 'elt' => 'Electrotyper',
378
- 'eng' => 'Engineer',
379
- 'etr' => 'Etcher',
380
- 'exp' => 'Expert',
381
- 'fac' => 'Facsimilist',
382
- 'fld' => 'Field director ',
383
- 'flm' => 'Film editor',
384
- 'fmo' => 'Former owner',
385
- 'fpy' => 'First party',
386
- 'fnd' => 'Funder',
387
- 'frg' => 'Forger',
388
- 'gis' => 'Geographic information specialist ',
389
- 'grt' => 'Graphic technician',
390
- 'hnr' => 'Honoree',
391
- 'hst' => 'Host',
392
- 'ill' => 'Illustrator',
393
- 'ilu' => 'Illuminator',
394
- 'ins' => 'Inscriber',
395
- 'inv' => 'Inventor',
396
- 'itr' => 'Instrumentalist',
397
- 'ive' => 'Interviewee',
398
- 'ivr' => 'Interviewer',
399
- 'lbr' => 'Laboratory ',
400
- 'lbt' => 'Librettist',
401
- 'ldr' => 'Laboratory director ',
402
- 'led' => 'Lead',
403
- 'lee' => 'Libelee-appellee',
404
- 'lel' => 'Libelee',
405
- 'len' => 'Lender',
406
- 'let' => 'Libelee-appellant',
407
- 'lgd' => 'Lighting designer',
408
- 'lie' => 'Libelant-appellee',
409
- 'lil' => 'Libelant',
410
- 'lit' => 'Libelant-appellant',
411
- 'lsa' => 'Landscape architect',
412
- 'lse' => 'Licensee',
413
- 'lso' => 'Licensor',
414
- 'ltg' => 'Lithographer',
415
- 'lyr' => 'Lyricist',
416
- 'mcp' => 'Music copyist',
417
- 'mfr' => 'Manufacturer',
418
- 'mdc' => 'Metadata contact',
419
- 'mod' => 'Moderator',
420
- 'mon' => 'Monitor',
421
- 'mrk' => 'Markup editor',
422
- 'msd' => 'Musical director',
423
- 'mte' => 'Metal-engraver',
424
- 'mus' => 'Musician',
425
- 'nrt' => 'Narrator',
426
- 'opn' => 'Opponent',
427
- 'org' => 'Originator',
428
- 'orm' => 'Organizer of meeting',
429
- 'oth' => 'Other',
430
- 'own' => 'Owner',
431
- 'pat' => 'Patron',
432
- 'pbd' => 'Publishing director',
433
- 'pbl' => 'Publisher',
434
- 'pdr' => 'Project director',
435
- 'pfr' => 'Proofreader',
436
- 'pht' => 'Photographer',
437
- 'plt' => 'Platemaker',
438
- 'pma' => 'Permitting agency',
439
- 'pmn' => 'Production manager',
440
- 'pop' => 'Printer of plates',
441
- 'ppm' => 'Papermaker',
442
- 'ppt' => 'Puppeteer',
443
- 'prc' => 'Process contact',
444
- 'prd' => 'Production personnel',
445
- 'prf' => 'Performer',
446
- 'prg' => 'Programmer',
447
- 'prm' => 'Printmaker',
448
- 'pro' => 'Producer',
449
- 'prt' => 'Printer',
450
- 'pta' => 'Patent applicant',
451
- 'pte' => 'Plaintiff -appellee',
452
- 'ptf' => 'Plaintiff',
453
- 'pth' => 'Patent holder',
454
- 'ptt' => 'Plaintiff-appellant',
455
- 'rbr' => 'Rubricator',
456
- 'rce' => 'Recording engineer',
457
- 'rcp' => 'Recipient',
458
- 'red' => 'Redactor',
459
- 'ren' => 'Renderer',
460
- 'res' => 'Researcher',
461
- 'rev' => 'Reviewer',
462
- 'rps' => 'Repository',
463
- 'rpt' => 'Reporter',
464
- 'rpy' => 'Responsible party',
465
- 'rse' => 'Respondent-appellee',
466
- 'rsg' => 'Restager',
467
- 'rsp' => 'Respondent',
468
- 'rst' => 'Respondent-appellant',
469
- 'rth' => 'Research team head',
470
- 'rtm' => 'Research team member',
471
- 'sad' => 'Scientific advisor',
472
- 'sce' => 'Scenarist',
473
- 'scl' => 'Sculptor',
474
- 'scr' => 'Scribe',
475
- 'sds' => 'Sound designer',
476
- 'sec' => 'Secretary',
477
- 'sgn' => 'Signer',
478
- 'sht' => 'Supporting host',
479
- 'sng' => 'Singer',
480
- 'spk' => 'Speaker',
481
- 'spn' => 'Sponsor',
482
- 'spy' => 'Second party',
483
- 'srv' => 'Surveyor',
484
- 'std' => 'Set designer',
485
- 'stl' => 'Storyteller',
486
- 'stm' => 'Stage manager',
487
- 'stn' => 'Standards body',
488
- 'str' => 'Stereotyper',
489
- 'tcd' => 'Technical director',
490
- 'tch' => 'Teacher',
491
- 'ths' => 'Thesis advisor',
492
- 'trc' => 'Transcriber',
493
- 'trl' => 'Translator',
494
- 'tyd' => 'Type designer',
495
- 'tyg' => 'Typographer',
496
- 'vdg' => 'Videographer',
497
- 'voc' => 'Vocalist',
498
- 'wam' => 'Writer of accompanying material',
499
- 'wdc' => 'Woodcutter',
500
- 'wde' => 'Wood -engraver',
501
- 'wit' => 'Witness'}
289
+ {"acp" => "Art copyist",
290
+ "act" => "Actor",
291
+ "adp" => "Adapter",
292
+ "aft" => "Author of afterword, colophon, etc.",
293
+ "anl" => "Analyst",
294
+ "anm" => "Animator",
295
+ "ann" => "Annotator",
296
+ "ant" => "Bibliographic antecedent",
297
+ "app" => "Applicant",
298
+ "aqt" => "Author in quotations or text abstracts",
299
+ "arc" => "Architect",
300
+ "ard" => "Artistic director ",
301
+ "arr" => "Arranger",
302
+ "art" => "Artist",
303
+ "asg" => "Assignee",
304
+ "asn" => "Associated name",
305
+ "att" => "Attributed name",
306
+ "auc" => "Auctioneer",
307
+ "aud" => "Author of dialog",
308
+ "aui" => "Author of introduction",
309
+ "aus" => "Author of screenplay",
310
+ "aut" => "Author",
311
+ "bdd" => "Binding designer",
312
+ "bjd" => "Bookjacket designer",
313
+ "bkd" => "Book designer",
314
+ "bkp" => "Book producer",
315
+ "bnd" => "Binder",
316
+ "bpd" => "Bookplate designer",
317
+ "bsl" => "Bookseller",
318
+ "ccp" => "Conceptor",
319
+ "chr" => "Choreographer",
320
+ "clb" => "Collaborator",
321
+ "cli" => "Client",
322
+ "cll" => "Calligrapher",
323
+ "clt" => "Collotyper",
324
+ "cmm" => "Commentator",
325
+ "cmp" => "Composer",
326
+ "cmt" => "Compositor",
327
+ "cng" => "Cinematographer",
328
+ "cnd" => "Conductor",
329
+ "cns" => "Censor",
330
+ "coe" => "Contestant -appellee",
331
+ "col" => "Collector",
332
+ "com" => "Compiler",
333
+ "cos" => "Contestant",
334
+ "cot" => "Contestant -appellant",
335
+ "cov" => "Cover designer",
336
+ "cpc" => "Copyright claimant",
337
+ "cpe" => "Complainant-appellee",
338
+ "cph" => "Copyright holder",
339
+ "cpl" => "Complainant",
340
+ "cpt" => "Complainant-appellant",
341
+ "cre" => "Creator",
342
+ "crp" => "Correspondent",
343
+ "crr" => "Corrector",
344
+ "csl" => "Consultant",
345
+ "csp" => "Consultant to a project",
346
+ "cst" => "Costume designer",
347
+ "ctb" => "Contributor",
348
+ "cte" => "Contestee-appellee",
349
+ "ctg" => "Cartographer",
350
+ "ctr" => "Contractor",
351
+ "cts" => "Contestee",
352
+ "ctt" => "Contestee-appellant",
353
+ "cur" => "Curator",
354
+ "cwt" => "Commentator for written text",
355
+ "dfd" => "Defendant",
356
+ "dfe" => "Defendant-appellee",
357
+ "dft" => "Defendant-appellant",
358
+ "dgg" => "Degree grantor",
359
+ "dis" => "Dissertant",
360
+ "dln" => "Delineator",
361
+ "dnc" => "Dancer",
362
+ "dnr" => "Donor",
363
+ "dpc" => "Depicted",
364
+ "dpt" => "Depositor",
365
+ "drm" => "Draftsman",
366
+ "drt" => "Director",
367
+ "dsr" => "Designer",
368
+ "dst" => "Distributor",
369
+ "dtc" => "Data contributor ",
370
+ "dte" => "Dedicatee",
371
+ "dtm" => "Data manager ",
372
+ "dto" => "Dedicator",
373
+ "dub" => "Dubious author",
374
+ "edt" => "Editor",
375
+ "egr" => "Engraver",
376
+ "elg" => "Electrician ",
377
+ "elt" => "Electrotyper",
378
+ "eng" => "Engineer",
379
+ "etr" => "Etcher",
380
+ "exp" => "Expert",
381
+ "fac" => "Facsimilist",
382
+ "fld" => "Field director ",
383
+ "flm" => "Film editor",
384
+ "fmo" => "Former owner",
385
+ "fpy" => "First party",
386
+ "fnd" => "Funder",
387
+ "frg" => "Forger",
388
+ "gis" => "Geographic information specialist ",
389
+ "grt" => "Graphic technician",
390
+ "hnr" => "Honoree",
391
+ "hst" => "Host",
392
+ "ill" => "Illustrator",
393
+ "ilu" => "Illuminator",
394
+ "ins" => "Inscriber",
395
+ "inv" => "Inventor",
396
+ "itr" => "Instrumentalist",
397
+ "ive" => "Interviewee",
398
+ "ivr" => "Interviewer",
399
+ "lbr" => "Laboratory ",
400
+ "lbt" => "Librettist",
401
+ "ldr" => "Laboratory director ",
402
+ "led" => "Lead",
403
+ "lee" => "Libelee-appellee",
404
+ "lel" => "Libelee",
405
+ "len" => "Lender",
406
+ "let" => "Libelee-appellant",
407
+ "lgd" => "Lighting designer",
408
+ "lie" => "Libelant-appellee",
409
+ "lil" => "Libelant",
410
+ "lit" => "Libelant-appellant",
411
+ "lsa" => "Landscape architect",
412
+ "lse" => "Licensee",
413
+ "lso" => "Licensor",
414
+ "ltg" => "Lithographer",
415
+ "lyr" => "Lyricist",
416
+ "mcp" => "Music copyist",
417
+ "mfr" => "Manufacturer",
418
+ "mdc" => "Metadata contact",
419
+ "mod" => "Moderator",
420
+ "mon" => "Monitor",
421
+ "mrk" => "Markup editor",
422
+ "msd" => "Musical director",
423
+ "mte" => "Metal-engraver",
424
+ "mus" => "Musician",
425
+ "nrt" => "Narrator",
426
+ "opn" => "Opponent",
427
+ "org" => "Originator",
428
+ "orm" => "Organizer of meeting",
429
+ "oth" => "Other",
430
+ "own" => "Owner",
431
+ "pat" => "Patron",
432
+ "pbd" => "Publishing director",
433
+ "pbl" => "Publisher",
434
+ "pdr" => "Project director",
435
+ "pfr" => "Proofreader",
436
+ "pht" => "Photographer",
437
+ "plt" => "Platemaker",
438
+ "pma" => "Permitting agency",
439
+ "pmn" => "Production manager",
440
+ "pop" => "Printer of plates",
441
+ "ppm" => "Papermaker",
442
+ "ppt" => "Puppeteer",
443
+ "prc" => "Process contact",
444
+ "prd" => "Production personnel",
445
+ "prf" => "Performer",
446
+ "prg" => "Programmer",
447
+ "prm" => "Printmaker",
448
+ "pro" => "Producer",
449
+ "prt" => "Printer",
450
+ "pta" => "Patent applicant",
451
+ "pte" => "Plaintiff -appellee",
452
+ "ptf" => "Plaintiff",
453
+ "pth" => "Patent holder",
454
+ "ptt" => "Plaintiff-appellant",
455
+ "rbr" => "Rubricator",
456
+ "rce" => "Recording engineer",
457
+ "rcp" => "Recipient",
458
+ "red" => "Redactor",
459
+ "ren" => "Renderer",
460
+ "res" => "Researcher",
461
+ "rev" => "Reviewer",
462
+ "rps" => "Repository",
463
+ "rpt" => "Reporter",
464
+ "rpy" => "Responsible party",
465
+ "rse" => "Respondent-appellee",
466
+ "rsg" => "Restager",
467
+ "rsp" => "Respondent",
468
+ "rst" => "Respondent-appellant",
469
+ "rth" => "Research team head",
470
+ "rtm" => "Research team member",
471
+ "sad" => "Scientific advisor",
472
+ "sce" => "Scenarist",
473
+ "scl" => "Sculptor",
474
+ "scr" => "Scribe",
475
+ "sds" => "Sound designer",
476
+ "sec" => "Secretary",
477
+ "sgn" => "Signer",
478
+ "sht" => "Supporting host",
479
+ "sng" => "Singer",
480
+ "spk" => "Speaker",
481
+ "spn" => "Sponsor",
482
+ "spy" => "Second party",
483
+ "srv" => "Surveyor",
484
+ "std" => "Set designer",
485
+ "stl" => "Storyteller",
486
+ "stm" => "Stage manager",
487
+ "stn" => "Standards body",
488
+ "str" => "Stereotyper",
489
+ "tcd" => "Technical director",
490
+ "tch" => "Teacher",
491
+ "ths" => "Thesis advisor",
492
+ "trc" => "Transcriber",
493
+ "trl" => "Translator",
494
+ "tyd" => "Type designer",
495
+ "tyg" => "Typographer",
496
+ "vdg" => "Videographer",
497
+ "voc" => "Vocalist",
498
+ "wam" => "Writer of accompanying material",
499
+ "wdc" => "Woodcutter",
500
+ "wde" => "Wood -engraver",
501
+ "wit" => "Witness"}
502
502
  end
503
-
503
+
504
504
  def self.valid_child_types
505
- ['data', 'supporting file', 'profile', 'lorem ipsum', 'dolor']
505
+ ["data", "supporting file", "profile", "lorem ipsum", "dolor"]
506
506
  end
507
507
 
508
- def to_solr(solr_doc = {})
508
+ def to_solr(solr_doc=Hash.new)
509
509
  super(solr_doc)
510
-
511
- ::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('object_type', :facetable), 'Article')
512
- ::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('mods_journal_title_info', :facetable), 'Unknown') if solr_doc['mods_journal_title_info_facet'].nil?
510
+
511
+ ::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('object_type', :facetable), "Article")
512
+ ::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('mods_journal_title_info', :facetable), "Unknown") if solr_doc["mods_journal_title_info_facet"].nil?
513
513
 
514
514
  solr_doc
515
515
  end