active-fedora 10.3.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 (164) 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/active-fedora.gemspec +6 -10
  6. data/lib/active_fedora/aggregation/list_source.rb +2 -0
  7. data/lib/active_fedora/associations/association_scope.rb +1 -1
  8. data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
  9. data/lib/active_fedora/associations/builder/association.rb +1 -1
  10. data/lib/active_fedora/associations/builder/orders.rb +11 -3
  11. data/lib/active_fedora/associations/collection_association.rb +3 -3
  12. data/lib/active_fedora/associations/contained_finder.rb +2 -2
  13. data/lib/active_fedora/associations/has_many_association.rb +1 -1
  14. data/lib/active_fedora/associations/orders_association.rb +4 -0
  15. data/lib/active_fedora/associations/rdf.rb +2 -0
  16. data/lib/active_fedora/attribute_assignment.rb +0 -1
  17. data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
  18. data/lib/active_fedora/attributes.rb +1 -1
  19. data/lib/active_fedora/base.rb +4 -8
  20. data/lib/active_fedora/change_set.rb +6 -2
  21. data/lib/active_fedora/core.rb +22 -27
  22. data/lib/active_fedora/fedora.rb +2 -6
  23. data/lib/active_fedora/fedora_attributes.rb +1 -1
  24. data/lib/active_fedora/file/streaming.rb +1 -1
  25. data/lib/active_fedora/indexing.rb +1 -18
  26. data/lib/active_fedora/indexing_service.rb +0 -9
  27. data/lib/active_fedora/loadable_from_json.rb +12 -1
  28. data/lib/active_fedora/nested_attributes.rb +2 -2
  29. data/lib/active_fedora/orders/list_node.rb +2 -2
  30. data/lib/active_fedora/orders/ordered_list.rb +7 -3
  31. data/lib/active_fedora/orders/target_proxy.rb +4 -0
  32. data/lib/active_fedora/querying.rb +1 -1
  33. data/lib/active_fedora/railtie.rb +2 -2
  34. data/lib/active_fedora/rdf/persistence.rb +1 -0
  35. data/lib/active_fedora/rdf.rb +0 -1
  36. data/lib/active_fedora/relation/delegation.rb +4 -0
  37. data/lib/active_fedora/solr_hit.rb +0 -13
  38. data/lib/active_fedora/solr_query_builder.rb +17 -13
  39. data/lib/active_fedora/version.rb +1 -1
  40. data/lib/active_fedora.rb +0 -12
  41. data/lib/generators/active_fedora/model/model_generator.rb +1 -1
  42. data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
  43. data/lib/tasks/active_fedora_dev.rake +1 -1
  44. data/spec/config_helper.rb +1 -1
  45. data/spec/integration/associations_spec.rb +23 -24
  46. data/spec/integration/attached_files_spec.rb +18 -8
  47. data/spec/integration/attributes_spec.rb +12 -16
  48. data/spec/integration/autosave_association_spec.rb +6 -6
  49. data/spec/integration/base_spec.rb +3 -3
  50. data/spec/integration/basic_contains_association_spec.rb +1 -1
  51. data/spec/integration/clean_connection_spec.rb +1 -1
  52. data/spec/integration/collection_association_spec.rb +2 -5
  53. data/spec/integration/date_time_properties_spec.rb +1 -17
  54. data/spec/integration/direct_container_spec.rb +12 -12
  55. data/spec/integration/directly_contains_one_association_spec.rb +11 -13
  56. data/spec/integration/fedora_solr_sync_spec.rb +2 -2
  57. data/spec/integration/file_fixity_spec.rb +6 -8
  58. data/spec/integration/file_spec.rb +32 -34
  59. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +5 -5
  60. data/spec/integration/has_many_associations_spec.rb +9 -11
  61. data/spec/integration/indexing_spec.rb +2 -2
  62. data/spec/integration/indirect_container_spec.rb +11 -12
  63. data/spec/integration/json_serialization_spec.rb +4 -4
  64. data/spec/integration/query_result_builder_spec.rb +9 -21
  65. data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
  66. data/spec/integration/relation_delegation_spec.rb +8 -10
  67. data/spec/integration/relation_spec.rb +13 -16
  68. data/spec/integration/scoped_query_spec.rb +3 -3
  69. data/spec/integration/solr_hit_spec.rb +4 -15
  70. data/spec/integration/versionable_spec.rb +73 -327
  71. data/spec/integration/with_metadata_spec.rb +1 -1
  72. data/spec/spec_helper.rb +52 -10
  73. data/spec/unit/active_fedora_spec.rb +1 -1
  74. data/spec/unit/aggregation/list_source_spec.rb +37 -37
  75. data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
  76. data/spec/unit/association_hash_spec.rb +17 -31
  77. data/spec/unit/attached_files_spec.rb +35 -32
  78. data/spec/unit/attributes_spec.rb +25 -25
  79. data/spec/unit/base_active_model_spec.rb +8 -8
  80. data/spec/unit/base_cma_spec.rb +1 -1
  81. data/spec/unit/base_extra_spec.rb +7 -22
  82. data/spec/unit/base_spec.rb +17 -24
  83. data/spec/unit/callback_spec.rb +2 -2
  84. data/spec/unit/change_set_spec.rb +5 -5
  85. data/spec/unit/checksum_spec.rb +2 -2
  86. data/spec/unit/code_configurator_spec.rb +1 -1
  87. data/spec/unit/core/fedora_id_translator_spec.rb +2 -2
  88. data/spec/unit/core/fedora_uri_translator_spec.rb +2 -2
  89. data/spec/unit/core_spec.rb +65 -29
  90. data/spec/unit/default_model_mapper_spec.rb +6 -6
  91. data/spec/unit/fedora_spec.rb +3 -4
  92. data/spec/unit/file_configurator_spec.rb +96 -96
  93. data/spec/unit/file_path_builder_spec.rb +1 -1
  94. data/spec/unit/file_spec.rb +61 -61
  95. data/spec/unit/files_hash_spec.rb +9 -9
  96. data/spec/unit/filter_spec.rb +3 -3
  97. data/spec/unit/finder_methods_spec.rb +3 -3
  98. data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
  99. data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
  100. data/spec/unit/has_many_association_spec.rb +5 -5
  101. data/spec/unit/indexers/global_indexer_spec.rb +6 -6
  102. data/spec/unit/indexing_service_spec.rb +5 -5
  103. data/spec/unit/indexing_spec.rb +6 -6
  104. data/spec/unit/inheritance_spec.rb +11 -7
  105. data/spec/unit/loadable_from_json_spec.rb +4 -4
  106. data/spec/unit/logger_spec.rb +1 -1
  107. data/spec/unit/model_classifier_spec.rb +5 -5
  108. data/spec/unit/ordered_spec.rb +144 -147
  109. data/spec/unit/orders/list_node_spec.rb +21 -21
  110. data/spec/unit/orders/ordered_list_spec.rb +96 -96
  111. data/spec/unit/orders/reflection_spec.rb +4 -4
  112. data/spec/unit/pathing_spec.rb +4 -4
  113. data/spec/unit/persistence_spec.rb +28 -28
  114. data/spec/unit/property_spec.rb +2 -2
  115. data/spec/unit/query_spec.rb +6 -6
  116. data/spec/unit/rdf/indexing_service_spec.rb +29 -29
  117. data/spec/unit/readonly_spec.rb +5 -4
  118. data/spec/unit/reflection_spec.rb +3 -3
  119. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
  120. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
  121. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
  122. data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
  123. data/spec/unit/serializers_spec.rb +3 -4
  124. data/spec/unit/solr_config_options_spec.rb +13 -16
  125. data/spec/unit/solr_hit_spec.rb +9 -9
  126. data/spec/unit/solr_service_spec.rb +4 -10
  127. data/spec/unit/sparql_insert_spec.rb +2 -2
  128. data/spec/unit/validations_spec.rb +9 -9
  129. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
  130. data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
  131. metadata +18 -92
  132. data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
  133. data/lib/active_fedora/datastreams.rb +0 -6
  134. data/lib/active_fedora/nom_datastream.rb +0 -73
  135. data/lib/active_fedora/om_datastream.rb +0 -118
  136. data/lib/active_fedora/profile_indexing_service.rb +0 -11
  137. data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
  138. data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
  139. data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
  140. data/lib/active_fedora/rdf/rdf_datastream.rb +0 -167
  141. data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
  142. data/lib/active_fedora/solr_instance_loader.rb +0 -47
  143. data/spec/fixtures/damsObjectModel.xml +0 -38
  144. data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
  145. data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
  146. data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
  147. data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
  148. data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
  149. data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
  150. data/spec/integration/ntriples_datastream_spec.rb +0 -203
  151. data/spec/integration/om_datastream_spec.rb +0 -78
  152. data/spec/integration/solr_instance_loader_spec.rb +0 -156
  153. data/spec/samples/hydra-mods_article_datastream.rb +0 -517
  154. data/spec/samples/models/mods_article.rb +0 -9
  155. data/spec/samples/oral_history_sample.xml +0 -38
  156. data/spec/samples/oral_history_xml.xml +0 -35
  157. data/spec/samples/samples.rb +0 -2
  158. data/spec/unit/nom_datastream_spec.rb +0 -60
  159. data/spec/unit/ntriples_datastream_spec.rb +0 -170
  160. data/spec/unit/om_datastream_spec.rb +0 -294
  161. data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
  162. data/spec/unit/rdf_datastream_spec.rb +0 -84
  163. data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
  164. data/spec/unit/rdfxml_datastream_spec.rb +0 -106
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f4e8471f5df940e6d52c76f150fd1532aff2e7d
4
- data.tar.gz: 79be63a9635f81dfe7a0017fe8890900e4ff598c
3
+ metadata.gz: 1a3e4470dd33d72dc20a0794fd42e8a08d96363f
4
+ data.tar.gz: 9e7b438a6b8a23515de79c50b3f44dc2df2a6d3f
5
5
  SHA512:
6
- metadata.gz: c2ff90b7a1a95255a21f55d72c55a488087087147629b29615380a041ba8da465a61274e850b52299955951f7a85bf398e4d0709db552cfb418d4ad2693b524f
7
- data.tar.gz: 193eac22abf48bb8b3817d92d36fb25f977155648ee8f7c2493d271be6d01c4b2f0d4b587c501b2fe668a0f82d0e7cd0a4eba16af506d84da7136c5664ca0ff6
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
@@ -14,31 +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'
21
+ s.add_dependency "active-triples", '~> 0.11.0'
25
22
  s.add_dependency "deprecation"
26
- s.add_dependency "ldp", '~> 0.5.0'
23
+ s.add_dependency "ldp", '~> 0.6.0'
27
24
 
28
25
  s.add_development_dependency "rails"
29
26
  s.add_development_dependency "rdoc"
30
27
  s.add_development_dependency "yard"
31
28
  # Pin rake to 10.0 due to https://github.com/lsegal/yard/issues/947
32
29
  s.add_development_dependency "rake", '~> 10.0'
33
- s.add_development_dependency "solr_wrapper", "~> 0.4"
30
+ s.add_development_dependency "solr_wrapper", "~> 0.15"
34
31
  s.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
35
32
  s.add_development_dependency "rspec", "~> 3.0"
36
33
  s.add_development_dependency "rspec-its"
37
34
  s.add_development_dependency "equivalent-xml"
38
35
  s.add_development_dependency "simplecov", '~> 0.8'
39
- # Pin to rubocop 0.38.0 due to https://github.com/nevir/rubocop-rspec/issues/78
40
- s.add_development_dependency "rubocop", '~> 0.38.0'
41
- 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'
42
38
 
43
39
  s.files = `git ls-files`.split("\n")
44
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
@@ -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
@@ -2,7 +2,6 @@ module ActiveFedora
2
2
  module Core
3
3
  extend ActiveSupport::Autoload
4
4
  extend ActiveSupport::Concern
5
- extend Deprecation
6
5
  include ActiveFedora::Common
7
6
 
8
7
  autoload :FedoraIdTranslator
@@ -23,14 +22,14 @@ module ActiveFedora
23
22
  # Also, if +attrs+ does not contain +:id+ but does contain +:namespace+ it will pass the
24
23
  # +:namespace+ value to Fedora::Repository.nextid to generate the next id available within
25
24
  # the given namespace.
26
- def initialize(attributes_or_id = nil, &_block)
25
+ def initialize(attributes = nil, &_block)
27
26
  init_internals
28
- attributes = initialize_attributes(attributes_or_id)
29
- @ldp_source = build_ldp_resource(attributes.delete('id'.freeze))
27
+ id = attributes && (attributes.delete(:id) || attributes.delete('id'))
28
+ @ldp_source = build_ldp_resource(id)
30
29
  raise IllegalOperation, "Attempting to recreate existing ldp_source: `#{ldp_source.subject}'" unless ldp_source.new?
30
+ assign_attributes(attributes) if attributes
31
31
  assert_content_model
32
32
  load_attached_files
33
- assign_attributes(attributes) if attributes
34
33
 
35
34
  yield self if block_given?
36
35
  _run_initialize_callbacks
@@ -97,13 +96,14 @@ module ActiveFedora
97
96
 
98
97
  protected
99
98
 
100
- # This can be overriden to assert a different model
101
- # It's normally called once in the lifecycle, by #create#
99
+ # This method is normally called once in the lifecycle, by #create#
102
100
  def assert_content_model
103
- self.has_model = self.class.to_s
101
+ self.has_model = self.class.to_rdf_representation
104
102
  end
105
103
 
106
104
  module ClassMethods
105
+ extend Deprecation
106
+
107
107
  def generated_association_methods
108
108
  @generated_association_methods ||= begin
109
109
  mod = const_set(:GeneratedAssociationMethods, Module.new)
@@ -112,13 +112,23 @@ module ActiveFedora
112
112
  end
113
113
  end
114
114
 
115
- # Returns a suitable uri object for :has_model
116
- # Should reverse Model#from_class_uri
117
- # TODO this is a poorly named method
118
- 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
119
119
  name
120
120
  end
121
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
+
122
132
  private
123
133
 
124
134
  def relation
@@ -145,20 +155,5 @@ module ActiveFedora
145
155
  raise ActiveFedora::ObjectNotFoundError, "Can't reload an object that hasn't been saved"
146
156
  end
147
157
  end
148
-
149
- def initialize_attributes(attributes_or_id)
150
- case attributes_or_id
151
- when String
152
- Deprecation.warn(Core, "calling #{self.class}.new with a string is deprecated. Pass a hash with id instead.")
153
- { 'id': attributes_or_id }
154
- when NilClass
155
- {}
156
- else
157
- unless attributes_or_id.respond_to?(:stringify_keys)
158
- raise ArgumentError, "#{attributes_or_id.class} is not acceptable"
159
- end
160
- attributes_or_id.stringify_keys
161
- end
162
- end
163
158
  end
164
159
  end
@@ -23,15 +23,11 @@ module ActiveFedora
23
23
  end
24
24
 
25
25
  def host
26
- @config[:url].sub(/\/$/, BLANK)
26
+ @config[:url]
27
27
  end
28
28
 
29
29
  def base_path
30
- @config[:base_path] || SLASH
31
- end
32
-
33
- def base_uri
34
- host + base_path.sub(/\/$/, BLANK)
30
+ @config[:base_path] || '/'
35
31
  end
36
32
 
37
33
  def user
@@ -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|
@@ -10,7 +10,6 @@ module ActiveFedora
10
10
  module Indexing
11
11
  extend ActiveSupport::Concern
12
12
  extend ActiveSupport::Autoload
13
- extend Deprecation
14
13
 
15
14
  eager_autoload do
16
15
  autoload :Map
@@ -84,7 +83,7 @@ module ActiveFedora
84
83
  end
85
84
 
86
85
  def reindex_everything
87
- descendants = descendant_uris(ActiveFedora.fedora.base_uri)
86
+ descendants = descendant_uris(ActiveFedora::Base.id_to_uri(''))
88
87
  descendants.shift # Discard the root uri
89
88
  descendants.each do |uri|
90
89
  logger.debug "Re-index everything ... #{uri}"
@@ -92,22 +91,6 @@ module ActiveFedora
92
91
  end
93
92
  end
94
93
 
95
- # This method can be used instead of ActiveFedora::Model::ClassMethods.find.
96
- # It works similarly except it populates an object from Solr instead of Fedora.
97
- # It is most useful for objects used in read-only displays in order to speed up loading time. If only
98
- # a id is passed in it will query solr for a corresponding solr document and then use it
99
- # to populate this object.
100
- #
101
- # If a value is passed in for optional parameter solr_doc it will not query solr again and just use the
102
- # one passed to populate the object.
103
- #
104
- # It will anything stored within solr such as metadata and relationships. Non-metadata attached files will not
105
- # be loaded and if needed you should use find instead.
106
- def load_instance_from_solr(id, solr_doc = nil)
107
- SolrInstanceLoader.new(self, id, solr_doc).object
108
- end
109
- deprecation_deprecate :load_instance_from_solr
110
-
111
94
  def descendant_uris(uri)
112
95
  resource = Ldp::Resource::RdfSource.new(ActiveFedora.fedora.connection, uri)
113
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)
@@ -50,6 +50,10 @@ module ActiveFedora
50
50
  @hash[k]
51
51
  end
52
52
 
53
+ def persist!(*)
54
+ true
55
+ end
56
+
53
57
  # FakeQuery exists to adapt the hash to the RDF interface used by RDF associations in ActiveFedora
54
58
  class FakeQuery
55
59
  include ::Enumerable
@@ -153,7 +157,7 @@ module ActiveFedora
153
157
  # @param attribute_name [String] the name of the attribute to adapt
154
158
  # @return [Object] the adapted value
155
159
  def adapt_attribute_value(attrs, attribute_name)
156
- reflection = self.class.reflect_on_property(attribute_name)
160
+ reflection = property_reflection(attribute_name)
157
161
  # if this isn't a property, copy value verbatim
158
162
  return attrs[attribute_name] unless reflection
159
163
  multiple = reflection.multiple?
@@ -169,6 +173,13 @@ module ActiveFedora
169
173
  end
170
174
  end
171
175
 
176
+ def property_reflection(attribute_name)
177
+ self.class.reflect_on_property(attribute_name)
178
+ rescue ActiveTriples::UndefinedPropertyError
179
+ ActiveFedora::Base.logger.info "Undefined property #{attribute_name} reflected."
180
+ nil
181
+ end
182
+
172
183
  def date_attribute?(attribute_name)
173
184
  reflection = self.class.reflect_on_property(attribute_name)
174
185
  return false unless reflection