active-fedora 10.1.0 → 11.1.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 (208) 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/.travis.yml +6 -9
  7. data/Gemfile +1 -0
  8. data/History.txt +34 -0
  9. data/README.md +1 -3
  10. data/active-fedora.gemspec +7 -13
  11. data/lib/active_fedora/aggregation/list_source.rb +2 -0
  12. data/lib/active_fedora/associations/association_scope.rb +1 -1
  13. data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
  14. data/lib/active_fedora/associations/builder/association.rb +1 -1
  15. data/lib/active_fedora/associations/builder/orders.rb +11 -3
  16. data/lib/active_fedora/associations/collection_association.rb +5 -5
  17. data/lib/active_fedora/associations/collection_proxy.rb +10 -10
  18. data/lib/active_fedora/associations/contained_finder.rb +2 -2
  19. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +1 -1
  20. data/lib/active_fedora/associations/has_many_association.rb +2 -2
  21. data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
  22. data/lib/active_fedora/associations/orders_association.rb +4 -0
  23. data/lib/active_fedora/associations/rdf.rb +2 -0
  24. data/lib/active_fedora/attribute_assignment.rb +0 -1
  25. data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
  26. data/lib/active_fedora/attribute_methods.rb +1 -1
  27. data/lib/active_fedora/attributes.rb +1 -1
  28. data/lib/active_fedora/base.rb +4 -8
  29. data/lib/active_fedora/change_set.rb +6 -2
  30. data/lib/active_fedora/cleaner.rb +1 -1
  31. data/lib/active_fedora/containers/container.rb +1 -1
  32. data/lib/active_fedora/core.rb +33 -30
  33. data/lib/active_fedora/fedora.rb +6 -2
  34. data/lib/active_fedora/fedora_attributes.rb +1 -1
  35. data/lib/active_fedora/file/streaming.rb +1 -1
  36. data/lib/active_fedora/file.rb +2 -1
  37. data/lib/active_fedora/file_configurator.rb +3 -3
  38. data/lib/active_fedora/indexing.rb +1 -18
  39. data/lib/active_fedora/indexing_service.rb +0 -9
  40. data/lib/active_fedora/initializing_connection.rb +1 -1
  41. data/lib/active_fedora/loadable_from_json.rb +12 -1
  42. data/lib/active_fedora/model_classifier.rb +1 -1
  43. data/lib/active_fedora/nested_attributes.rb +2 -2
  44. data/lib/active_fedora/null_logger.rb +10 -0
  45. data/lib/active_fedora/orders/list_node.rb +2 -2
  46. data/lib/active_fedora/orders/ordered_list.rb +8 -4
  47. data/lib/active_fedora/orders/target_proxy.rb +4 -0
  48. data/lib/active_fedora/querying.rb +1 -1
  49. data/lib/active_fedora/railtie.rb +2 -2
  50. data/lib/active_fedora/rake_support.rb +1 -1
  51. data/lib/active_fedora/rdf/field_map_entry.rb +6 -0
  52. data/lib/active_fedora/rdf/persistence.rb +1 -0
  53. data/lib/active_fedora/rdf/value_caster.rb +15 -0
  54. data/lib/active_fedora/rdf.rb +1 -1
  55. data/lib/active_fedora/relation/delegation.rb +4 -0
  56. data/lib/active_fedora/relation/finder_methods.rb +3 -1
  57. data/lib/active_fedora/solr_hit.rb +1 -14
  58. data/lib/active_fedora/solr_query_builder.rb +17 -13
  59. data/lib/active_fedora/version.rb +1 -1
  60. data/lib/active_fedora/with_metadata/metadata_node.rb +2 -1
  61. data/lib/active_fedora.rb +1 -12
  62. data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +11 -0
  63. data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
  64. data/lib/generators/active_fedora/model/model_generator.rb +1 -1
  65. data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
  66. data/lib/tasks/active_fedora_dev.rake +1 -1
  67. data/spec/config_helper.rb +1 -1
  68. data/spec/integration/associations_spec.rb +23 -24
  69. data/spec/integration/attached_files_spec.rb +19 -9
  70. data/spec/integration/attributes_spec.rb +12 -16
  71. data/spec/integration/autosave_association_spec.rb +6 -6
  72. data/spec/integration/base_spec.rb +8 -8
  73. data/spec/integration/basic_contains_association_spec.rb +1 -1
  74. data/spec/integration/clean_connection_spec.rb +1 -1
  75. data/spec/integration/collection_association_spec.rb +2 -5
  76. data/spec/integration/date_time_properties_spec.rb +1 -17
  77. data/spec/integration/direct_container_spec.rb +12 -12
  78. data/spec/integration/directly_contains_one_association_spec.rb +11 -13
  79. data/spec/integration/eradicate_spec.rb +1 -1
  80. data/spec/integration/fedora_solr_sync_spec.rb +2 -2
  81. data/spec/integration/file_fixity_spec.rb +6 -8
  82. data/spec/integration/file_spec.rb +37 -39
  83. data/spec/integration/generators/solr_generator_spec.rb +7 -10
  84. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +7 -7
  85. data/spec/integration/has_many_associations_spec.rb +9 -11
  86. data/spec/integration/indexing_spec.rb +2 -2
  87. data/spec/integration/indirect_container_spec.rb +11 -12
  88. data/spec/integration/json_serialization_spec.rb +4 -4
  89. data/spec/integration/query_result_builder_spec.rb +9 -21
  90. data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
  91. data/spec/integration/relation_delegation_spec.rb +8 -10
  92. data/spec/integration/relation_spec.rb +13 -16
  93. data/spec/integration/scoped_query_spec.rb +3 -3
  94. data/spec/integration/scoping_spec.rb +3 -3
  95. data/spec/integration/solr_hit_spec.rb +4 -15
  96. data/spec/integration/versionable_spec.rb +73 -327
  97. data/spec/integration/with_metadata_spec.rb +1 -1
  98. data/spec/spec_helper.rb +52 -10
  99. data/spec/unit/active_fedora_spec.rb +1 -1
  100. data/spec/unit/aggregation/list_source_spec.rb +37 -37
  101. data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
  102. data/spec/unit/association_hash_spec.rb +17 -31
  103. data/spec/unit/attached_files_spec.rb +35 -32
  104. data/spec/unit/attributes_spec.rb +25 -25
  105. data/spec/unit/base_active_model_spec.rb +8 -8
  106. data/spec/unit/base_cma_spec.rb +1 -1
  107. data/spec/unit/base_extra_spec.rb +7 -22
  108. data/spec/unit/base_spec.rb +21 -27
  109. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
  110. data/spec/unit/callback_spec.rb +2 -2
  111. data/spec/unit/change_set_spec.rb +5 -5
  112. data/spec/unit/checksum_spec.rb +2 -2
  113. data/spec/unit/code_configurator_spec.rb +1 -1
  114. data/spec/unit/core/fedora_id_translator_spec.rb +2 -2
  115. data/spec/unit/core/fedora_uri_translator_spec.rb +2 -2
  116. data/spec/unit/core/logger_spec.rb +18 -0
  117. data/spec/unit/core_spec.rb +68 -32
  118. data/spec/unit/default_model_mapper_spec.rb +6 -6
  119. data/spec/unit/fedora_spec.rb +3 -4
  120. data/spec/unit/file_configurator_spec.rb +96 -96
  121. data/spec/unit/file_path_builder_spec.rb +3 -3
  122. data/spec/unit/file_spec.rb +93 -61
  123. data/spec/unit/files_hash_spec.rb +9 -9
  124. data/spec/unit/filter_spec.rb +3 -3
  125. data/spec/unit/finder_methods_spec.rb +3 -3
  126. data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
  127. data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
  128. data/spec/unit/has_many_association_spec.rb +28 -13
  129. data/spec/unit/indexers/global_indexer_spec.rb +6 -6
  130. data/spec/unit/indexing_service_spec.rb +5 -5
  131. data/spec/unit/indexing_spec.rb +8 -8
  132. data/spec/unit/inheritance_spec.rb +11 -7
  133. data/spec/unit/loadable_from_json_spec.rb +4 -4
  134. data/spec/unit/logger_spec.rb +1 -1
  135. data/spec/unit/model_classifier_spec.rb +5 -5
  136. data/spec/unit/ordered_spec.rb +144 -147
  137. data/spec/unit/orders/list_node_spec.rb +22 -22
  138. data/spec/unit/orders/ordered_list_spec.rb +96 -96
  139. data/spec/unit/orders/reflection_spec.rb +4 -4
  140. data/spec/unit/pathing_spec.rb +4 -4
  141. data/spec/unit/persistence_spec.rb +28 -28
  142. data/spec/unit/property_spec.rb +2 -2
  143. data/spec/unit/query_spec.rb +12 -12
  144. data/spec/unit/rdf/indexing_service_spec.rb +29 -29
  145. data/spec/unit/readonly_spec.rb +5 -4
  146. data/spec/unit/reflection_spec.rb +3 -3
  147. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
  148. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
  149. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
  150. data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
  151. data/spec/unit/serializers_spec.rb +3 -4
  152. data/spec/unit/solr_config_options_spec.rb +13 -16
  153. data/spec/unit/solr_hit_spec.rb +9 -9
  154. data/spec/unit/solr_service_spec.rb +4 -10
  155. data/spec/unit/sparql_insert_spec.rb +2 -2
  156. data/spec/unit/validations_spec.rb +12 -12
  157. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
  158. data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
  159. metadata +30 -130
  160. data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
  161. data/lib/active_fedora/datastreams.rb +0 -6
  162. data/lib/active_fedora/nom_datastream.rb +0 -73
  163. data/lib/active_fedora/om_datastream.rb +0 -118
  164. data/lib/active_fedora/profile_indexing_service.rb +0 -11
  165. data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
  166. data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
  167. data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
  168. data/lib/active_fedora/rdf/rdf_datastream.rb +0 -167
  169. data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
  170. data/lib/active_fedora/solr_instance_loader.rb +0 -47
  171. data/solr/config/_rest_managed.json +0 -3
  172. data/solr/config/admin-extra.html +0 -31
  173. data/solr/config/elevate.xml +0 -36
  174. data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
  175. data/solr/config/protwords.txt +0 -21
  176. data/solr/config/schema.xml +0 -372
  177. data/solr/config/scripts.conf +0 -24
  178. data/solr/config/solrconfig.xml +0 -311
  179. data/solr/config/spellings.txt +0 -2
  180. data/solr/config/stopwords.txt +0 -58
  181. data/solr/config/stopwords_en.txt +0 -58
  182. data/solr/config/synonyms.txt +0 -31
  183. data/solr/config/xslt/example.xsl +0 -132
  184. data/solr/config/xslt/example_atom.xsl +0 -67
  185. data/solr/config/xslt/example_rss.xsl +0 -66
  186. data/solr/config/xslt/luke.xsl +0 -337
  187. data/spec/fixtures/damsObjectModel.xml +0 -38
  188. data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
  189. data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
  190. data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
  191. data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
  192. data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
  193. data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
  194. data/spec/integration/ntriples_datastream_spec.rb +0 -203
  195. data/spec/integration/om_datastream_spec.rb +0 -78
  196. data/spec/integration/solr_instance_loader_spec.rb +0 -156
  197. data/spec/samples/hydra-mods_article_datastream.rb +0 -517
  198. data/spec/samples/models/mods_article.rb +0 -9
  199. data/spec/samples/oral_history_sample.xml +0 -38
  200. data/spec/samples/oral_history_xml.xml +0 -35
  201. data/spec/samples/samples.rb +0 -2
  202. data/spec/unit/nom_datastream_spec.rb +0 -60
  203. data/spec/unit/ntriples_datastream_spec.rb +0 -170
  204. data/spec/unit/om_datastream_spec.rb +0 -294
  205. data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
  206. data/spec/unit/rdf_datastream_spec.rb +0 -84
  207. data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
  208. data/spec/unit/rdfxml_datastream_spec.rb +0 -106
@@ -1,119 +0,0 @@
1
- module ActiveFedora
2
- module Datastreams
3
- module NokogiriDatastreams
4
- extend ActiveSupport::Concern
5
-
6
- module ClassMethods
7
- def xml_template
8
- Nokogiri::XML::Document.parse("<xml/>")
9
- end
10
-
11
- def decorate_ng_xml(xml)
12
- xml
13
- end
14
- end
15
-
16
- def ng_xml
17
- @ng_xml ||= begin
18
- xml = if new_record?
19
- ## Load up the template
20
- self.class.xml_template
21
- else
22
- Nokogiri::XML::Document.parse(remote_content)
23
- end
24
- self.class.decorate_ng_xml xml
25
- end
26
- end
27
-
28
- def ng_xml=(new_xml)
29
- # before we set ng_xml, we load the datastream so we know if the new value differs.
30
- # TODO reinstate this
31
- # local_or_remote_content(true)
32
-
33
- case new_xml
34
- when Nokogiri::XML::Document
35
- self.content = new_xml.to_xml
36
- when Nokogiri::XML::Node
37
- ## Cast a fragment to a document
38
- self.content = new_xml.to_s
39
- when String
40
- self.content = new_xml
41
- else
42
- raise TypeError, "You passed a #{new_xml.class} into the ng_xml of the #{dsid} datastream. OmDatastream.ng_xml= only accepts Nokogiri::XML::Document, Nokogiri::XML::Element, Nokogiri::XML::Node, or raw XML (String) as inputs."
43
- end
44
- end
45
-
46
- def refresh_attributes
47
- changed_attributes.clear
48
- @ng_xml = nil
49
- end
50
-
51
- # don't want content eagerly loaded by proxy, so implementing methods that would be implemented by define_attribute_methods
52
- def ng_xml_will_change!
53
- changed_attributes['ng_xml'] = nil
54
- end
55
-
56
- def ng_xml_doesnt_change!
57
- changed_attributes.delete('ng_xml')
58
- end
59
-
60
- # don't want content eagerly loaded by proxy, so implementing methods that would be implemented by define_attribute_methods
61
- def ng_xml_changed?
62
- changed_attributes.key? 'ng_xml'
63
- end
64
-
65
- def remote_content
66
- @ds_content ||= Nokogiri::XML(super).to_xml(&:no_declaration).strip
67
- end
68
-
69
- def content=(new_content)
70
- if remote_content != new_content.to_s
71
- ng_xml_will_change!
72
- @ng_xml = Nokogiri::XML::Document.parse(new_content)
73
- super(@ng_xml.to_s.strip)
74
- end
75
- self.class.decorate_ng_xml @ng_xml
76
- end
77
-
78
- def content_changed?
79
- return true if autocreate? && new_record?
80
- return false unless xml_loaded
81
- ng_xml_changed?
82
- end
83
-
84
- def to_xml(xml = nil)
85
- xml = ng_xml if xml.nil?
86
- ng_xml = self.ng_xml
87
- if ng_xml.respond_to?(:root) && ng_xml.root.nil? && self.class.respond_to?(:root_property_ref) && !self.class.root_property_ref.nil?
88
- ng_xml = self.class.generate(self.class.root_property_ref, "")
89
- xml = ng_xml if xml.root.nil?
90
- end
91
-
92
- unless xml == ng_xml || ng_xml.root.nil?
93
- if xml.is_a?(Nokogiri::XML::Document)
94
- xml.root.add_child(ng_xml.root)
95
- elsif xml.is_a?(Nokogiri::XML::Node)
96
- xml.add_child(ng_xml.root)
97
- else
98
- raise "You can only pass instances of Nokogiri::XML::Node into this method. You passed in #{xml}"
99
- end
100
- end
101
-
102
- xml.to_xml.strip
103
- end
104
-
105
- def content
106
- @content = to_xml if ng_xml_changed? || autocreate?
107
- super
108
- end
109
-
110
- def autocreate?
111
- changed_attributes.key? :profile
112
- end
113
-
114
- def xml_loaded
115
- instance_variable_defined? :@ng_xml
116
- end
117
- end
118
- end
119
- end
@@ -1,6 +0,0 @@
1
- module ActiveFedora
2
- module Datastreams
3
- extend ActiveSupport::Autoload
4
- autoload :NokogiriDatastreams, 'active_fedora/datastreams/nokogiri_datastreams'
5
- end
6
- end
@@ -1,73 +0,0 @@
1
- require "nom"
2
-
3
- module ActiveFedora
4
- class NomDatastream < File
5
- include Datastreams::NokogiriDatastreams
6
- extend Deprecation
7
-
8
- def self.set_terminology(options = {}, &block)
9
- @terminology_options = options || {}
10
- @terminology = block
11
- end
12
-
13
- def initialize(*args)
14
- super
15
- Deprecation.warn(NomDatastream, "NomDatastream is deprecated and will be removed in ActiveFedora 11")
16
- end
17
-
18
- class << self
19
- attr_reader :terminology_options
20
- end
21
-
22
- class << self
23
- attr_reader :terminology
24
- end
25
-
26
- def self.decorate_ng_xml(xml)
27
- xml.set_terminology terminology_options, &terminology
28
- xml.nom!
29
- xml
30
- end
31
-
32
- def serialize!
33
- self.content = @ng_xml.to_s if @ng_xml
34
- end
35
-
36
- def to_solr
37
- solr_doc = {}
38
-
39
- ng_xml.terminology.flatten.select { |x| x.options[:index] }.each do |term|
40
- term.values.each do |v|
41
- Array(term.options[:index]).each do |index_as|
42
- solr_doc[index_as] ||= []
43
- solr_doc[index_as] << if v.is_a? Nokogiri::XML::Node
44
- v.text
45
- else
46
- v
47
- end
48
- end
49
- end
50
- end
51
-
52
- solr_doc
53
- end
54
-
55
- def method_missing(method, *args, &block)
56
- if ng_xml.respond_to? method
57
- ng_xml.send(method, *args, &block)
58
- else
59
- super
60
- end
61
- end
62
-
63
- def respond_to?(*args)
64
- super || self.class.terminology.respond_to?(*args)
65
- end
66
-
67
- protected
68
-
69
- def default_mime_type
70
- 'text/xml'
71
- end
72
- end
73
- end
@@ -1,118 +0,0 @@
1
- require "om"
2
-
3
- module ActiveFedora
4
- class OmDatastream < File
5
- # before_save do
6
- # if content.blank?
7
- # ActiveFedora::Base.logger.warn "Cowardly refusing to save a datastream with empty content: #{self.inspect}"
8
- # false
9
- # end
10
- # end
11
-
12
- include OM::XML::Document
13
- include OM::XML::TerminologyBasedSolrizer # this adds support for calling .to_solr
14
- include Datastreams::NokogiriDatastreams
15
- extend Deprecation
16
-
17
- alias om_term_values term_values unless method_defined?(:om_term_values)
18
- alias om_update_values update_values unless method_defined?(:om_update_values)
19
-
20
- def initialize(*args)
21
- super
22
- Deprecation.warn(OmDatastream, "OmDatastream is deprecated and will be removed in ActiveFedora 11")
23
- end
24
-
25
- def default_mime_type
26
- 'text/xml'
27
- end
28
-
29
- # Indicates that this datastream has metadata content.
30
- # @return true
31
- def metadata?
32
- true
33
- end
34
-
35
- # Return a hash suitable for indexing in solr. Every field name is prefixed with the
36
- # value returned by the +prefix+ method.
37
- def to_solr(solr_doc = {}, opts = {})
38
- prefix = self.prefix(opts[:name])
39
- solr_doc.merge super({}).each_with_object({}) { |(key, value), new| new[[prefix, key].join] = value }
40
- end
41
-
42
- # Update field values within the current datastream using {#update_values}, which is a wrapper for {http://rdoc.info/gems/om/1.2.4/OM/XML/TermValueOperators#update_values-instance_method OM::TermValueOperators#update_values}
43
- # Ignores any fields from params that this datastream's Terminology doesn't recognize
44
- #
45
- # @param [Hash] params The params specifying which fields to update and their new values. The syntax of the params Hash is the same as that expected by
46
- # term_pointers must be a valid OM Term pointers (ie. [:name]). Strings will be ignored.
47
- # @param [Hash] _opts This is not currently used by the datastream-level update_indexed_attributes method
48
- #
49
- # Example:
50
- # @mods_ds.update_indexed_attributes( {[{":person"=>"0"}, "role"]=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"} })
51
- # => {"person_0_role"=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"}}
52
- #
53
- # @mods_ds.to_xml # (the following is an approximation)
54
- # <mods>
55
- # <mods:name type="person">
56
- # <mods:role>
57
- # <mods:roleTerm>role1</mods:roleTerm>
58
- # </mods:role>
59
- # <mods:role>
60
- # <mods:roleTerm>role2</mods:roleTerm>
61
- # </mods:role>
62
- # <mods:role>
63
- # <mods:roleTerm>role3</mods:roleTerm>
64
- # </mods:role>
65
- # </mods:name>
66
- # </mods>
67
- def update_indexed_attributes(params = {}, _opts = {})
68
- if self.class.terminology.nil?
69
- raise "No terminology is set for this OmDatastream class. Cannot perform update_indexed_attributes"
70
- end
71
- # remove any fields from params that this datastream doesn't recognize
72
- # make sure to make a copy of params so not to modify hash that might be passed to other methods
73
- current_params = params.clone
74
- current_params.delete_if do |term_pointer, new_values|
75
- if term_pointer.is_a?(String)
76
- ActiveFedora::Base.logger.warn "WARNING: #{self.class.name} ignoring {#{term_pointer.inspect} => #{new_values.inspect}} because #{term_pointer.inspect} is a String (only valid OM Term Pointers will be used). Make sure your html has the correct field_selector tags in it." if ActiveFedora::Base.logger
77
- true
78
- else
79
- !self.class.terminology.has_term?(*OM.destringify(term_pointer))
80
- end
81
- end
82
-
83
- result = {}
84
- result = update_values(current_params) unless current_params.empty?
85
-
86
- result
87
- end
88
-
89
- def get_values(field_key, _default = [])
90
- term_values(*field_key)
91
- end
92
-
93
- def find_by_terms(*termpointer)
94
- super
95
- end
96
-
97
- # Update values in the datastream's xml
98
- # This wraps {http://rdoc.info/gems/om/1.2.4/OM/XML/TermValueOperators#update_values-instance_method OM::TermValueOperators#update_values} so that returns an error if we have loaded from solr since datastreams loaded that way should be read-only
99
- #
100
- # @example Updating multiple values with a Hash of Term pointers and values
101
- # ds.update_values( {[{":person"=>"0"}, "role", "text"]=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"}, [{:person=>1}, :family_name]=>"Andronicus", [{"person"=>"1"},:given_name]=>["Titus"],[{:person=>1},:role,:text]=>["otherrole1","otherrole2"] } )
102
- # => {"person_0_role_text"=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"}, "person_1_role_text"=>{"0"=>"otherrole1", "1"=>"otherrole2"}}
103
- def update_values(params = {})
104
- raise "can't modify frozen #{self.class}" if frozen?
105
- ng_xml_will_change!
106
- result = om_update_values(params)
107
- result
108
- end
109
-
110
- protected
111
-
112
- # The string to prefix all solr fields with. Override this method if you want
113
- # a prefix other than the default
114
- def prefix(path)
115
- path ? "#{path.underscore}__" : ''
116
- end
117
- end
118
- end
@@ -1,11 +0,0 @@
1
- module ActiveFedora
2
- class ProfileIndexingService
3
- def initialize(object)
4
- @object = object
5
- end
6
-
7
- def export
8
- @object.serializable_hash.to_json
9
- end
10
- end
11
- end
@@ -1,158 +0,0 @@
1
- module ActiveFedora
2
- # This class represents a Qualified Dublin Core Datastream. A special case of ActiveFedora::OmDatastream
3
- # The implementation of this class defines the terms from the Qualified Dublin Core specification.
4
- # This implementation features customized xml generators and deserialization routines to handle the
5
- # Fedora Dublin Core XML datastreams structure.
6
- #
7
- # Fields can still be overridden if more specificity is desired (see ActiveFedora::File#fields method).
8
- class QualifiedDublinCoreDatastream < OmDatastream
9
- attr_accessor :fields
10
- class_attribute :class_fields
11
- self.class_fields = []
12
-
13
- set_terminology do |t|
14
- t.root(path: "dc", xmlns: "http://purl.org/dc/terms/")
15
- end
16
-
17
- define_template :creator do |xml, name|
18
- xml.creator do
19
- xml.text(name)
20
- end
21
- end
22
-
23
- # A frozen array of Dublincore Terms.
24
- DCTERMS = [
25
- :abstract,
26
- :accessRights,
27
- :accrualMethod,
28
- :accrualPeriodicity,
29
- :accrualPolicy,
30
- :alternative,
31
- :audience,
32
- :available,
33
- :bibliographicCitation,
34
- :conformsTo,
35
- :contributor,
36
- :coverage,
37
- :created,
38
- :creator,
39
- :date,
40
- :dateAccepted,
41
- :dateCopyrighted,
42
- :dateSubmitted,
43
- :description,
44
- :educationLevel,
45
- :extent,
46
- :hasFormat,
47
- :hasPart,
48
- :hasVersion,
49
- :identifier,
50
- :instructionalMethod,
51
- :isFormatOf,
52
- :isPartOf,
53
- :isReferencedBy,
54
- :isReplacedBy,
55
- :isRequiredBy,
56
- :isVersionOf,
57
- :issued,
58
- :language,
59
- :license,
60
- :mediator,
61
- :medium,
62
- :modified,
63
- :provenance,
64
- :publisher,
65
- :references,
66
- :relation,
67
- :replaces,
68
- :requires,
69
- :rights,
70
- :rightsHolder,
71
- :source,
72
- :spatial,
73
- :subject,
74
- :tableOfContents,
75
- :temporal,
76
- :title,
77
- :type,
78
- :valid
79
- ].freeze # removed :format
80
- DCTERMS.freeze
81
-
82
- # Constructor. this class will call self.field for each DCTERM. In short, all DCTERMS fields will already exist
83
- # when this method returns. Each term is marked as a multivalue string.
84
- def initialize(string_or_url = nil)
85
- super
86
- self.fields = {}
87
- DCTERMS.each do |el|
88
- field el, :string, multiple: true
89
- end
90
- end
91
-
92
- # This method generates the various accessor and mutator methods on self for the datastream metadata attributes.
93
- # each field will have the 2 magic methods:
94
- # name=(arg)
95
- # name
96
- #
97
- #
98
- # Calling any of the generated methods marks self as dirty.
99
- #
100
- # 'tupe' is a datatype, currently :string, :text and :date are supported.
101
- #
102
- # opts is an options hash, which will affect the generation of the xml representation of this datastream.
103
- #
104
- # Currently supported modifiers:
105
- # For +QualifiedDublinCorDatastreams+:
106
- # :element_attrs =>{:foo=>:bar} - hash of xml element attributes
107
- # :xml_node => :nodename - The xml node to be used to represent this object (in dcterms namespace)
108
- # :encoding=>foo, or encodings_scheme - causes an xsi:type attribute to be set to 'foo'
109
- # :multiple=>true - mark this field as a multivalue field (on by default)
110
- #
111
- #
112
- # There is quite a good example of this class in use in spec/examples/oral_history.rb
113
- #
114
- # !! Careful: If you declare two fields that correspond to the same xml node without any qualifiers to differentiate them,
115
- # you will end up replicating the values in the underlying datastream, resulting in mysterious dubling, quadrupling, etc.
116
- # whenever you edit the field's values.
117
- def field(name, tupe = nil, opts = {})
118
- @fields[name.to_s.to_sym] = { type: tupe, values: [] }.merge(opts)
119
- # add term to template
120
- self.class.class_fields << name.to_s
121
- # add term to terminology
122
- return if self.class.terminology.has_term?(name.to_sym)
123
- om_term_opts = { xmlns: "http://purl.org/dc/terms/", namespace_prefix: "dcterms", path: opts[:path] }
124
- term = OM::XML::Term.new(name.to_sym, om_term_opts, self.class.terminology)
125
- self.class.terminology.add_term(term)
126
- term.generate_xpath_queries!
127
- end
128
-
129
- def update_indexed_attributes(params = {}, opts = {})
130
- # if the params are just keys, not an array, make then into an array.
131
- new_params = {}
132
- params.each do |key, val|
133
- if key.is_a? Array
134
- new_params[key] = val
135
- else
136
- new_params[[key.to_sym]] = val
137
- end
138
- end
139
- super(new_params, opts)
140
- end
141
-
142
- def self.xml_template
143
- Nokogiri::XML::Document.parse("<dc xmlns:dcterms='http://purl.org/dc/terms/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'/>")
144
- end
145
-
146
- def to_solr(solr_doc = {}, _opts = {}) # :nodoc:
147
- @fields.each do |field_key, field_info|
148
- things = send(field_key)
149
- next unless things
150
- field_symbol = ActiveFedora.index_field_mapper.solr_name(field_key, type: field_info[:type])
151
- things.val.each do |val|
152
- ::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val)
153
- end
154
- end
155
- solr_doc
156
- end
157
- end
158
- end
@@ -1,49 +0,0 @@
1
- module ActiveFedora::RDF
2
- module DatastreamIndexing
3
- extend ActiveSupport::Concern
4
-
5
- def to_solr(solr_doc = {}, opts = {}) # :nodoc:
6
- super.tap do |new_doc|
7
- solrize_rdf_assertions(opts[:name], new_doc)
8
- end
9
- end
10
-
11
- module ClassMethods
12
- def indexer
13
- ActiveFedora::RDF::IndexingService
14
- end
15
-
16
- def index_config
17
- @index_config ||= ActiveFedora::Indexing::Map.new
18
- end
19
- end
20
-
21
- protected
22
-
23
- def indexing_service
24
- @indexing_service ||= self.class.indexer.new(self)
25
- end
26
-
27
- # Serialize the datastream's RDF relationships to solr
28
- # @param [String] file_path used to prefix the keys in the solr document
29
- # @param [Hash] solr_doc @default an empty Hash
30
- def solrize_rdf_assertions(file_path, solr_doc = {})
31
- solr_doc.merge! indexing_service.generate_solr_document(prefix_method(file_path))
32
- end
33
-
34
- # Returns a function that takes field name and returns a solr document key
35
- def prefix_method(file_path)
36
- ->(field_name) { apply_prefix(field_name, file_path) }
37
- end
38
-
39
- def apply_prefix(name, file_path)
40
- prefix(file_path) + name.to_s
41
- end
42
-
43
- # The string to prefix all solr fields with. Override this method if you want
44
- # a prefix other than the default
45
- def prefix(path)
46
- path ? "#{path.underscore}__" : ''
47
- end
48
- end
49
- end
@@ -1,13 +0,0 @@
1
- require 'rdf/ntriples'
2
-
3
- module ActiveFedora
4
- class NtriplesRDFDatastream < RDFDatastream
5
- def serialization_format
6
- :ntriples
7
- end
8
-
9
- def deprecation_warning
10
- Deprecation.warn(NtriplesRDFDatastream, "NtriplesRDFDatastream is deprecated and will be removed in ActiveFedora 11", caller(2))
11
- end
12
- end
13
- end