active-fedora 9.0.0.beta2 → 9.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/config/jetty.yml +1 -1
  3. data/lib/active_fedora.rb +11 -3
  4. data/lib/active_fedora/associations/association_scope.rb +2 -2
  5. data/lib/active_fedora/associations/belongs_to_association.rb +2 -2
  6. data/lib/active_fedora/associations/collection_association.rb +13 -13
  7. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +2 -2
  8. data/lib/active_fedora/associations/rdf.rb +2 -2
  9. data/lib/active_fedora/cleaner.rb +2 -6
  10. data/lib/active_fedora/fedora.rb +18 -0
  11. data/lib/active_fedora/fedora_attributes.rb +4 -4
  12. data/lib/active_fedora/file.rb +7 -0
  13. data/lib/active_fedora/fixity_service.rb +9 -1
  14. data/lib/active_fedora/indexing_service.rb +2 -7
  15. data/lib/active_fedora/loadable_from_json.rb +4 -0
  16. data/lib/active_fedora/om_datastream.rb +0 -4
  17. data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
  18. data/lib/active_fedora/query_result_builder.rb +56 -0
  19. data/lib/active_fedora/querying.rb +1 -1
  20. data/lib/active_fedora/rdf.rb +2 -1
  21. data/lib/active_fedora/rdf/fcrepo.rb +323 -9
  22. data/lib/active_fedora/rdf/fcrepo4.rb +7 -0
  23. data/lib/active_fedora/rdf/indexing.rb +1 -1
  24. data/lib/active_fedora/rdf/project_hydra.rb +12 -0
  25. data/lib/active_fedora/reflection.rb +4 -1
  26. data/lib/active_fedora/relation/finder_methods.rb +4 -4
  27. data/lib/active_fedora/simple_datastream.rb +11 -12
  28. data/lib/active_fedora/solr_instance_loader.rb +1 -1
  29. data/lib/active_fedora/solr_query_builder.rb +57 -0
  30. data/lib/active_fedora/solr_service.rb +22 -48
  31. data/lib/active_fedora/version.rb +1 -1
  32. data/lib/active_fedora/versionable.rb +12 -13
  33. data/spec/integration/associations_spec.rb +6 -6
  34. data/spec/integration/attributes_spec.rb +22 -6
  35. data/spec/integration/base_spec.rb +2 -2
  36. data/spec/integration/collection_association_spec.rb +9 -0
  37. data/spec/integration/file_spec.rb +30 -0
  38. data/spec/integration/full_featured_model_spec.rb +1 -1
  39. data/spec/integration/ntriples_datastream_spec.rb +5 -5
  40. data/spec/integration/om_datastream_spec.rb +1 -1
  41. data/spec/integration/{solr_service_spec.rb → query_result_builder_spec.rb} +5 -7
  42. data/spec/integration/relation_delegation_spec.rb +3 -3
  43. data/spec/integration/scoped_query_spec.rb +11 -11
  44. data/spec/integration/solr_instance_loader_spec.rb +8 -0
  45. data/spec/integration/versionable_spec.rb +32 -14
  46. data/spec/unit/base_spec.rb +3 -3
  47. data/spec/unit/indexing_service_spec.rb +2 -2
  48. data/spec/unit/ntriples_datastream_spec.rb +16 -16
  49. data/spec/unit/om_datastream_spec.rb +7 -7
  50. data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
  51. data/spec/unit/query_result_builder_spec.rb +39 -0
  52. data/spec/unit/query_spec.rb +2 -2
  53. data/spec/unit/rdf_vocab_spec.rb +30 -0
  54. data/spec/unit/simple_datastream_spec.rb +2 -2
  55. data/spec/unit/solr_config_options_spec.rb +1 -1
  56. data/spec/unit/solr_query_builder_spec.rb +20 -0
  57. data/spec/unit/solr_service_spec.rb +2 -53
  58. metadata +11 -4
@@ -0,0 +1,7 @@
1
+ require 'rdf'
2
+ module ActiveFedora::RDF
3
+ class Fcrepo4 < RDF::StrictVocabulary("http://fedora.info/definitions/v4/repository#")
4
+ property :created
5
+ property :lastModified
6
+ end
7
+ end
@@ -32,7 +32,7 @@ module ActiveFedora
32
32
  return nil unless config # punt on index names for deep nodes!
33
33
  if behaviors = config.behaviors
34
34
  behaviors.each do |behavior|
35
- result = ActiveFedora::SolrService.solr_name(apply_prefix(field, file_path), behavior, type: config.type)
35
+ result = ActiveFedora::SolrQueryBuilder.solr_name(apply_prefix(field, file_path), behavior, type: config.type)
36
36
  return result if Solrizer::DefaultDescriptors.send(behavior).evaluate_suffix(:text).stored?
37
37
  end
38
38
  raise RuntimeError "no stored fields were found"
@@ -0,0 +1,12 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rdf'
3
+ class ActiveFedora::RDF::ProjectHydra < ::RDF::StrictVocabulary("http://projecthydra.org/ns/relations#")
4
+ property :hasProfile,
5
+ label: "Has Profile".freeze,
6
+ subPropertyOf: "info:fedora/fedora-system:def/relations-external#fedoraRelationship".freeze,
7
+ type: "rdf:Property".freeze
8
+ property :isGovernedBy,
9
+ label: "Is Governed By".freeze,
10
+ subPropertyOf: "info:fedora/fedora-system:def/relations-external#fedoraRelationship".freeze,
11
+ type: "rdf:Property".freeze
12
+ end
@@ -192,7 +192,10 @@ module ActiveFedora
192
192
  end
193
193
 
194
194
  def solr_key
195
- ActiveFedora::SolrService.solr_name(predicate.to_s, :symbol)
195
+ @solr_key ||= begin
196
+ predicate_string = predicate.fragment || predicate.to_s.rpartition(/\//).last
197
+ ActiveFedora::SolrQueryBuilder.solr_name(predicate_string, :symbol)
198
+ end
196
199
  end
197
200
 
198
201
  def check_validity!
@@ -178,7 +178,7 @@ module ActiveFedora
178
178
  if where_values.empty?
179
179
  load_from_fedora(id, cast)
180
180
  else
181
- conditions = where_values + [ActiveFedora::SolrService.raw_query(SOLR_DOCUMENT_ID, id)]
181
+ conditions = where_values + [ActiveFedora::SolrQueryBuilder.raw_query(SOLR_DOCUMENT_ID, id)]
182
182
  query = conditions.join(" AND ".freeze)
183
183
  to_enum(:find_each, query, {}).to_a.first
184
184
  end
@@ -204,7 +204,7 @@ module ActiveFedora
204
204
 
205
205
  # TODO just use has_model
206
206
  def has_model_value(resource)
207
- Ldp::Orm.new(resource).value(::RDF::URI.new("http://fedora.info/definitions/v4/rels-ext#hasModel")).first.to_s
207
+ Ldp::Orm.new(resource).value(ActiveFedora::RDF::Fcrepo::Model.hasModel).first.to_s
208
208
  end
209
209
 
210
210
  def find_with_ids(ids, cast)
@@ -259,7 +259,7 @@ module ActiveFedora
259
259
  # if the key is a property name, turn it into a solr field
260
260
  if @klass.delegated_attributes.key?(key)
261
261
  # TODO Check to see if `key' is a possible solr field for this class, if it isn't try :searchable instead
262
- key = ActiveFedora::SolrService.solr_name(key, :stored_searchable, type: :string)
262
+ key = ActiveFedora::SolrQueryBuilder.solr_name(key, :stored_searchable, type: :string)
263
263
  end
264
264
 
265
265
  if value.empty?
@@ -278,7 +278,7 @@ module ActiveFedora
278
278
  # The concrete class could could be any subclass of @klass or @klass itself
279
279
  unless @klass == ActiveFedora::Base
280
280
  clauses = ([@klass] + @klass.descendants).map do |k|
281
- ActiveFedora::SolrService.construct_query_for_rel(has_model: k.to_s)
281
+ ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: k.to_s)
282
282
  end
283
283
  clauses.size == 1 ? clauses.first : "(#{clauses.join(" OR ")})"
284
284
  end
@@ -27,15 +27,15 @@ module ActiveFedora
27
27
 
28
28
  # This method generates the various accessor and mutator methods on self for the datastream metadata attributes.
29
29
  # each field will have the 2 magic methods:
30
- # name=(arg)
31
- # name
30
+ # name=(arg)
31
+ # name
32
32
  #
33
33
  #
34
34
  # 'datatype' is a datatype, currently :string, :integer and :date are supported.
35
35
  #
36
36
  # opts is an options hash, which will affect the generation of the xml representation of this datastream.
37
37
  #
38
- # Currently supported modifiers:
38
+ # Currently supported modifiers:
39
39
  # For +SimpleDatastream+:
40
40
  # :element_attrs =>{:foo=>:bar} - hash of xml element attributes
41
41
  # :xml_node => :nodename - The xml node to be used to represent this object (in dcterms namespace)
@@ -45,8 +45,8 @@ module ActiveFedora
45
45
  #
46
46
  #There is quite a good example of this class in use in spec/examples/oral_history.rb
47
47
  #
48
- #!! Careful: If you declare two fields that correspond to the same xml node without any qualifiers to differentiate them,
49
- #you will end up replicating the values in the underlying datastream, resulting in mysterious dubling, quadrupling, etc.
48
+ #!! Careful: If you declare two fields that correspond to the same xml node without any qualifiers to differentiate them,
49
+ #you will end up replicating the values in the underlying datastream, resulting in mysterious dubling, quadrupling, etc.
50
50
  #whenever you edit the field's values.
51
51
  def field(name, datatype=:string, opts={})
52
52
  fields ||= {}
@@ -59,9 +59,8 @@ module ActiveFedora
59
59
  self.class.terminology.add_term(term)
60
60
  term.generate_xpath_queries!
61
61
  end
62
-
63
62
  end
64
-
63
+
65
64
  def update_indexed_attributes(params={}, opts={})
66
65
  raise "can't modify frozen #{self.class}" if frozen?
67
66
  # if the params are just keys, not an array, make then into an array.
@@ -75,7 +74,7 @@ module ActiveFedora
75
74
  end
76
75
  super(new_params, opts)
77
76
  end
78
-
77
+
79
78
 
80
79
  def self.xml_template
81
80
  Nokogiri::XML::Document.parse("<fields/>")
@@ -85,10 +84,10 @@ module ActiveFedora
85
84
  @fields.each do |field_key, field_info|
86
85
  next if field_key == :location ## FIXME HYDRA-825
87
86
  things = send(field_key)
88
- if things
89
- field_symbol = ActiveFedora::SolrService.solr_name(field_key, type: field_info[:type])
90
- things.val.each do |val|
91
- ::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val.to_s )
87
+ if things
88
+ field_symbol = ActiveFedora::SolrQueryBuilder.solr_name(field_key, type: field_info[:type])
89
+ things.val.each do |val|
90
+ ::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val.to_s )
92
91
  end
93
92
  end
94
93
  end
@@ -51,7 +51,7 @@ module ActiveFedora
51
51
  end
52
52
 
53
53
  def active_fedora_class
54
- @active_fedora_class ||= ActiveFedora::SolrService.class_from_solr_document(solr_doc)
54
+ @active_fedora_class ||= ActiveFedora::QueryResultBuilder.class_from_solr_document(solr_doc)
55
55
  end
56
56
 
57
57
  def profile_json
@@ -0,0 +1,57 @@
1
+ module ActiveFedora
2
+ module SolrQueryBuilder
3
+ # Construct a solr query for a list of ids
4
+ # This is used to get a solr response based on the list of ids in an object's RELS-EXT relationhsips
5
+ # If the id_array is empty, defaults to a query of "id:NEVER_USE_THIS_ID", which will return an empty solr response
6
+ # @param [Array] id_array the ids that you want included in the query
7
+ def self.construct_query_for_ids(id_array)
8
+ q = id_array.reject { |x| x.blank? }.map { |id| raw_query(SOLR_DOCUMENT_ID, id) }
9
+ q.empty? ? "id:NEVER_USE_THIS_ID" : q.join(" OR ".freeze)
10
+ end
11
+
12
+ # Create a raw query clause suitable for sending to solr as an fq element
13
+ # @param [String] key
14
+ # @param [String] value
15
+ def self.raw_query(key, value)
16
+ "_query_:\"{!raw f=#{key}}#{value.gsub('"', '\"')}\""
17
+ end
18
+
19
+ def self.solr_name(*args)
20
+ Solrizer.default_field_mapper.solr_name(*args)
21
+ end
22
+
23
+ # Create a query with a clause for each key, value
24
+ # @param [Hash, Array<Array<String>>] args key is the predicate, value is the target_uri
25
+ # @param [String] join_with ('AND') the value we're joining the clauses with
26
+ # @example
27
+ # construct_query_for_rel [[:has_model, "info:fedora/afmodel:ComplexCollection"], [:has_model, "info:fedora/afmodel:ActiveFedora_Base"]], 'OR'
28
+ # # => _query_:"{!raw f=has_model_ssim}info:fedora/afmodel:ComplexCollection" OR _query_:"{!raw f=has_model_ssim}info:fedora/afmodel:ActiveFedora_Base"
29
+ #
30
+ # construct_query_for_rel [[Book.reflect_on_association(:library), "foo/bar/baz"]]
31
+ def self.construct_query_for_rel(field_pairs, join_with = 'AND')
32
+ field_pairs = field_pairs.to_a if field_pairs.kind_of? Hash
33
+
34
+ clauses = pairs_to_clauses(field_pairs.reject { |_, target_uri| target_uri.blank? })
35
+ clauses.empty? ? "id:NEVER_USE_THIS_ID" : clauses.join(" #{join_with} ".freeze)
36
+ end
37
+
38
+ private
39
+ # Given an list of 2 element lists, transform to a list of solr clauses
40
+ def self.pairs_to_clauses(pairs)
41
+ pairs.map do |field, target_uri|
42
+ raw_query(solr_field(field), target_uri)
43
+ end
44
+ end
45
+
46
+ # @param [String, ActiveFedora::Relation] field
47
+ # @return [String] the corresponding solr field for the string
48
+ def self.solr_field(field)
49
+ case field
50
+ when ActiveFedora::Reflection::AssociationReflection
51
+ field.solr_key
52
+ else
53
+ solr_name(field, :symbol)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -35,55 +35,30 @@ module ActiveFedora
35
35
  end
36
36
 
37
37
  def lazy_reify_solr_results(solr_results, opts = {})
38
- Enumerator.new do |yielder|
39
- solr_results.each do |hit|
40
- yielder.yield(reify_solr_result(hit, opts))
41
- end
42
- end
38
+ Deprecation.warn SolrService, "SolrService.lazy_reify_solr_results is deprecated. Use QueryResultBuilder.lazy_reify_solr_results instead. This will be removed in active-fedora 10.0"
39
+ QueryResultBuilder.lazy_reify_solr_results(solr_results, opts)
43
40
  end
44
41
 
45
42
  def reify_solr_results(solr_results, opts = {})
46
- solr_results.collect {|hit| reify_solr_result(hit, opts)}
43
+ Deprecation.warn SolrService, "SolrService.reify_solr_results is deprecated. Use QueryResultBuilder.reify_solr_results instead. This will be removed in active-fedora 10.0"
44
+ QueryResultBuilder.reify_solr_results(solr_results, opts)
47
45
  end
48
46
 
49
47
  def reify_solr_result(hit, opts = {})
50
- klass = class_from_solr_document(hit)
51
- klass.find(hit[SOLR_DOCUMENT_ID], cast: true)
48
+ Deprecation.warn SolrService, "SolrService.reify_solr_result is deprecated. Use QueryResultBuilder.reify_solr_result instead. This will be removed in active-fedora 10.0"
49
+ QueryResultBuilder.reify_solr_result(hit, opts)
52
50
  end
53
51
 
54
52
  #Returns all possible classes for the solr object
55
53
  def classes_from_solr_document(hit, opts = {})
56
- #Add ActiveFedora::Base as never stored in Solr explicitely.
57
- #classes = [ActiveFedora::Base]
58
- classes = []
59
-
60
- hit[HAS_MODEL_SOLR_FIELD].each { |value| classes << Model.from_class_uri(value) }
61
-
62
- classes.compact
54
+ Deprecation.warn SolrService, "SolrService.classes_from_solr_document is deprecated. Use QueryResultBuilder.classes_from_solr_document instead. This will be removed in active-fedora 10.0"
55
+ QueryResultBuilder.classes_from_solr_document(hit, opts)
63
56
  end
64
57
 
65
58
  #Returns the best singular class for the solr object
66
59
  def class_from_solr_document(hit, opts = {})
67
- #Set the default starting point to the class specified, if available.
68
- best_model_match = Model.from_class_uri(opts[:class]) unless opts[:class].nil?
69
- Array(hit[HAS_MODEL_SOLR_FIELD]).each do |value|
70
-
71
- model_value = Model.from_class_uri(value)
72
-
73
- if model_value
74
-
75
- # Set as the first model in case opts[:class] was nil
76
- best_model_match ||= model_value
77
-
78
- # If there is an inheritance structure, use the most specific case.
79
- if best_model_match > model_value
80
- best_model_match = model_value
81
- end
82
- end
83
- end
84
-
85
- ActiveFedora::Base.logger.warn "Could not find a model for #{hit["id"]}, defaulting to ActiveFedora::Base" unless best_model_match if ActiveFedora::Base.logger
86
- best_model_match || ActiveFedora::Base
60
+ Deprecation.warn SolrService, "SolrService.class_from_solr_document is deprecated. Use QueryResultBuilder.class_from_solr_document instead. This will be removed in active-fedora 10.0"
61
+ QueryResultBuilder.class_from_solr_document(hit, opts)
87
62
  end
88
63
 
89
64
  # Construct a solr query for a list of ids
@@ -91,24 +66,26 @@ module ActiveFedora
91
66
  # If the id_array is empty, defaults to a query of "id:NEVER_USE_THIS_ID", which will return an empty solr response
92
67
  # @param [Array] id_array the ids that you want included in the query
93
68
  def construct_query_for_ids(id_array)
94
- q = id_array.reject { |x| x.blank? }.map { |id| raw_query(SOLR_DOCUMENT_ID, id) }
95
- q.empty? ? "id:NEVER_USE_THIS_ID" : q.join(" OR ".freeze)
69
+ Deprecation.warn SolrService, "SolrService.construct_query_for_ids is deprecated. Use SolrQueryBuilder.construct_query_for_ids instead. This will be removed in active-fedora 10.0"
70
+ SolrQueryBuilder.construct_query_for_ids(id_array)
96
71
  end
97
72
 
98
73
  def construct_query_for_pids(id_array)
99
74
  Deprecation.warn SolrService, "construct_query_for_pids is deprecated and will be removed in active-fedora 10.0"
100
- construct_query_for_ids(id_array)
75
+ SolrQueryBuilder.construct_query_for_ids(id_array)
101
76
  end
102
77
 
103
78
  # Create a raw query clause suitable for sending to solr as an fq element
104
79
  # @param [String] key
105
80
  # @param [String] value
106
81
  def raw_query(key, value)
107
- "_query_:\"{!raw f=#{key}}#{value.gsub('"', '\"')}\""
82
+ Deprecation.warn SolrService, "SolrService.raw_query is deprecated. Use SolrQueryBuilder.raw_query instead. This will be removed in active-fedora 10.0"
83
+ SolrQueryBuilder.raw_query(key, value)
108
84
  end
109
85
 
110
86
  def solr_name(*args)
111
- Solrizer.default_field_mapper.solr_name(*args)
87
+ Deprecation.warn SolrService, "SolrService.solr_name is deprecated. Use SolrQueryBuilder.solr_name instead. This will be removed in active-fedora 10.0"
88
+ SolrQueryBuilder.solr_name(*args)
112
89
  end
113
90
 
114
91
  # Create a query with a clause for each key, value
@@ -117,12 +94,11 @@ module ActiveFedora
117
94
  # @example
118
95
  # construct_query_for_rel [[:has_model, "info:fedora/afmodel:ComplexCollection"], [:has_model, "info:fedora/afmodel:ActiveFedora_Base"]], 'OR'
119
96
  # # => _query_:"{!raw f=has_model_ssim}info:fedora/afmodel:ComplexCollection" OR _query_:"{!raw f=has_model_ssim}info:fedora/afmodel:ActiveFedora_Base"
97
+ #
98
+ # construct_query_for_rel [[Book.reflect_on_association(:library), "foo/bar/baz"]]
120
99
  def construct_query_for_rel(field_pairs, join_with = 'AND')
121
- field_pairs = field_pairs.to_a if field_pairs.kind_of? Hash
122
-
123
- clauses = field_pairs.reject{ |_, target_uri| target_uri.blank? }.
124
- map { |predicate, target_uri| raw_query(solr_name(predicate, :symbol), target_uri) }
125
- clauses.empty? ? "id:NEVER_USE_THIS_ID" : clauses.join(" #{join_with} ".freeze)
100
+ Deprecation.warn SolrService, "SolrService.construct_query_for_rel is deprecated. Use SolrQueryBuilder.construct_query_for_rel instead. This will be removed in active-fedora 10.0"
101
+ SolrQueryBuilder.construct_query_for_rel(field_pairs, join_with)
126
102
  end
127
103
 
128
104
  def query(query, args={})
@@ -157,10 +133,8 @@ module ActiveFedora
157
133
  def commit
158
134
  SolrService.instance.conn.commit
159
135
  end
160
- end
161
-
162
- HAS_MODEL_SOLR_FIELD = solr_name("has_model", :symbol).freeze
163
136
 
137
+ end
164
138
  end #SolrService
165
139
  class SolrNotInitialized < StandardError;end
166
140
  end #ActiveFedora
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "9.0.0.beta2"
2
+ VERSION = "9.0.0.beta3"
3
3
  end
@@ -20,23 +20,18 @@ module ActiveFedora
20
20
  end
21
21
  end
22
22
 
23
- # Returns an array of RDF::Literal objects where the version label matches
24
- # our own version label and excludes auto-snapshot versions from Fedora.
23
+ # Returns an array of uris matching our own version label, excluding auto-snapshot versions from Fedora.
25
24
  def versions
26
25
  results = versions_graph.query([nil, ::RDF::URI.new('http://fedora.info/definitions/v4/repository#hasVersionLabel'), nil])
27
- numbered_versions(results)
26
+ numbered_versions(results).map { |v| version_uri(v.to_s) }
28
27
  end
29
28
 
30
29
  def versions_graph
31
30
  @versions_graph ||= ::RDF::Graph.new << ::RDF::Reader.for(:ttl).new(versions_request)
32
31
  end
33
32
 
34
- def versions_url
35
- uri + '/fcr:versions'
36
- end
37
-
38
33
  def create_version
39
- resp = ActiveFedora.fedora.connection.post(versions_url, nil, {slug: version_name})
34
+ resp = ActiveFedora.fedora.connection.post(versions_uri, nil, {slug: version_name})
40
35
  @versions_graph = nil
41
36
  resp.success?
42
37
  end
@@ -44,14 +39,14 @@ module ActiveFedora
44
39
  # This method does not rely on the internal versionable flag of the object, instead
45
40
  # it queries Fedora directly to figure out if there are versions for the resource.
46
41
  def has_versions?
47
- ActiveFedora.fedora.connection.head(versions_url)
42
+ ActiveFedora.fedora.connection.head(versions_uri)
48
43
  true
49
44
  rescue Ldp::NotFound
50
45
  false
51
46
  end
52
47
 
53
48
  def restore_version label
54
- resp = ActiveFedora.fedora.connection.patch(version_url(label), nil)
49
+ resp = ActiveFedora.fedora.connection.patch(version_uri(label), nil)
55
50
  @versions_graph = nil
56
51
  reload
57
52
  refresh_attributes if self.respond_to?("refresh_attributes")
@@ -62,7 +57,7 @@ module ActiveFedora
62
57
 
63
58
  def versions_request
64
59
  resp = begin
65
- ActiveFedora.fedora.connection.get(versions_url)
60
+ ActiveFedora.fedora.connection.get(versions_uri)
66
61
  rescue Ldp::NotFound
67
62
  return ''
68
63
  end
@@ -74,10 +69,14 @@ module ActiveFedora
74
69
  resp.body
75
70
  end
76
71
 
77
- def version_url label
78
- versions_url + '/' + label
72
+ def versions_uri
73
+ uri + '/fcr:versions'
79
74
  end
80
75
 
76
+ def version_uri label
77
+ versions_uri + '/' + label
78
+ end
79
+
81
80
  def version_name
82
81
  if versions.empty?
83
82
  "version1"
@@ -483,8 +483,8 @@ describe ActiveFedora::Base do
483
483
  Object.send(:remove_const, :MediaObject)
484
484
  end
485
485
 
486
- it "it should find the predicate" do
487
- expect(MediaObject.new.association(:baubles).send(:find_predicate)).to eq 'http://fedora.info/definitions/v4/rels-ext#isPartOf'
486
+ it "it should find the reflection that bears the predicate" do
487
+ expect(MediaObject.new.association(:baubles).send(:find_reflection)).to eq Bauble.reflect_on_association(:media_object)
488
488
  end
489
489
  end
490
490
 
@@ -503,8 +503,8 @@ describe ActiveFedora::Base do
503
503
  Object.send(:remove_const, :MediaObject)
504
504
  end
505
505
 
506
- it "it should find the predicate" do
507
- expect(MediaObject.new.association(:parts).send(:find_predicate)).to eq 'http://fedora.info/definitions/v4/rels-ext#isPartOf'
506
+ it "it should find the reflection that bears the predicate" do
507
+ expect(MediaObject.new.association(:parts).send(:find_reflection)).to eq MasterFile.reflect_on_association(:media_object)
508
508
  end
509
509
  end
510
510
 
@@ -523,8 +523,8 @@ describe ActiveFedora::Base do
523
523
  Object.send(:remove_const, :MediaObject)
524
524
  end
525
525
 
526
- it "it should find the predicate" do
527
- expect(MediaObject.new.association(:baubles).send(:find_predicate)).to eq 'http://fedora.info/definitions/v4/rels-ext#hasEquivalent'
526
+ it "it should find the reflection that bears the predicate" do
527
+ expect(MediaObject.new.association(:baubles).send(:find_reflection)).to eq MediaObject.reflect_on_association(:baubles)
528
528
  end
529
529
  end
530
530
 
@@ -6,6 +6,7 @@ describe "delegating attributes" do
6
6
  set_terminology do |t|
7
7
  t.root(path: "fields")
8
8
  t.depositor index_as: [:symbol, :stored_searchable]
9
+ t.wrangler index_as: [:facetable]
9
10
  end
10
11
  end
11
12
  class TitledObject < ActiveFedora::Base
@@ -17,6 +18,7 @@ describe "delegating attributes" do
17
18
  class RdfObject < ActiveFedora::Base
18
19
  contains 'foo', class_name: 'PropertiesDatastream'
19
20
  has_attributes :depositor, datastream: :foo, multiple: false
21
+ has_attributes :wrangler, datastream: :foo, multiple: true
20
22
  property :resource_type, predicate: ::RDF::DC.type do |index|
21
23
  index.as :stored_searchable, :facetable
22
24
  end
@@ -47,7 +49,7 @@ describe "delegating attributes" do
47
49
  end
48
50
  end
49
51
 
50
- context "with an rdf property" do
52
+ context "with multiple datastreams" do
51
53
 
52
54
  subject { RdfObject.create }
53
55
 
@@ -71,22 +73,36 @@ describe "delegating attributes" do
71
73
  end
72
74
 
73
75
  describe "setting attributes" do
74
-
75
- after do
76
- expect(subject.depositor).to eql("foo")
77
- expect(subject.resource_type).to eql(["bar"])
78
- end
76
+
79
77
  specify "using strings for keys" do
80
78
  subject["depositor"] = "foo"
81
79
  subject["resource_type"] = "bar"
82
80
  subject.save
81
+ expect(subject.depositor).to eql("foo")
82
+ expect(subject.resource_type).to eql(["bar"])
83
83
  end
84
84
  specify "using symbols for keys" do
85
85
  subject[:depositor] = "foo"
86
86
  subject[:resource_type] = "bar"
87
87
  subject.save
88
+ expect(subject.depositor).to eql("foo")
89
+ expect(subject.resource_type).to eql(["bar"])
88
90
  end
89
91
 
92
+ # TODO: bug logged in issue #540
93
+ describe "using shift", pending: "has_changed? not returning true" do
94
+ specify "with rdf properties" do
95
+ subject.resource_type << "bar"
96
+ subject.save
97
+ expect(subject.resource_type).to eql(["bar"])
98
+ end
99
+ specify "with om terms" do
100
+ subject.wrangler << "bar"
101
+ subject.save
102
+ expect(subject.wrangler).to eql(["bar"])
103
+ end
104
+ end
105
+
90
106
  end
91
107
 
92
108
  end