ddr-core 1.5.4 → 1.5.5

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: dd302a231a2cb10cfb34d72a9d68cd7c52b1a19e7b61eaf237498921b00578ff
4
- data.tar.gz: 3bad65714fa43167182dcf88250f227518d22f376d0ccd822be2fe1048765283
3
+ metadata.gz: 92867a8dbfa97c6c96918832f4a7b031b1d2a43003d494522354d9a035601e17
4
+ data.tar.gz: 0fef07ae4d93da41514678af0c5efb77dd39ecd760a1a5497826c2d1fb481cd7
5
5
  SHA512:
6
- metadata.gz: f0f763d15a06561cd30a93571235c12e280e970fc9ac1fd1d85bf518827aa19baeabe75b75d7dfcc61cad7086cc4ec3cec1d191f0acceab2cd1b4dd2af9efdca
7
- data.tar.gz: af7f6b1bbbd2de0b6fa0f40b6bafdb7c3e6720bde6512ae980ca05b3b3bcaae022f4ca314fd98c96ad98a01f7d244924d1027f2446f04fcc273ed08ac5f8ea3b
6
+ metadata.gz: 90302d9df8273869777b165edcadb4f077706b3389c7b8eebc8ac49d8f92b6fd85932743f1729539ccbd8b97d09d12c4742349f9486c2aafee71d83272022ad9
7
+ data.tar.gz: 5d668698ea1f841a9f37db6a868ad340e27bc2d1589596abd5e871e4e5a84abc961b3c1665520e46d5a81d40f3270b8e24743a47bbe69d7f657755bd36fdbbdb
@@ -5,41 +5,34 @@ module Ddr
5
5
  module SolrDocumentBehavior
6
6
  extend ActiveSupport::Concern
7
7
 
8
- class NotFound < Error; end
9
-
10
8
  included do
11
- delegate :query_service,
12
- :resource_factory,
13
- to: :metadata_adapter
9
+ alias_method :pid, :id
14
10
  end
15
11
 
12
+ class NotFound < Error; end
13
+
16
14
  module ClassMethods
17
15
  def find(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
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}\"."
25
21
  end
26
22
 
27
23
  def find_by_permanent_id(ark)
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}"
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
36
33
  end
34
+ raise NotFound, "SolrDocument not found for permanent id \"#{ark}\"."
37
35
  end
38
- end # ClassMethods
39
-
40
- def pid
41
- warn "DEPRECATION: #pid is deprecated. Use #id instead."
42
- id
43
36
  end
44
37
 
45
38
  def inspect
@@ -63,12 +56,8 @@ module Ddr
63
56
  super
64
57
  end
65
58
 
66
- def metadata_adapter
67
- Valkyrie::MetadataAdapter.find(:index_solr)
68
- end
69
-
70
59
  def resource
71
- @resource ||= resource_factory.to_resource(object: self)
60
+ @resource ||= Valkyrie::MetadataAdapter.find(:index_solr).query_service.find_by(id: id)
72
61
  end
73
62
 
74
63
  def object_create_date
@@ -145,7 +134,7 @@ module Ddr
145
134
  end
146
135
 
147
136
  def targets_count
148
- @targets_count ||= targets.count
137
+ @targets_count = targets.count
149
138
  end
150
139
 
151
140
  def has_target?
@@ -161,7 +150,7 @@ module Ddr
161
150
  end
162
151
 
163
152
  def roles
164
- resource.roles
153
+ @roles ||= resource.roles
165
154
  end
166
155
 
167
156
  def resource_roles
@@ -187,14 +176,9 @@ module Ddr
187
176
  Ddr::Contact.call(research_help_contact) if research_help_contact
188
177
  end
189
178
 
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
179
+ def parent_id
180
+ is_part_of || is_member_of_collection
181
+ end
198
182
 
199
183
  def has_parent?
200
184
  parent_id.present?
@@ -323,6 +307,10 @@ module Ddr
323
307
 
324
308
  private
325
309
 
310
+ def query_service
311
+ @query_service ||= Valkyrie::MetadataAdapter.find(:index_solr).query_service
312
+ end
313
+
326
314
  def get_date(field)
327
315
  parse_date(self[field])
328
316
  end
@@ -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.
41
- # Valkyrie indexes fields > 1000 characters in length as _tsim only.
40
+ # DDR-1997 - description should always be indexed as _tesim regardless of length - Valkyrie indexes fields > 1000
41
+ # 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
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.5.4
4
+ version: 1.5.5
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: 2021-05-18 00:00:00.000000000 Z
14
+ date: 2021-05-20 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'
92
+ version: 2.1.0
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'
99
+ version: 2.1.0
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: '0'
162
+ version: '1.3'
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: '0'
169
+ version: '1.3'
170
170
  - !ruby/object:Gem::Dependency
171
171
  name: virtus
172
172
  requirement: !ruby/object:Gem::Requirement