active-fedora 10.0.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +6 -7
  4. data/.rubocop_todo.yml +55 -0
  5. data/.solr_wrapper +6 -0
  6. data/README.md +1 -3
  7. data/active-fedora.gemspec +6 -11
  8. data/lib/active_fedora/aggregation/list_source.rb +2 -0
  9. data/lib/active_fedora/associations/association_scope.rb +1 -1
  10. data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
  11. data/lib/active_fedora/associations/builder/association.rb +1 -1
  12. data/lib/active_fedora/associations/builder/orders.rb +11 -3
  13. data/lib/active_fedora/associations/collection_association.rb +3 -3
  14. data/lib/active_fedora/associations/contained_finder.rb +2 -2
  15. data/lib/active_fedora/associations/has_many_association.rb +2 -2
  16. data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
  17. data/lib/active_fedora/associations/orders_association.rb +4 -0
  18. data/lib/active_fedora/associations/rdf.rb +2 -0
  19. data/lib/active_fedora/attribute_assignment.rb +0 -1
  20. data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
  21. data/lib/active_fedora/attributes.rb +1 -1
  22. data/lib/active_fedora/base.rb +4 -8
  23. data/lib/active_fedora/change_set.rb +6 -2
  24. data/lib/active_fedora/containers/container.rb +1 -1
  25. data/lib/active_fedora/core.rb +22 -25
  26. data/lib/active_fedora/fedora_attributes.rb +1 -1
  27. data/lib/active_fedora/file/streaming.rb +1 -1
  28. data/lib/active_fedora/file.rb +1 -9
  29. data/lib/active_fedora/indexing.rb +0 -15
  30. data/lib/active_fedora/indexing_service.rb +0 -9
  31. data/lib/active_fedora/loadable_from_json.rb +12 -1
  32. data/lib/active_fedora/nested_attributes.rb +2 -2
  33. data/lib/active_fedora/orders/list_node.rb +2 -2
  34. data/lib/active_fedora/orders/ordered_list.rb +7 -3
  35. data/lib/active_fedora/orders/target_proxy.rb +4 -0
  36. data/lib/active_fedora/querying.rb +1 -1
  37. data/lib/active_fedora/railtie.rb +2 -2
  38. data/lib/active_fedora/rake_support.rb +1 -1
  39. data/lib/active_fedora/rdf/persistence.rb +1 -0
  40. data/lib/active_fedora/rdf.rb +0 -2
  41. data/lib/active_fedora/relation/delegation.rb +4 -0
  42. data/lib/active_fedora/relation/finder_methods.rb +3 -3
  43. data/lib/active_fedora/scoping/named.rb +1 -0
  44. data/lib/active_fedora/solr_hit.rb +0 -13
  45. data/lib/active_fedora/solr_query_builder.rb +24 -13
  46. data/lib/active_fedora/version.rb +1 -1
  47. data/lib/active_fedora.rb +0 -12
  48. data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +11 -0
  49. data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
  50. data/lib/generators/active_fedora/model/model_generator.rb +1 -1
  51. data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
  52. data/lib/tasks/active_fedora_dev.rake +1 -9
  53. data/spec/config_helper.rb +1 -1
  54. data/spec/integration/associations_spec.rb +23 -24
  55. data/spec/integration/attached_files_spec.rb +18 -8
  56. data/spec/integration/attributes_spec.rb +12 -16
  57. data/spec/integration/autosave_association_spec.rb +6 -6
  58. data/spec/integration/base_spec.rb +3 -3
  59. data/spec/integration/basic_contains_association_spec.rb +1 -1
  60. data/spec/integration/clean_connection_spec.rb +1 -1
  61. data/spec/integration/collection_association_spec.rb +2 -5
  62. data/spec/integration/date_time_properties_spec.rb +1 -16
  63. data/spec/integration/direct_container_spec.rb +12 -12
  64. data/spec/integration/directly_contains_one_association_spec.rb +11 -13
  65. data/spec/integration/eradicate_spec.rb +1 -1
  66. data/spec/integration/fedora_solr_sync_spec.rb +2 -2
  67. data/spec/integration/file_fixity_spec.rb +6 -8
  68. data/spec/integration/file_spec.rb +32 -34
  69. data/spec/integration/generators/solr_generator_spec.rb +7 -10
  70. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +5 -5
  71. data/spec/integration/has_many_associations_spec.rb +9 -11
  72. data/spec/integration/indexing_spec.rb +2 -2
  73. data/spec/integration/indirect_container_spec.rb +11 -12
  74. data/spec/integration/json_serialization_spec.rb +4 -4
  75. data/spec/integration/query_result_builder_spec.rb +9 -21
  76. data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
  77. data/spec/integration/relation_delegation_spec.rb +8 -10
  78. data/spec/integration/relation_spec.rb +13 -16
  79. data/spec/integration/scoped_query_spec.rb +4 -3
  80. data/spec/integration/solr_hit_spec.rb +4 -15
  81. data/spec/integration/versionable_spec.rb +73 -327
  82. data/spec/integration/with_metadata_spec.rb +1 -1
  83. data/spec/spec_helper.rb +52 -4
  84. data/spec/unit/active_fedora_spec.rb +1 -1
  85. data/spec/unit/aggregation/list_source_spec.rb +37 -37
  86. data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
  87. data/spec/unit/association_hash_spec.rb +17 -31
  88. data/spec/unit/attached_files_spec.rb +35 -32
  89. data/spec/unit/attributes_spec.rb +25 -25
  90. data/spec/unit/base_active_model_spec.rb +8 -8
  91. data/spec/unit/base_cma_spec.rb +1 -1
  92. data/spec/unit/base_extra_spec.rb +7 -22
  93. data/spec/unit/base_spec.rb +16 -22
  94. data/spec/unit/callback_spec.rb +2 -2
  95. data/spec/unit/change_set_spec.rb +5 -5
  96. data/spec/unit/checksum_spec.rb +2 -2
  97. data/spec/unit/code_configurator_spec.rb +1 -1
  98. data/spec/unit/core_spec.rb +62 -26
  99. data/spec/unit/default_model_mapper_spec.rb +6 -6
  100. data/spec/unit/fedora_spec.rb +3 -4
  101. data/spec/unit/file_configurator_spec.rb +96 -96
  102. data/spec/unit/file_path_builder_spec.rb +1 -1
  103. data/spec/unit/file_spec.rb +61 -61
  104. data/spec/unit/files_hash_spec.rb +9 -9
  105. data/spec/unit/filter_spec.rb +3 -3
  106. data/spec/unit/finder_methods_spec.rb +5 -5
  107. data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
  108. data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
  109. data/spec/unit/has_many_association_spec.rb +28 -13
  110. data/spec/unit/indexers/global_indexer_spec.rb +6 -6
  111. data/spec/unit/indexing_service_spec.rb +5 -5
  112. data/spec/unit/indexing_spec.rb +6 -6
  113. data/spec/unit/inheritance_spec.rb +11 -7
  114. data/spec/unit/loadable_from_json_spec.rb +4 -4
  115. data/spec/unit/logger_spec.rb +1 -1
  116. data/spec/unit/model_classifier_spec.rb +5 -5
  117. data/spec/unit/ordered_spec.rb +144 -146
  118. data/spec/unit/orders/list_node_spec.rb +22 -22
  119. data/spec/unit/orders/ordered_list_spec.rb +96 -96
  120. data/spec/unit/orders/reflection_spec.rb +4 -4
  121. data/spec/unit/pathing_spec.rb +4 -4
  122. data/spec/unit/persistence_spec.rb +28 -28
  123. data/spec/unit/property_spec.rb +2 -2
  124. data/spec/unit/query_spec.rb +20 -20
  125. data/spec/unit/rdf/indexing_service_spec.rb +29 -29
  126. data/spec/unit/readonly_spec.rb +5 -4
  127. data/spec/unit/reflection_spec.rb +3 -3
  128. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
  129. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
  130. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
  131. data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
  132. data/spec/unit/serializers_spec.rb +3 -4
  133. data/spec/unit/solr_config_options_spec.rb +13 -16
  134. data/spec/unit/solr_hit_spec.rb +9 -9
  135. data/spec/unit/solr_service_spec.rb +4 -10
  136. data/spec/unit/sparql_insert_spec.rb +2 -2
  137. data/spec/unit/validations_spec.rb +9 -9
  138. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
  139. data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
  140. metadata +18 -122
  141. data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
  142. data/lib/active_fedora/datastreams.rb +0 -6
  143. data/lib/active_fedora/nom_datastream.rb +0 -67
  144. data/lib/active_fedora/om_datastream.rb +0 -126
  145. data/lib/active_fedora/profile_indexing_service.rb +0 -11
  146. data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
  147. data/lib/active_fedora/rdf/datastream_indexing.rb +0 -43
  148. data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -9
  149. data/lib/active_fedora/rdf/rdf_datastream.rb +0 -158
  150. data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
  151. data/lib/active_fedora/solr_instance_loader.rb +0 -47
  152. data/solr/config/_rest_managed.json +0 -3
  153. data/solr/config/admin-extra.html +0 -31
  154. data/solr/config/elevate.xml +0 -36
  155. data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
  156. data/solr/config/protwords.txt +0 -21
  157. data/solr/config/schema.xml +0 -372
  158. data/solr/config/scripts.conf +0 -24
  159. data/solr/config/solrconfig.xml +0 -311
  160. data/solr/config/spellings.txt +0 -2
  161. data/solr/config/stopwords.txt +0 -58
  162. data/solr/config/stopwords_en.txt +0 -58
  163. data/solr/config/synonyms.txt +0 -31
  164. data/solr/config/xslt/example.xsl +0 -132
  165. data/solr/config/xslt/example_atom.xsl +0 -67
  166. data/solr/config/xslt/example_rss.xsl +0 -66
  167. data/solr/config/xslt/luke.xsl +0 -337
  168. data/spec/fixtures/damsObjectModel.xml +0 -38
  169. data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
  170. data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
  171. data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
  172. data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
  173. data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
  174. data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
  175. data/spec/integration/ntriples_datastream_spec.rb +0 -203
  176. data/spec/integration/om_datastream_spec.rb +0 -78
  177. data/spec/integration/solr_instance_loader_spec.rb +0 -155
  178. data/spec/samples/hydra-mods_article_datastream.rb +0 -517
  179. data/spec/samples/models/mods_article.rb +0 -9
  180. data/spec/samples/oral_history_sample.xml +0 -38
  181. data/spec/samples/oral_history_xml.xml +0 -35
  182. data/spec/samples/samples.rb +0 -2
  183. data/spec/unit/nom_datastream_spec.rb +0 -60
  184. data/spec/unit/ntriples_datastream_spec.rb +0 -170
  185. data/spec/unit/om_datastream_spec.rb +0 -325
  186. data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
  187. data/spec/unit/rdf_datastream_spec.rb +0 -84
  188. data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
  189. data/spec/unit/rdfxml_datastream_spec.rb +0 -106
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1467d74478a1ea4aa80bcb17add4c7f34b798af7
4
- data.tar.gz: 5e15c3f279e391f4acf2fd0c87a5554e0df65c7d
3
+ metadata.gz: 1a3e4470dd33d72dc20a0794fd42e8a08d96363f
4
+ data.tar.gz: 9e7b438a6b8a23515de79c50b3f44dc2df2a6d3f
5
5
  SHA512:
6
- metadata.gz: c65e10a31bc1b766e4837eabfa198a3fe873b3ba93963d46edaaf0efb16c509f7091752336bf4608ea7e2fbccab5f899644777bb187585f1f197560b963b52b3
7
- data.tar.gz: 03dcfbf9f6c33829ac0235a5108985b29a62cbbe8b9782a24cee195f7962749010c4d75559f2f7e9ffade94f5acaeb58474465a021c43c25e2b370e1ba7d80cd
6
+ metadata.gz: f86db04efd279c3412c1e57fa8449f7fbef3ac6cb83143314b573edaf559dfca3bc0bab762ada09c87c0f86759aea537f812bd194c3361f8adbea78385abbfe3
7
+ data.tar.gz: fd864a26944cc8e5ca33b313a1a2544dcfa965e46005a16c6a4833755f85e82ab349e36470347c02eef601b979213c3877c2691153a41c81429595337dc68ead
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ bin
15
15
  gemfiles/*.gemfile.lock
16
16
  /fcrepo4-data
17
17
  /fcrepo4-test-data
18
+ /spec/examples.txt
data/.rubocop.yml CHANGED
@@ -1,3 +1,8 @@
1
+ require: rubocop-rspec
2
+
3
+ inherit_from:
4
+ - .rubocop_todo.yml
5
+
1
6
  AllCops:
2
7
  TargetRubyVersion: 2.2
3
8
  DisplayCopNames: true
@@ -42,7 +47,6 @@ Metrics/CyclomaticComplexity:
42
47
  - 'lib/active_fedora/associations/builder/directly_contains_one.rb'
43
48
  - 'lib/active_fedora/file_configurator.rb'
44
49
  - 'lib/active_fedora/file.rb'
45
- - 'lib/active_fedora/datastreams/nokogiri_datastreams.rb'
46
50
  - 'lib/active_fedora/attribute_methods.rb'
47
51
  - 'lib/active_fedora/scoping/named.rb'
48
52
  - 'lib/active_fedora/inheritance.rb'
@@ -53,7 +57,6 @@ Metrics/PerceivedComplexity:
53
57
  - 'lib/active_fedora/relation/finder_methods.rb'
54
58
  - 'lib/active_fedora/nested_attributes.rb'
55
59
  - 'lib/active_fedora/file_configurator.rb'
56
- - 'lib/active_fedora/datastreams/nokogiri_datastreams.rb'
57
60
  - 'lib/active_fedora/autosave_association.rb'
58
61
  - 'lib/active_fedora/associations/has_many_association.rb'
59
62
  - 'lib/active_fedora/associations/has_and_belongs_to_many_association.rb'
@@ -76,10 +79,7 @@ Metrics/ModuleLength:
76
79
 
77
80
  Metrics/ClassLength:
78
81
  Exclude:
79
- - 'spec/samples/hydra-mods_article_datastream.rb'
80
- - 'lib/active_fedora/rdf/rdf_datastream.rb'
81
82
  - 'lib/active_fedora/rdf/fcrepo.rb'
82
- - 'lib/active_fedora/qualified_dublin_core_datastream.rb'
83
83
  - 'lib/active_fedora/file_configurator.rb'
84
84
  - 'lib/active_fedora/file.rb'
85
85
  - 'lib/active_fedora/associations/association.rb'
@@ -89,6 +89,7 @@ Metrics/ClassLength:
89
89
  - 'lib/active_fedora/reflection.rb'
90
90
  - 'lib/active_fedora/orders/ordered_list.rb'
91
91
  - 'lib/active_fedora/solr_service.rb'
92
+ - 'lib/active_fedora/associations/orders_association.rb'
92
93
 
93
94
  Metrics/MethodLength:
94
95
  Enabled: false
@@ -117,7 +118,6 @@ Style/PredicateName:
117
118
  - 'lib/active_fedora/versionable.rb'
118
119
  - 'lib/active_fedora/reflection.rb'
119
120
  - 'lib/active_fedora/pathing.rb'
120
- - 'lib/active_fedora/om_datastream.rb'
121
121
  - 'lib/active_fedora/nested_attributes.rb'
122
122
  - 'lib/active_fedora/clean_connection.rb'
123
123
  - 'lib/active_fedora/attributes.rb'
@@ -215,7 +215,6 @@ Style/SignalException:
215
215
  Style/FileName:
216
216
  Exclude:
217
217
  - 'lib/active-fedora.rb'
218
- - 'spec/samples/hydra-mods_article_datastream.rb'
219
218
 
220
219
  Style/ZeroLengthPredicate:
221
220
  Exclude:
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,55 @@
1
+ require: rubocop-rspec
2
+
3
+ # This configuration was generated by
4
+ # `rubocop --auto-gen-config`
5
+ # on 2016-08-25 16:34:38 -0700 using RuboCop version 0.42.0.
6
+ # The point is for the user to remove these configuration records
7
+ # one by one as the offenses are removed from the code base.
8
+ # Note that changes in the inspected code, or installation of new
9
+ # versions of RuboCop, may require this file to be generated again.
10
+
11
+ # Offense count: 116
12
+ # Configuration parameters: Max.
13
+ RSpec/ExampleLength:
14
+ Enabled: false
15
+
16
+ # Offense count: 40
17
+ RSpec/LeadingSubject:
18
+ Enabled: false
19
+
20
+ # Offense count: 15
21
+ RSpec/LetSetup:
22
+ Exclude:
23
+ - 'spec/integration/collection_association_spec.rb'
24
+ - 'spec/integration/delete_all_spec.rb'
25
+ - 'spec/integration/has_many_associations_spec.rb'
26
+ - 'spec/integration/nested_attribute_spec.rb'
27
+ - 'spec/integration/persistence_spec.rb'
28
+ - 'spec/unit/has_and_belongs_to_many_association_spec.rb'
29
+
30
+ # Offense count: 1
31
+ RSpec/MessageChain:
32
+ Exclude:
33
+ - 'spec/unit/file_spec.rb'
34
+
35
+ # Offense count: 218
36
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
37
+ # SupportedStyles: allow, expect
38
+ RSpec/MessageExpectation:
39
+ Enabled: false
40
+
41
+ # Offense count: 238
42
+ RSpec/MultipleExpectations:
43
+ Max: 8
44
+
45
+ # Offense count: 394
46
+ # Configuration parameters: MaxNesting.
47
+ RSpec/NestedGroups:
48
+ Enabled: false
49
+
50
+ # Offense count: 94
51
+ RSpec/SubjectStub:
52
+ Enabled: false
53
+
54
+ RSpec/VerifiedDoubles:
55
+ Enabled: false
data/.solr_wrapper ADDED
@@ -0,0 +1,6 @@
1
+ # Place any default configuration for solr_wrapper here
2
+ # version: 6.1.0
3
+ port: 8985
4
+ collection:
5
+ dir: lib/generators/active_fedora/config/solr/templates/solr/config/
6
+ name: hydra-test
data/README.md CHANGED
@@ -75,11 +75,9 @@ rake active_fedora:ci
75
75
  If you want to run the tests manually, follow these instructions:
76
76
 
77
77
  ```bash
78
- solr_wrapper -d solr/config/ --collection_name hydra-test
78
+ solr_wrapper
79
79
  ```
80
80
 
81
- You can switch `hydra-test` to `hydra-dev` if you want to create a collection for development.
82
-
83
81
  To start FCRepo, open another shell and run:
84
82
 
85
83
  ```bash
@@ -14,32 +14,27 @@ Gem::Specification.new do |s|
14
14
  s.license = "APACHE2"
15
15
  s.required_ruby_version = '~> 2.0'
16
16
 
17
- s.add_dependency 'rsolr', '~> 1.0', '>= 1.0.10'
17
+ s.add_dependency 'rsolr', '~> 1.1', '>= 1.1.2'
18
18
  s.add_dependency 'solrizer', '~> 3.4'
19
- s.add_dependency 'om', '~> 3.1'
20
- s.add_dependency 'nom-xml', '>= 0.5.1'
21
19
  s.add_dependency "activesupport", '>= 4.2.4', '< 6'
22
20
  s.add_dependency "activemodel", '>= 4.2', '< 6'
23
- s.add_dependency "active-triples", '~> 0.7.1'
24
- s.add_dependency "rdf-rdfxml", '~> 1.1'
25
- s.add_dependency "linkeddata"
21
+ s.add_dependency "active-triples", '~> 0.11.0'
26
22
  s.add_dependency "deprecation"
27
- s.add_dependency "ldp", '~> 0.5.0'
23
+ s.add_dependency "ldp", '~> 0.6.0'
28
24
 
29
25
  s.add_development_dependency "rails"
30
26
  s.add_development_dependency "rdoc"
31
27
  s.add_development_dependency "yard"
32
28
  # Pin rake to 10.0 due to https://github.com/lsegal/yard/issues/947
33
29
  s.add_development_dependency "rake", '~> 10.0'
34
- s.add_development_dependency "solr_wrapper", "~> 0.4"
30
+ s.add_development_dependency "solr_wrapper", "~> 0.15"
35
31
  s.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
36
32
  s.add_development_dependency "rspec", "~> 3.0"
37
33
  s.add_development_dependency "rspec-its"
38
34
  s.add_development_dependency "equivalent-xml"
39
35
  s.add_development_dependency "simplecov", '~> 0.8'
40
- # Pin to rubocop 0.38.0 due to https://github.com/nevir/rubocop-rspec/issues/78
41
- s.add_development_dependency "rubocop", '~> 0.38.0'
42
- s.add_development_dependency "rubocop-rspec", '~> 1.4'
36
+ s.add_development_dependency "rubocop", '~> 0.42.0'
37
+ s.add_development_dependency "rubocop-rspec", '~> 1.6'
43
38
 
44
39
  s.files = `git ls-files`.split("\n")
45
40
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
@@ -73,6 +73,8 @@ module ActiveFedora
73
73
  # Assert head and tail
74
74
  self.head = ordered_self.head.next.rdf_subject
75
75
  self.tail = ordered_self.tail.prev.rdf_subject
76
+ head_will_change!
77
+ tail_will_change!
76
78
  graph = ordered_self.to_graph
77
79
  resource << graph
78
80
  # Set node subjects to a term in AF JUST so that AF will persist the
@@ -31,7 +31,7 @@ module ActiveFedora
31
31
  scope = scope.where(ActiveFedora::SolrQueryBuilder.construct_query_for_rel(association.send(:find_reflection) => owner.id))
32
32
  end
33
33
 
34
- is_first_chain = i == 0
34
+ is_first_chain = i.zero?
35
35
  is_first_chain ? klass : reflection.klass
36
36
  end
37
37
 
@@ -19,7 +19,7 @@ module ActiveFedora::Associations::Builder
19
19
  private_class_method :indirect_options
20
20
 
21
21
  def self.has_member_relation(options)
22
- options[:has_member_relation] || ::RDF::DC.hasPart
22
+ options[:has_member_relation] || ::RDF::Vocab::DC.hasPart
23
23
  end
24
24
  private_class_method :has_member_relation
25
25
 
@@ -36,7 +36,7 @@ module ActiveFedora::Associations::Builder
36
36
  def self.build_scope(scope, extension)
37
37
  new_scope = scope
38
38
 
39
- new_scope = proc { instance_exec(&scope) } if scope && scope.arity == 0
39
+ new_scope = proc { instance_exec(&scope) } if scope && scope.arity.zero?
40
40
 
41
41
  new_scope = wrap_scope new_scope, extension if extension
42
42
 
@@ -14,6 +14,9 @@ module ActiveFedora::Associations::Builder
14
14
  mixin.redefine_method(target_accessor(name)) do
15
15
  association(name).target_reader
16
16
  end
17
+ mixin.redefine_method("#{target_accessor(name, pluralize: false)}_ids") do
18
+ association(name).target_ids_reader
19
+ end
17
20
  mixin.redefine_method("#{target_accessor(name)}=") do |nodes|
18
21
  association(name).target_writer(nodes)
19
22
  end
@@ -27,7 +30,7 @@ module ActiveFedora::Associations::Builder
27
30
  model.send(:define_method, :apply_first_and_last) do
28
31
  source = send(options[:through])
29
32
  source.save
30
- return if head.map(&:rdf_subject) == source.head_id && tail.map(&:rdf_subject) == source.tail_id
33
+ return if head_ids == source.head_id && tail_ids == source.tail_id
31
34
  self.head = source.head_id
32
35
  self.tail = source.tail_id
33
36
  save! if changed?
@@ -50,8 +53,13 @@ module ActiveFedora::Associations::Builder
50
53
  end
51
54
  end
52
55
 
53
- def self.target_accessor(name)
54
- name.to_s.gsub("_proxies", "").pluralize
56
+ def self.target_accessor(name, pluralize: true)
57
+ name = name.to_s.gsub("_proxies", "")
58
+ if pluralize
59
+ name.pluralize
60
+ else
61
+ name
62
+ end
55
63
  end
56
64
  private_class_method :target_accessor
57
65
 
@@ -94,7 +94,7 @@ module ActiveFedora
94
94
  if loaded?
95
95
  size.zero?
96
96
  else
97
- @target.blank? && count_records == 0
97
+ @target.blank? && count_records.zero?
98
98
  end
99
99
  end
100
100
 
@@ -250,7 +250,7 @@ module ActiveFedora
250
250
  finder_query = construct_query
251
251
  return [] if finder_query.empty?
252
252
  rows = opts.delete(:rows) { count }
253
- return [] if rows == 0
253
+ return [] if rows.zero?
254
254
  SolrService.query(finder_query, { rows: rows }.merge(opts))
255
255
  end
256
256
 
@@ -291,7 +291,7 @@ module ActiveFedora
291
291
  def construct_query
292
292
  @solr_query ||= begin
293
293
  clauses = { find_reflection => @owner.id }
294
- clauses[:has_model] = @reflection.class_name.constantize.to_class_uri if @reflection.class_name && @reflection.class_name != 'ActiveFedora::Base'
294
+ clauses[:has_model] = @reflection.klass.to_rdf_representation if @reflection.klass != ActiveFedora::Base
295
295
  ActiveFedora::SolrQueryBuilder.construct_query_for_rel(clauses)
296
296
  end
297
297
  end
@@ -29,7 +29,7 @@ module ActiveFedora::Associations
29
29
  private
30
30
 
31
31
  def matching_ids(record)
32
- IDComposite.new(proxy_ids(record) & contained_ids, repository.translate_uri_to_id)
32
+ IDComposite.new(proxy_ids(record) & contained_ids.to_a, repository.translate_uri_to_id)
33
33
  end
34
34
 
35
35
  def proxy_ids(record)
@@ -40,7 +40,7 @@ module ActiveFedora::Associations
40
40
  # a slow fedora call
41
41
  def relation_subjects(record)
42
42
  query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(
43
- [[:has_model, proxy_class.to_class_uri], [:proxyFor, record.id]]
43
+ [[:has_model, proxy_class.to_rdf_representation], [:proxyFor, record.id]]
44
44
  )
45
45
  ActiveFedora::SolrService.query(query, fl: 'id').map(&:rdf_uri)
46
46
  end
@@ -19,7 +19,7 @@ module ActiveFedora
19
19
  # If there's nothing in the database and @target has no new records
20
20
  # we are certain the current target is an empty array. This is a
21
21
  # documented side-effect of the method that may avoid an extra SELECT.
22
- @target ||= [] and loaded! if count == 0
22
+ @target ||= [] and loaded! if count.zero?
23
23
 
24
24
  count
25
25
  end
@@ -83,7 +83,7 @@ module ActiveFedora
83
83
  protected
84
84
 
85
85
  def find_polymorphic_inverse(record)
86
- record.reflections.values.find { |r| !r.has_many? && r.options[:property] == reflection.options[:property] }
86
+ record.reflections.values.find { |r| !r.has_many? && r.predicate == reflection.predicate }
87
87
  end
88
88
 
89
89
  # Deletes the records according to the <tt>:dependent</tt> option.
@@ -25,12 +25,12 @@ module ActiveFedora
25
25
 
26
26
  def find_or_initialize_target(&block)
27
27
  if reflection.klass < ActiveFedora::File
28
- reflection.build_association(target_uri, &block)
28
+ reflection.build_association(id: target_uri, &block)
29
29
  else
30
30
  reflection.klass.find(target_uri)
31
31
  end
32
32
  rescue ActiveFedora::ObjectNotFoundError
33
- reflection.build_association(target_uri, &block)
33
+ reflection.build_association(id: target_uri, &block)
34
34
  end
35
35
 
36
36
  def replace(record)
@@ -27,6 +27,10 @@ module ActiveFedora::Associations
27
27
  @target_proxy ||= ActiveFedora::Orders::TargetProxy.new(self)
28
28
  end
29
29
 
30
+ def target_ids_reader
31
+ target_reader.ids
32
+ end
33
+
30
34
  def find_reflection
31
35
  reflection
32
36
  end
@@ -10,6 +10,7 @@ module ActiveFedora
10
10
  additions = incoming_objects - current_objects
11
11
  deletions.each { |object| owner.resource.delete([owner.rdf_subject, reflection.predicate, object]) }
12
12
  additions.each { |object| owner.resource.insert([owner.rdf_subject, reflection.predicate, object]) }
13
+ owner.resource.persist!
13
14
  owner.send(:attribute_will_change!, reflection.name)
14
15
  end
15
16
 
@@ -21,6 +22,7 @@ module ActiveFedora
21
22
  filtered_results.each do |candidate|
22
23
  owner.resource.delete([owner.rdf_subject, reflection.predicate, candidate])
23
24
  end
25
+ owner.resource.persist!
24
26
  end
25
27
 
26
28
  private
@@ -48,7 +48,6 @@ module ActiveFedora
48
48
 
49
49
  def _assign_attribute(k, v)
50
50
  raise UnknownAttributeError.new(self, k) unless respond_to?("#{k}=")
51
-
52
51
  public_send("#{k}=", v)
53
52
  end
54
53
  end
@@ -6,7 +6,7 @@ module ActiveFedora
6
6
  def set_value(*val)
7
7
  attribute = val.first
8
8
  unless [:has_model, :modified_date].include? attribute
9
- attribute_will_change!(attribute) unless self[val.first] == val.last
9
+ attribute_will_change!(attribute) unless Array(self[val.first]).to_set == Array(val.last).to_set
10
10
  end
11
11
  super
12
12
  end
@@ -144,7 +144,7 @@ module ActiveFedora
144
144
 
145
145
  # @param [Symbol] field the field to find or create
146
146
  # @param [Class] klass the class to use to delegate the attribute (e.g.
147
- # ActiveTripleAttribute, OmAttribute, or RdfDatastreamAttribute)
147
+ # ActiveTripleAttribute)
148
148
  # @param [Hash] args
149
149
  # @option args [String] :delegate_target the path to the delegate
150
150
  # @option args [Class] :klass the class to create
@@ -10,16 +10,12 @@ module ActiveFedora
10
10
  #
11
11
  # =The Basics
12
12
  # class Oralhistory < ActiveFedora::Base
13
- # has_metadata "properties", type: ActiveFedora::SimpleDatastream do |m|
14
- # m.field "narrator", :string
15
- # m.field "narrator", :text
16
- # end
13
+ # property :creator, predicate: RDF::Vocab::DC.creator
17
14
  # end
18
15
  #
19
- # The above example creates a Fedora object with a metadata datastream named "properties", which is composed of a
20
- # narrator and bio field.
16
+ # The above example creates a Fedora object with a property named "creator"
21
17
  #
22
- # Attached files defined with +contains+ are accessed via the +attached_files+ member hash.
18
+ # Attached files defined with +has_subresource+ and iis accessed via the +attached_files+ member hash.
23
19
  #
24
20
  class Base
25
21
  extend ActiveModel::Naming
@@ -40,11 +36,11 @@ module ActiveFedora
40
36
  include Associations
41
37
  include AutosaveAssociation
42
38
  include NestedAttributes
43
- include Reflection
44
39
  include Serialization
45
40
 
46
41
  include AttachedFiles
47
42
  include FedoraAttributes
43
+ include Reflection
48
44
  include AttributeMethods
49
45
  include Attributes
50
46
  include Versionable
@@ -23,8 +23,12 @@ module ActiveFedora
23
23
  result[predicate] = graph.query(subject: object.rdf_subject, predicate: predicate)
24
24
  elsif object.class.properties.keys.include?(key)
25
25
  predicate = graph.reflections.reflect_on_property(key).predicate
26
- result[predicate] = graph.query(subject: object.rdf_subject, predicate: predicate)
27
- result[predicate] = child_graphs(result[predicate].objects) << result[predicate]
26
+ results = graph.query(subject: object.rdf_subject, predicate: predicate)
27
+ new_graph = child_graphs(results.map(&:object))
28
+ results.each do |res|
29
+ new_graph << res
30
+ end
31
+ result[predicate] = new_graph
28
32
  elsif key == 'type'.freeze
29
33
  # working around https://github.com/ActiveTriples/ActiveTriples/issues/122
30
34
  predicate = ::RDF.type
@@ -22,7 +22,7 @@ module ActiveFedora
22
22
  def self.find_or_initialize(id)
23
23
  find(id)
24
24
  rescue ActiveFedora::ObjectNotFoundError
25
- new(id)
25
+ new(id: id)
26
26
  end
27
27
 
28
28
  private
@@ -22,14 +22,14 @@ module ActiveFedora
22
22
  # Also, if +attrs+ does not contain +:id+ but does contain +:namespace+ it will pass the
23
23
  # +:namespace+ value to Fedora::Repository.nextid to generate the next id available within
24
24
  # the given namespace.
25
- def initialize(attributes_or_id = nil, &_block)
25
+ def initialize(attributes = nil, &_block)
26
26
  init_internals
27
- attributes = initialize_attributes(attributes_or_id)
28
- @ldp_source = build_ldp_resource(attributes.delete(:id))
27
+ id = attributes && (attributes.delete(:id) || attributes.delete('id'))
28
+ @ldp_source = build_ldp_resource(id)
29
29
  raise IllegalOperation, "Attempting to recreate existing ldp_source: `#{ldp_source.subject}'" unless ldp_source.new?
30
+ assign_attributes(attributes) if attributes
30
31
  assert_content_model
31
32
  load_attached_files
32
- assign_attributes(attributes) if attributes
33
33
 
34
34
  yield self if block_given?
35
35
  _run_initialize_callbacks
@@ -96,13 +96,14 @@ module ActiveFedora
96
96
 
97
97
  protected
98
98
 
99
- # This can be overriden to assert a different model
100
- # It's normally called once in the lifecycle, by #create#
99
+ # This method is normally called once in the lifecycle, by #create#
101
100
  def assert_content_model
102
- self.has_model = self.class.to_s
101
+ self.has_model = self.class.to_rdf_representation
103
102
  end
104
103
 
105
104
  module ClassMethods
105
+ extend Deprecation
106
+
106
107
  def generated_association_methods
107
108
  @generated_association_methods ||= begin
108
109
  mod = const_set(:GeneratedAssociationMethods, Module.new)
@@ -111,13 +112,23 @@ module ActiveFedora
111
112
  end
112
113
  end
113
114
 
114
- # Returns a suitable uri object for :has_model
115
- # Should reverse Model#from_class_uri
116
- # TODO this is a poorly named method
117
- def to_class_uri(_attrs = {})
115
+ # Returns a suitable string representation for :has_model
116
+ # Override this method if you want to change how this class
117
+ # is represented in RDF.
118
+ def to_rdf_representation
118
119
  name
119
120
  end
120
121
 
122
+ # Returns a suitable string representation for :has_model
123
+ # @deprecated use to_rdf_representation instead
124
+ def to_class_uri(attrs = nil)
125
+ if attrs
126
+ Deprecation.warn ActiveFedora::Core, "to_class_uri no longer acceps an argument"
127
+ end
128
+ to_rdf_representation
129
+ end
130
+ deprecation_deprecate to_class_uri: "use 'to_rdf_representation()' instead"
131
+
121
132
  private
122
133
 
123
134
  def relation
@@ -144,19 +155,5 @@ module ActiveFedora
144
155
  raise ActiveFedora::ObjectNotFoundError, "Can't reload an object that hasn't been saved"
145
156
  end
146
157
  end
147
-
148
- def initialize_attributes(attributes_or_id)
149
- case attributes_or_id
150
- when String
151
- attributes = { id: attributes_or_id }.with_indifferent_access
152
- when Hash
153
- attributes = attributes_or_id.with_indifferent_access
154
- when NilClass
155
- attributes = {}.with_indifferent_access
156
- else
157
- raise ArgumentError, "#{attributes_or_id.class} is not acceptable"
158
- end
159
- attributes
160
- end
161
158
  end
162
159
  end
@@ -43,7 +43,7 @@ module ActiveFedora
43
43
  # Appending the graph at the end is necessary because adding it as the
44
44
  # parent leaves behind triples not related to the ldp_source's rdf
45
45
  # subject.
46
- @resource ||= self.class.resource_class.new(@ldp_source.graph.rdf_subject, @ldp_source.graph) << @ldp_source.graph
46
+ @resource ||= self.class.resource_class.new(@ldp_source.graph.rdf_subject, data: @ldp_source.graph.graph.data)
47
47
  end
48
48
 
49
49
  # You can set the URI to use for the rdf_label on ClassMethods.rdf_label, then on
@@ -23,7 +23,7 @@ module ActiveFedora::File::Streaming
23
23
  end
24
24
 
25
25
  def each(no_of_requests_limit = 3, &block)
26
- raise ArgumentError, 'HTTP redirect too deep' if no_of_requests_limit == 0
26
+ raise ArgumentError, 'HTTP redirect too deep' if no_of_requests_limit.zero?
27
27
  Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
28
28
  request = Net::HTTP::Get.new uri, headers
29
29
  http.request request do |response|
@@ -30,7 +30,7 @@ module ActiveFedora
30
30
  # @yield [self] Yields self
31
31
  # @yieldparam [File] self the newly created file
32
32
  def initialize(identifier = nil, &_block)
33
- identifier = nil if identifier.is_a? Hash
33
+ identifier = identifier.delete(:id) if identifier.is_a? Hash
34
34
  run_callbacks(:initialize) do
35
35
  case identifier
36
36
  when nil, ::RDF::URI
@@ -160,14 +160,6 @@ module ActiveFedora
160
160
  end
161
161
  private_class_method :relation
162
162
 
163
- protected
164
-
165
- # The string to prefix all solr fields with. Override this method if you want
166
- # a prefix other than the default
167
- def prefix(path)
168
- path ? "#{path.underscore}__" : ''
169
- end
170
-
171
163
  private
172
164
 
173
165
  def create_or_update(*options)
@@ -91,21 +91,6 @@ module ActiveFedora
91
91
  end
92
92
  end
93
93
 
94
- # This method can be used instead of ActiveFedora::Model::ClassMethods.find.
95
- # It works similarly except it populates an object from Solr instead of Fedora.
96
- # It is most useful for objects used in read-only displays in order to speed up loading time. If only
97
- # a id is passed in it will query solr for a corresponding solr document and then use it
98
- # to populate this object.
99
- #
100
- # If a value is passed in for optional parameter solr_doc it will not query solr again and just use the
101
- # one passed to populate the object.
102
- #
103
- # It will anything stored within solr such as metadata and relationships. Non-metadata attached files will not
104
- # be loaded and if needed you should use find instead.
105
- def load_instance_from_solr(id, solr_doc = nil)
106
- SolrInstanceLoader.new(self, id, solr_doc).object
107
- end
108
-
109
94
  def descendant_uris(uri)
110
95
  resource = Ldp::Resource::RdfSource.new(ActiveFedora.fedora.connection, uri)
111
96
  # GET could be slow if it's a big resource, we're using HEAD to avoid this problem,
@@ -15,10 +15,6 @@ module ActiveFedora
15
15
  @object = obj
16
16
  end
17
17
 
18
- def self.profile_solr_name
19
- @profile_solr_name ||= ActiveFedora.index_field_mapper.solr_name("object_profile", :displayable)
20
- end
21
-
22
18
  def self.create_time_solr_name
23
19
  @create_time_solr_name ||= ActiveFedora.index_field_mapper.solr_name('system_create', :stored_sortable, type: :date)
24
20
  end
@@ -40,7 +36,6 @@ module ActiveFedora
40
36
  Solrizer.set_field(solr_doc, 'system_modified', m_time, :stored_sortable)
41
37
  solr_doc[QueryResultBuilder::HAS_MODEL_SOLR_FIELD] = object.has_model
42
38
  solr_doc[ActiveFedora.id_field.to_sym] = object.id
43
- solr_doc[self.class.profile_solr_name] = profile_service.new(object).export
44
39
  object.declared_attached_files.each do |name, file|
45
40
  solr_doc.merge! file.to_solr(solr_doc, name: name.to_s)
46
41
  end
@@ -51,10 +46,6 @@ module ActiveFedora
51
46
 
52
47
  protected
53
48
 
54
- def profile_service
55
- ProfileIndexingService
56
- end
57
-
58
49
  def c_time
59
50
  c_time = object.create_date.present? ? object.create_date : DateTime.now
60
51
  c_time = DateTime.parse(c_time) unless c_time.is_a?(DateTime)