ddr-core 1.5.1 → 1.6.0

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: bd64dda80015a23322764578176c17ed01d87d1ccaa11c9bf6962d99e02abe66
4
- data.tar.gz: 97055be97a593c3718a66372079fd3eaafa8a2465a5f76bbb6a62f7b0661b42f
3
+ metadata.gz: 1364ab93e3c082c34f2659457da88cb2d9fadc8022b8f6f20624a93204f5eb33
4
+ data.tar.gz: 914a4b226a010e472ccbd1fb0094e1f79e5820c81c767d973a01ed1aed6c7117
5
5
  SHA512:
6
- metadata.gz: 4b1e406145e1a15129c75f0ea8430fa7d470d1d292417c163846ebc1746327ce213c7b1779d6b78d420b355c13bd93d8fa21949f00df22158a0639ad39618f4a
7
- data.tar.gz: 8da1e652bf2279f787fa58fd02294c2b66648ca9f5864bf4d05ff284a7f70ed821278868e630858d52d4a9fae9e71164f54b1bfa87f22c4cf4a5da8e6589529c
6
+ metadata.gz: e5d381cbd5e5f7849105c6b3298f93ca67836deb6e8d81ea8c2166032baeb298cc5ffa5619c41483ac4c4b0b2e08a87514e9c40c4029b6be120bb7931894f267
7
+ data.tar.gz: 98c97a9de5bc87e28a464a4647af8f83f7b2cc27e2aef082a0cf079205110cc3e5de3aa478fea50d7b52841d00e91e825d01addd2241b8439bd7c3a43949a662
@@ -0,0 +1,14 @@
1
+ module Ddr
2
+ module HasDerivedImage
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ attribute :derived_image, Ddr::File.optional
7
+ end
8
+
9
+ def derived_image_file_path
10
+ derived_image&.file&.disk_path
11
+ end
12
+
13
+ end
14
+ end
@@ -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
@@ -4,6 +4,7 @@ module Ddr
4
4
  include Captionable
5
5
  include Embargoable
6
6
  include HasContent
7
+ include HasDerivedImage
7
8
  include HasExtractedText
8
9
  include HasIntermediateFile
9
10
  include HasMultiresImage
@@ -10,6 +10,7 @@ module Ddr
10
10
 
11
11
  FILE_FIELDS = %i( caption
12
12
  content
13
+ derived_image
13
14
  extracted_text
14
15
  fits_file
15
16
  intermediate_file
@@ -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,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
8
8
  - David Chandek-Stark
9
9
  - Ayse Durmaz
10
10
  - Hugh Cayless
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-05-17 00:00:00.000000000 Z
14
+ date: 2021-05-27 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
@@ -294,7 +294,7 @@ dependencies:
294
294
  - !ruby/object:Gem::Version
295
295
  version: '0'
296
296
  description: Models used in the Duke Digital Repository
297
- email:
297
+ email:
298
298
  executables: []
299
299
  extensions: []
300
300
  extra_rdoc_files: []
@@ -313,6 +313,7 @@ files:
313
313
  - app/models/concerns/ddr/has_attachments.rb
314
314
  - app/models/concerns/ddr/has_children.rb
315
315
  - app/models/concerns/ddr/has_content.rb
316
+ - app/models/concerns/ddr/has_derived_image.rb
316
317
  - app/models/concerns/ddr/has_extracted_text.rb
317
318
  - app/models/concerns/ddr/has_intermediate_file.rb
318
319
  - app/models/concerns/ddr/has_multires_image.rb
@@ -439,7 +440,7 @@ licenses:
439
440
  - BSD-3-Clause
440
441
  metadata:
441
442
  allowed_push_host: https://rubygems.org
442
- post_install_message:
443
+ post_install_message:
443
444
  rdoc_options: []
444
445
  require_paths:
445
446
  - lib
@@ -454,8 +455,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
454
455
  - !ruby/object:Gem::Version
455
456
  version: '0'
456
457
  requirements: []
457
- rubygems_version: 3.0.8
458
- signing_key:
458
+ rubygems_version: 3.2.18
459
+ signing_key:
459
460
  specification_version: 4
460
461
  summary: Models used in the Duke Digital Repository
461
462
  test_files: []