ddr-core 1.3.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61fa03b921f6c0f3b15a68938f568c4547f324facd5f57bf753ca5b28ae756e2
4
- data.tar.gz: e74b196e266a1d4a21c24c90490374d2f7054fb52921623adba198bbc9948eca
3
+ metadata.gz: bd64dda80015a23322764578176c17ed01d87d1ccaa11c9bf6962d99e02abe66
4
+ data.tar.gz: 97055be97a593c3718a66372079fd3eaafa8a2465a5f76bbb6a62f7b0661b42f
5
5
  SHA512:
6
- metadata.gz: 95ab554ea0873c8b6f8db7ae981f0d6336d180731f91bfd57d19f8806682142fdc47bce3fb09a8aae485bd41e7e9389e0c4cf16fdfa992406032335350085041
7
- data.tar.gz: 5239037ba065ed2034951311c260d988b19cbd45f3d2c2f6f10e78e9cd311e866e9fc7ca49619fca3de2ec791dea19942b41b4b22863383b9442456ade3ff0ac
6
+ metadata.gz: 4b1e406145e1a15129c75f0ea8430fa7d470d1d292417c163846ebc1746327ce213c7b1779d6b78d420b355c13bd93d8fa21949f00df22158a0639ad39618f4a
7
+ data.tar.gz: 8da1e652bf2279f787fa58fd02294c2b66648ca9f5864bf4d05ff284a7f70ed821278868e630858d52d4a9fae9e71164f54b1bfa87f22c4cf4a5da8e6589529c
@@ -5,34 +5,41 @@ module Ddr
5
5
  module SolrDocumentBehavior
6
6
  extend ActiveSupport::Concern
7
7
 
8
+ class NotFound < Error; end
9
+
8
10
  included do
9
- alias_method :pid, :id
11
+ delegate :query_service,
12
+ :resource_factory,
13
+ to: :metadata_adapter
10
14
  end
11
15
 
12
- class NotFound < Error; end
13
-
14
16
  module ClassMethods
15
17
  def find(id)
16
- query = Ddr::Index::Query.new { id id }
17
- if doc = query.docs.first
18
- return doc
19
- end
20
- raise NotFound, "SolrDocument not found for \"#{id}\"."
18
+ raise ArgumentError, "ID argument must be present." if id.blank?
19
+
20
+ response = Blacklight.default_index.find(id)
21
+ response.documents.first
22
+
23
+ rescue Blacklight::Exceptions::RecordNotFound => e
24
+ raise NotFound, e
21
25
  end
22
26
 
23
27
  def find_by_permanent_id(ark)
24
- if ark.blank?
25
- raise ArgumentError, "ARK argument must be present."
26
- end
27
- query = Ddr::Index::Query.new do
28
- q *:*
29
- where permanent_id: ark
30
- end
31
- if doc = query.docs.first
32
- return doc
28
+ raise ArgumentError, "ARK argument must be present." if ark.blank?
29
+
30
+ response = Blacklight.default_index.search(q: "#{Ddr::Index::Fields::PERMANENT_ID}:\"#{ark}\"", rows: 1)
31
+
32
+ if doc = response.documents.first
33
+ doc
34
+ else
35
+ raise NotFound, "Permanent ID: #{ark}"
33
36
  end
34
- raise NotFound, "SolrDocument not found for permanent id \"#{ark}\"."
35
37
  end
38
+ end # ClassMethods
39
+
40
+ def pid
41
+ warn "DEPRECATION: #pid is deprecated. Use #id instead."
42
+ id
36
43
  end
37
44
 
38
45
  def inspect
@@ -56,8 +63,12 @@ module Ddr
56
63
  super
57
64
  end
58
65
 
66
+ def metadata_adapter
67
+ Valkyrie::MetadataAdapter.find(:index_solr)
68
+ end
69
+
59
70
  def resource
60
- @resource ||= Valkyrie::MetadataAdapter.find(:index_solr).query_service.find_by(id: id)
71
+ @resource ||= resource_factory.to_resource(object: self)
61
72
  end
62
73
 
63
74
  def object_create_date
@@ -134,7 +145,7 @@ module Ddr
134
145
  end
135
146
 
136
147
  def targets_count
137
- @targets_count = targets.count
148
+ @targets_count ||= targets.count
138
149
  end
139
150
 
140
151
  def has_target?
@@ -150,7 +161,7 @@ module Ddr
150
161
  end
151
162
 
152
163
  def roles
153
- @roles ||= resource.roles
164
+ resource.roles
154
165
  end
155
166
 
156
167
  def resource_roles
@@ -176,9 +187,14 @@ module Ddr
176
187
  Ddr::Contact.call(research_help_contact) if research_help_contact
177
188
  end
178
189
 
179
- def parent_id
180
- is_part_of || is_member_of_collection
181
- end
190
+ #
191
+ # Fall back to PARENT_ID field, which supersedes IS_PART_OF and _IS_MEMBER_OF_COLLECTION
192
+ # for this usage.
193
+ # Cf. https://duldev.atlassian.net/browse/DDR-2296
194
+ #
195
+ # def parent_id
196
+ # is_part_of || is_member_of_collection
197
+ # end
182
198
 
183
199
  def has_parent?
184
200
  parent_id.present?
@@ -307,10 +323,6 @@ module Ddr
307
323
 
308
324
  private
309
325
 
310
- def query_service
311
- @query_service ||= Valkyrie::MetadataAdapter.find(:index_solr).query_service
312
- end
313
-
314
326
  def get_date(field)
315
327
  parse_date(self[field])
316
328
  end
@@ -13,8 +13,6 @@ module Ddr::Index
13
13
  delegate [:get, :post, :paginate] => :solr
14
14
 
15
15
  def solr
16
- # Changed for Valkyrie
17
- # RSolr.connect(ActiveFedora.solr_config)
18
16
  Blacklight.default_index.connection
19
17
  end
20
18
 
@@ -37,8 +37,8 @@ module Ddr::Index
37
37
  DATE_SORT = Field.new :date_sort, :sortable
38
38
  DC_IS_PART_OF = Field.new :isPartOf, :symbol
39
39
  DEPOSITOR = Field.new :depositor, :stored_sortable
40
- # DDR-1997 - description should always be indexed as _tesim regardless of length - Valkyrie indexes fields > 1000
41
- # characters in length as _tsim only
40
+ # DDR-1997 - description should always be indexed as _tesim regardless of length.
41
+ # Valkyrie indexes fields > 1000 characters in length as _tsim only.
42
42
  DESCRIPTION = Field.new :description, :stored_searchable # stored_searchable produces _tesim
43
43
  DISPLAY_FORMAT = Field.new :display_format, :stored_sortable
44
44
  DOI = Field.new :doi, :symbol
@@ -92,9 +92,10 @@ module Ddr::Index
92
92
  end
93
93
 
94
94
  def page(num)
95
- page_params = params.dup
96
- page_size = page_params.delete(:rows) || PAGE_SIZE
97
- response = Connection.page(num, page_size, "select", params: page_params)
95
+ data = params.dup
96
+ page_size = data.delete(:rows) || PAGE_SIZE
97
+ opts = { method: :post, data: data }
98
+ response = Connection.page(num, page_size, 'select', opts)
98
99
  response.docs
99
100
  end
100
101
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-10-27 00:00:00.000000000 Z
14
+ date: 2021-05-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activeresource
@@ -89,14 +89,14 @@ dependencies:
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: 2.1.0
92
+ version: '2.1'
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: 2.1.0
99
+ version: '2.1'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: grouper-rest-client
102
102
  requirement: !ruby/object:Gem::Requirement
@@ -157,16 +157,16 @@ dependencies:
157
157
  name: omniauth-shibboleth
158
158
  requirement: !ruby/object:Gem::Requirement
159
159
  requirements:
160
- - - "~>"
160
+ - - ">="
161
161
  - !ruby/object:Gem::Version
162
- version: '1.3'
162
+ version: '0'
163
163
  type: :runtime
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
166
166
  requirements:
167
- - - "~>"
167
+ - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: '1.3'
169
+ version: '0'
170
170
  - !ruby/object:Gem::Dependency
171
171
  name: virtus
172
172
  requirement: !ruby/object:Gem::Requirement
@@ -295,7 +295,6 @@ dependencies:
295
295
  version: '0'
296
296
  description: Models used in the Duke Digital Repository
297
297
  email:
298
- - lib-drs@duke.edu
299
298
  executables: []
300
299
  extensions: []
301
300
  extra_rdoc_files: []
@@ -388,7 +387,6 @@ files:
388
387
  - lib/ddr/auth/web_auth_context.rb
389
388
  - lib/ddr/core.rb
390
389
  - lib/ddr/core/engine.rb
391
- - lib/ddr/core/version.rb
392
390
  - lib/ddr/error.rb
393
391
  - lib/ddr/files.rb
394
392
  - lib/ddr/fits.rb
@@ -456,7 +454,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
456
454
  - !ruby/object:Gem::Version
457
455
  version: '0'
458
456
  requirements: []
459
- rubygems_version: 3.0.6
457
+ rubygems_version: 3.0.8
460
458
  signing_key:
461
459
  specification_version: 4
462
460
  summary: Models used in the Duke Digital Repository
@@ -1,5 +0,0 @@
1
- module Ddr
2
- module Core
3
- VERSION = '1.3.0'
4
- end
5
- end