active-fedora 10.0.0 → 10.1.0.rc1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1467d74478a1ea4aa80bcb17add4c7f34b798af7
4
- data.tar.gz: 5e15c3f279e391f4acf2fd0c87a5554e0df65c7d
3
+ metadata.gz: 0da32a629ca0c04a5d83095d550ff267d2f53167
4
+ data.tar.gz: 7a68b6ee0c5231ae10e9f1c93d3cac54427ff322
5
5
  SHA512:
6
- metadata.gz: c65e10a31bc1b766e4837eabfa198a3fe873b3ba93963d46edaaf0efb16c509f7091752336bf4608ea7e2fbccab5f899644777bb187585f1f197560b963b52b3
7
- data.tar.gz: 03dcfbf9f6c33829ac0235a5108985b29a62cbbe8b9782a24cee195f7962749010c4d75559f2f7e9ffade94f5acaeb58474465a021c43c25e2b370e1ba7d80cd
6
+ metadata.gz: 1b11aa699b0ac03ed5b4a33727e7544fc74f3e027a19487bb6774334e029814030a8099b67dc6f6bb1fdf4cd0af9690bf166ac883337f4503de9c05274877eef
7
+ data.tar.gz: abadc23ff5e3f8646c991e6f3b1ac8c1367f12d8b73fea9e66d0fc98c8d8d9a1ef3d6171c78beee1d887dc49f3956b76052bb2cee101763448031f374684f07f
@@ -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)
@@ -3,12 +3,18 @@ require "nom"
3
3
  module ActiveFedora
4
4
  class NomDatastream < File
5
5
  include Datastreams::NokogiriDatastreams
6
+ extend Deprecation
6
7
 
7
8
  def self.set_terminology(options = {}, &block)
8
9
  @terminology_options = options || {}
9
10
  @terminology = block
10
11
  end
11
12
 
13
+ def initialize(*args)
14
+ super
15
+ Deprecation.warn(NomDatastream, "NomDatastream is deprecated and will be removed in ActiveFedora 11")
16
+ end
17
+
12
18
  class << self
13
19
  attr_reader :terminology_options
14
20
  end
@@ -12,10 +12,16 @@ module ActiveFedora
12
12
  include OM::XML::Document
13
13
  include OM::XML::TerminologyBasedSolrizer # this adds support for calling .to_solr
14
14
  include Datastreams::NokogiriDatastreams
15
+ extend Deprecation
15
16
 
16
17
  alias om_term_values term_values unless method_defined?(:om_term_values)
17
18
  alias om_update_values update_values unless method_defined?(:om_update_values)
18
19
 
20
+ def initialize(*args)
21
+ super
22
+ Deprecation.warn(OmDatastream, "OmDatastream is deprecated and will be removed in ActiveFedora 11")
23
+ end
24
+
19
25
  def default_mime_type
20
26
  'text/xml'
21
27
  end
@@ -33,28 +39,6 @@ module ActiveFedora
33
39
  solr_doc.merge super({}).each_with_object({}) { |(key, value), new| new[[prefix, key].join] = value }
34
40
  end
35
41
 
36
- # ** Experimental **
37
- # @return [Boolean] true if either the key for name exists in solr or if its string value exists
38
- # @param [String] name Name of key to look for
39
- # @param [Solr::Document] solr_doc Solr doc to query
40
- def has_solr_name?(name, solr_doc = {})
41
- !solr_doc[name].nil? || !solr_doc[name.to_s].nil?
42
- end
43
-
44
- # ** Experimental **
45
- # @return true if the term_pointer contains an index
46
- # ====Example:
47
- # [:image, {:title_set=>1}, :title] return true
48
- # [:image, :title_set, :title] return false
49
- def is_hierarchical_term_pointer?(*term_pointer)
50
- if term_pointer.length > 1
51
- term_pointer.each do |pointer|
52
- return true if pointer.is_a?(Hash)
53
- end
54
- end
55
- false
56
- end
57
-
58
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}
59
43
  # Ignores any fields from params that this datastream's Terminology doesn't recognize
60
44
  #
@@ -122,5 +106,13 @@ module ActiveFedora
122
106
  result = om_update_values(params)
123
107
  result
124
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
125
117
  end
126
118
  end
@@ -4,7 +4,6 @@ module ActiveFedora
4
4
  autoload :DatastreamIndexing
5
5
  autoload :Fcrepo
6
6
  autoload :IndexingService
7
- autoload :Identifiable
8
7
  autoload :Persistence
9
8
  autoload :ProjectHydra
10
9
  autoload :FieldMap
@@ -39,5 +39,11 @@ module ActiveFedora::RDF
39
39
  def apply_prefix(name, file_path)
40
40
  prefix(file_path) + name.to_s
41
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
42
48
  end
43
49
  end
@@ -5,5 +5,9 @@ module ActiveFedora
5
5
  def serialization_format
6
6
  :ntriples
7
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
8
12
  end
9
13
  end
@@ -4,8 +4,17 @@ module ActiveFedora
4
4
  include RDF::DatastreamIndexing
5
5
  include ActiveTriples::Properties
6
6
  include ActiveTriples::Reflection
7
+ extend Deprecation
7
8
 
8
9
  delegate :rdf_subject, :set_value, :get_values, :attributes=, to: :resource
10
+ def initialize(*args)
11
+ super
12
+ deprecation_warning
13
+ end
14
+
15
+ def deprecation_warning
16
+ Deprecation.warn(RDFDatastream, "RDFDatastream is deprecated and will be removed in ActiveFedora 11", caller(2))
17
+ end
9
18
 
10
19
  class << self
11
20
  def rdf_subject(&block)
@@ -255,13 +255,13 @@ module ActiveFedora
255
255
  # @param [Hash<Symbol,String>] conditions
256
256
  # @return [Array<String>]
257
257
  def create_query_from_hash(conditions)
258
- conditions.map { |key, value| condition_to_clauses(key, value) }.compact
258
+ conditions.map { |key, value| condition_to_clauses(key, value, ' OR ') }.compact
259
259
  end
260
260
 
261
261
  # @param [Symbol] key
262
262
  # @param [String] value
263
- def condition_to_clauses(key, value)
264
- SolrQueryBuilder.construct_query([[field_name_for(key), value]])
263
+ def condition_to_clauses(key, value, join_with = SolrQueryBuilder.default_join_with)
264
+ SolrQueryBuilder.construct_query([[field_name_for(key), value]], join_with)
265
265
  end
266
266
 
267
267
  # If the key is a property name, turn it into a solr field
@@ -13,6 +13,7 @@ module ActiveFedora
13
13
  #
14
14
  # fruits = Fruit.all
15
15
  # fruits = fruits.where(color: 'red') if options[:red_only]
16
+ # fruits = fruits.where(size: ['big', 'little']) # gets big or little fruit
16
17
  # fruits = fruits.limit(10) if limited?
17
18
  #
18
19
  # You can define a scope that applies to all finders using
@@ -19,7 +19,7 @@ module ActiveFedora
19
19
  # # => _query_:"{!field f=has_model_ssim}info:fedora/afmodel:ComplexCollection" OR _query_:"{!field f=has_model_ssim}info:fedora/afmodel:ActiveFedora_Base"
20
20
  #
21
21
  # construct_query_for_rel [[Book._reflect_on_association(:library), "foo/bar/baz"]]
22
- def construct_query_for_rel(field_pairs, join_with = ' AND ')
22
+ def construct_query_for_rel(field_pairs, join_with = default_join_with)
23
23
  field_pairs = field_pairs.to_a if field_pairs.is_a? Hash
24
24
  construct_query(property_values_to_solr(field_pairs), join_with)
25
25
  end
@@ -31,8 +31,15 @@ module ActiveFedora
31
31
  # @example
32
32
  # construct_query([['library_id_ssim', '123'], ['owner_ssim', 'Fred']])
33
33
  # # => "_query_:\"{!field f=library_id_ssim}123\" AND _query_:\"{!field f=owner_ssim}Fred\""
34
- def construct_query(field_pairs, join_with = ' AND ')
35
- pairs_to_clauses(field_pairs).join(join_with)
34
+ def construct_query(field_pairs, join_with = default_join_with)
35
+ clauses = pairs_to_clauses(field_pairs)
36
+ return "" if clauses.count == 0
37
+ return clauses.first if clauses.count == 1
38
+ "(#{clauses.join(join_with)})"
39
+ end
40
+
41
+ def default_join_with
42
+ ' AND '
36
43
  end
37
44
 
38
45
  private
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "10.0.0".freeze
2
+ VERSION = "10.1.0.rc1".freeze
3
3
  end
@@ -41,14 +41,6 @@ namespace :active_fedora do
41
41
  spec.rcov = true
42
42
  end
43
43
 
44
- desc "Copies the default SOLR config for the bundled Testing Server"
45
- task :configure_jetty do
46
- FileList['lib/generators/active_fedora/config/solr/templates/solr_conf/conf/*'].each do |f|
47
- cp("#{f}", 'jetty/solr/development-core/conf/', :verbose => true)
48
- cp("#{f}", 'jetty/solr/test-core/conf/', :verbose => true)
49
- end
50
- end
51
-
52
44
  desc "CI build"
53
45
  task :ci do
54
46
  ENV['environment'] = "test"
@@ -65,6 +65,7 @@ describe ActiveFedora::Querying do
65
65
  field = ActiveFedora.index_field_mapper.solr_name('foo', type: :string)
66
66
  expect(ModelIntegrationSpec::Basic.where(field => 'Beta')).to eq [test_instance1]
67
67
  expect(ModelIntegrationSpec::Basic.where('foo' => 'Beta')).to eq [test_instance1]
68
+ expect(ModelIntegrationSpec::Basic.where('foo' => ['Beta', 'Alpha'])).to eq [test_instance1, test_instance2]
68
69
  end
69
70
  it "orders" do
70
71
  expect(ModelIntegrationSpec::Basic.order(ActiveFedora.index_field_mapper.solr_name('foo', :sortable) + ' asc')).to eq [test_instance2, test_instance1, test_instance3]
@@ -37,6 +37,12 @@ restore_spec_configuration
37
37
 
38
38
  require 'active_fedora/cleaner'
39
39
  RSpec.configure do |config|
40
+ config.before(:suite) do
41
+ ActiveFedora::RDFDatastream.deprecation_behavior = :silence
42
+ ActiveFedora::NtriplesRDFDatastream.deprecation_behavior = :silence
43
+ ActiveFedora::OmDatastream.deprecation_behavior = :silence
44
+ ActiveFedora::NomDatastream.deprecation_behavior = :silence
45
+ end
40
46
  # Stub out test stuff.
41
47
  config.before(:each) do
42
48
  begin
@@ -51,8 +51,8 @@ describe ActiveFedora::FinderMethods do
51
51
 
52
52
  context "when value is an array" do
53
53
  let(:value) { ['one', 'four'] }
54
- it { is_expected.to eq "_query_:\"{!field f=library_id}one\" AND " \
55
- "_query_:\"{!field f=library_id}four\"" }
54
+ it { is_expected.to eq "(_query_:\"{!field f=library_id}one\" AND " \
55
+ "_query_:\"{!field f=library_id}four\")" }
56
56
  end
57
57
  end
58
58
 
@@ -256,37 +256,6 @@ describe ActiveFedora::OmDatastream do
256
256
  end
257
257
  end
258
258
 
259
- describe '.has_solr_name?' do
260
- let(:name0_role0) { ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_0_role_0_roleTerm", type: :string) }
261
- let(:name1_role1) { ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_1_role_1_roleTerm", type: :string) }
262
- let(:solr_doc) do
263
- { "id" => "mods_article1",
264
- ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_role_roleTerm", type: :string) => ["creator", "submitter", "teacher"],
265
- ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_0_role", type: :string) => "\r\ncreator\r\nsubmitter\r\n",
266
- ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_1_role", type: :string) => "\r\n teacher \r\n",
267
- name0_role0 => "creator",
268
- ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_0_role_1_roleTerm", type: :string) => "submitter",
269
- ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_1_role_0_roleTerm", type: :string) => ["teacher"] }
270
- end
271
-
272
- it "returns true if the given key exists in the solr document passed in" do
273
- expect(subject).to have_solr_name(name0_role0, solr_doc)
274
- expect(subject).to have_solr_name(name0_role0.to_sym, solr_doc)
275
- expect(subject).to_not have_solr_name(name1_role1, solr_doc)
276
- # if not doc passed in should be new empty solr doc and always return false
277
- expect(subject).to_not have_solr_name(name0_role0)
278
- end
279
- end
280
-
281
- describe '.is_hierarchical_term_pointer?' do
282
- it "returns true only if the pointer passed in is an array that contains a hash" do
283
- expect(subject.is_hierarchical_term_pointer?(*[:image, { tag1: 1 }, :tag2])).to be true
284
- expect(subject.is_hierarchical_term_pointer?(*[:image, :tag1, { tag2: 1 }])).to be true
285
- expect(subject.is_hierarchical_term_pointer?(*[:image, :tag1, :tag2])).to be false
286
- expect(subject.is_hierarchical_term_pointer?(nil)).to be false
287
- end
288
- end
289
-
290
259
  describe '.update_values' do
291
260
  subject { described_class.new }
292
261
 
@@ -79,8 +79,8 @@ describe ActiveFedora::Base do
79
79
  let(:solr) { ActiveFedora::SolrService.instance.conn }
80
80
  let(:expected_query) { "#{model_query} AND " \
81
81
  "_query_:\"{!field f=foo}bar\" AND " \
82
- "_query_:\"{!field f=baz}quix\" AND " \
83
- "_query_:\"{!field f=baz}quack\"" }
82
+ "(_query_:\"{!field f=baz}quix\" OR " \
83
+ "_query_:\"{!field f=baz}quack\")" }
84
84
  let(:expected_params) { { params: { sort: [sort_query], fl: 'id', q: expected_query, qt: 'standard' } } }
85
85
  let(:expected_sort_params) { { params: { sort: ["title_t desc"], fl: 'id', q: expected_query, qt: 'standard' } } }
86
86
  let(:mock_docs) { [{ "id" => "changeme:30" }, { "id" => "changeme:22" }] }
@@ -138,8 +138,8 @@ describe ActiveFedora::Base do
138
138
  let(:solr) { ActiveFedora::SolrService.instance.conn }
139
139
  let(:expected_query) { "#{model_query} AND " \
140
140
  "_query_:\"{!field f=foo}bar\" AND " \
141
- "_query_:\"{!field f=baz}quix\" AND " \
142
- "_query_:\"{!field f=baz}quack\"" }
141
+ "(_query_:\"{!field f=baz}quix\" OR " \
142
+ "_query_:\"{!field f=baz}quack\")" }
143
143
  let(:expected_params) { { params: { sort: [sort_query], fl: 'id', q: expected_query, qt: 'standard' } } }
144
144
  let(:mock_docs) { [{ "id" => "changeme-30" }, { "id" => "changeme-22" }] }
145
145
 
@@ -159,8 +159,8 @@ describe ActiveFedora::Base do
159
159
  let(:solr) { ActiveFedora::SolrService.instance.conn }
160
160
  let(:expected_query) { "#{model_query} AND " \
161
161
  "_query_:\"{!field f=foo}bar\" AND " \
162
- "_query_:\"{!field f=baz}quix\" AND " \
163
- "_query_:\"{!field f=baz}quack\"" }
162
+ "(_query_:\"{!field f=baz}quix\" OR " \
163
+ "_query_:\"{!field f=baz}quack\")" }
164
164
  let(:expected_params) { { params: { sort: [sort_query], fl: 'id', q: expected_query, qt: 'standard' } } }
165
165
  let(:mock_docs) { double('docs') }
166
166
 
@@ -254,8 +254,8 @@ describe ActiveFedora::Base do
254
254
  context "with a hash of conditions" do
255
255
  let(:expected_query) { "#{model_query} AND " \
256
256
  "_query_:\"{!field f=foo}bar\" AND " \
257
- "_query_:\"{!field f=baz}quix\" AND " \
258
- "_query_:\"{!field f=baz}quack\"" }
257
+ "(_query_:\"{!field f=baz}quix\" OR " \
258
+ "_query_:\"{!field f=baz}quack\")" }
259
259
  let(:conditions) { { foo: 'bar', baz: ['quix', 'quack'] } }
260
260
 
261
261
  it "makes a query to solr and returns the results" do
@@ -266,8 +266,8 @@ describe ActiveFedora::Base do
266
266
  context "with quotes in the params" do
267
267
  let(:expected_query) { "#{model_query} AND " \
268
268
  "_query_:\"{!field f=foo}9\\\" Nails\" AND " \
269
- "_query_:\"{!field f=baz}7\\\" version\" AND " \
270
- "_query_:\"{!field f=baz}quack\"" }
269
+ "(_query_:\"{!field f=baz}7\\\" version\" OR " \
270
+ "_query_:\"{!field f=baz}quack\")" }
271
271
  let(:conditions) { { foo: '9" Nails', baz: ['7" version', 'quack'] } }
272
272
 
273
273
  it "escapes quotes" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0
4
+ version: 10.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-06-08 00:00:00.000000000 Z
13
+ date: 2016-07-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr
@@ -772,9 +772,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
772
772
  version: '2.0'
773
773
  required_rubygems_version: !ruby/object:Gem::Requirement
774
774
  requirements:
775
- - - ">="
775
+ - - ">"
776
776
  - !ruby/object:Gem::Version
777
- version: '0'
777
+ version: 1.3.1
778
778
  requirements: []
779
779
  rubyforge_project:
780
780
  rubygems_version: 2.5.1