ddr-core 1.5.4 → 1.6.3

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: 7c2ee6a1a1de8fd86904bc1f067378379972862830e591ad2588c77057666608
4
+ data.tar.gz: 999d2c0e8710e45fe854bd7b75718dd36f1e2ee01181ffe4af2c34121f49ca70
5
5
  SHA512:
6
- metadata.gz: f0f763d15a06561cd30a93571235c12e280e970fc9ac1fd1d85bf518827aa19baeabe75b75d7dfcc61cad7086cc4ec3cec1d191f0acceab2cd1b4dd2af9efdca
7
- data.tar.gz: af7f6b1bbbd2de0b6fa0f40b6bafdb7c3e6720bde6512ae980ca05b3b3bcaae022f4ca314fd98c96ad98a01f7d244924d1027f2446f04fcc273ed08ac5f8ea3b
6
+ metadata.gz: 4b2a4518977f7a36e6b9959b0f1b5e891f975edf97f8c474bc4f10bfb80646fb8da294bd8c5e03a19a113c31d4ec27ce2423455734b40ecdd0bfb56b3e6ae147
7
+ data.tar.gz: bed7b8d7fcb879d9763bfbe6b0989c8c0e5b39eea4b0e12120dfa995d731a915b932c95c79b46555db1c3a0daac08a5dbfc65098af2d359b06f4eb711f09860e
@@ -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
@@ -31,7 +31,7 @@ module Ddr
31
31
  # Return default file extension for file based on MIME type
32
32
  def default_file_extension
33
33
  mimetypes = MIME::Types[media_type]
34
- return mimetypes.first.extensions.first unless mimetypes.empty?
34
+ return mimetypes.first.preferred_extension unless mimetypes.empty?
35
35
  case media_type
36
36
  when 'application/n-triples'
37
37
  'txt'
@@ -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,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.6.3
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-06-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activeresource
@@ -42,35 +42,35 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: '6.20'
44
44
  - !ruby/object:Gem::Dependency
45
- name: pg
45
+ name: cancancan
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ">="
48
+ - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: '0'
50
+ version: '1.8'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ">="
55
+ - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '0'
57
+ version: '1.8'
58
58
  - !ruby/object:Gem::Dependency
59
- name: rails
59
+ name: devise
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: 5.2.2
64
+ version: '4.6'
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: 5.2.2
71
+ version: '4.6'
72
72
  - !ruby/object:Gem::Dependency
73
- name: rdf-rdfxml
73
+ name: grouper-rest-client
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - ">="
@@ -84,35 +84,35 @@ dependencies:
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  - !ruby/object:Gem::Dependency
87
- name: valkyrie
87
+ name: net-ldap
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - "~>"
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: '2.1'
92
+ version: '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: '0'
100
100
  - !ruby/object:Gem::Dependency
101
- name: grouper-rest-client
101
+ name: omniauth-shibboleth
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - ">="
104
+ - - "~>"
105
105
  - !ruby/object:Gem::Version
106
- version: '0'
106
+ version: '1.3'
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - ">="
111
+ - - "~>"
112
112
  - !ruby/object:Gem::Version
113
- version: '0'
113
+ version: '1.3'
114
114
  - !ruby/object:Gem::Dependency
115
- name: net-ldap
115
+ name: pg
116
116
  requirement: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="
@@ -126,35 +126,35 @@ dependencies:
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  - !ruby/object:Gem::Dependency
129
- name: cancancan
129
+ name: rails
130
130
  requirement: !ruby/object:Gem::Requirement
131
131
  requirements:
132
132
  - - "~>"
133
133
  - !ruby/object:Gem::Version
134
- version: '1.8'
134
+ version: 5.2.2
135
135
  type: :runtime
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
138
138
  requirements:
139
139
  - - "~>"
140
140
  - !ruby/object:Gem::Version
141
- version: '1.8'
141
+ version: 5.2.2
142
142
  - !ruby/object:Gem::Dependency
143
- name: devise
143
+ name: rdf-rdfxml
144
144
  requirement: !ruby/object:Gem::Requirement
145
145
  requirements:
146
- - - "~>"
146
+ - - ">="
147
147
  - !ruby/object:Gem::Version
148
- version: '4.6'
148
+ version: '0'
149
149
  type: :runtime
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
152
152
  requirements:
153
- - - "~>"
153
+ - - ">="
154
154
  - !ruby/object:Gem::Version
155
- version: '4.6'
155
+ version: '0'
156
156
  - !ruby/object:Gem::Dependency
157
- name: omniauth-shibboleth
157
+ name: rsolr
158
158
  requirement: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - ">="
@@ -168,47 +168,47 @@ dependencies:
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0'
170
170
  - !ruby/object:Gem::Dependency
171
- name: virtus
171
+ name: solrizer
172
172
  requirement: !ruby/object:Gem::Requirement
173
173
  requirements:
174
- - - "~>"
174
+ - - ">="
175
175
  - !ruby/object:Gem::Version
176
- version: 1.0.5
176
+ version: '0'
177
177
  type: :runtime
178
178
  prerelease: false
179
179
  version_requirements: !ruby/object:Gem::Requirement
180
180
  requirements:
181
- - - "~>"
181
+ - - ">="
182
182
  - !ruby/object:Gem::Version
183
- version: 1.0.5
183
+ version: '0'
184
184
  - !ruby/object:Gem::Dependency
185
- name: rsolr
185
+ name: valkyrie
186
186
  requirement: !ruby/object:Gem::Requirement
187
187
  requirements:
188
- - - ">="
188
+ - - "~>"
189
189
  - !ruby/object:Gem::Version
190
- version: '0'
190
+ version: '2.1'
191
191
  type: :runtime
192
192
  prerelease: false
193
193
  version_requirements: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - ">="
195
+ - - "~>"
196
196
  - !ruby/object:Gem::Version
197
- version: '0'
197
+ version: '2.1'
198
198
  - !ruby/object:Gem::Dependency
199
- name: solrizer
199
+ name: virtus
200
200
  requirement: !ruby/object:Gem::Requirement
201
201
  requirements:
202
- - - ">="
202
+ - - "~>"
203
203
  - !ruby/object:Gem::Version
204
- version: '0'
204
+ version: 1.0.5
205
205
  type: :runtime
206
206
  prerelease: false
207
207
  version_requirements: !ruby/object:Gem::Requirement
208
208
  requirements:
209
- - - ">="
209
+ - - "~>"
210
210
  - !ruby/object:Gem::Version
211
- version: '0'
211
+ version: 1.0.5
212
212
  - !ruby/object:Gem::Dependency
213
213
  name: equivalent-xml
214
214
  requirement: !ruby/object:Gem::Requirement
@@ -238,7 +238,7 @@ dependencies:
238
238
  - !ruby/object:Gem::Version
239
239
  version: '0'
240
240
  - !ruby/object:Gem::Dependency
241
- name: rspec-its
241
+ name: rails-controller-testing
242
242
  requirement: !ruby/object:Gem::Requirement
243
243
  requirements:
244
244
  - - ">="
@@ -252,7 +252,7 @@ dependencies:
252
252
  - !ruby/object:Gem::Version
253
253
  version: '0'
254
254
  - !ruby/object:Gem::Dependency
255
- name: rspec-rails
255
+ name: rspec-its
256
256
  requirement: !ruby/object:Gem::Requirement
257
257
  requirements:
258
258
  - - ">="
@@ -266,7 +266,7 @@ dependencies:
266
266
  - !ruby/object:Gem::Version
267
267
  version: '0'
268
268
  - !ruby/object:Gem::Dependency
269
- name: solr_wrapper
269
+ name: rspec-rails
270
270
  requirement: !ruby/object:Gem::Requirement
271
271
  requirements:
272
272
  - - ">="
@@ -280,7 +280,7 @@ dependencies:
280
280
  - !ruby/object:Gem::Version
281
281
  version: '0'
282
282
  - !ruby/object:Gem::Dependency
283
- name: rails-controller-testing
283
+ name: solr_wrapper
284
284
  requirement: !ruby/object:Gem::Requirement
285
285
  requirements:
286
286
  - - ">="
@@ -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
@@ -454,7 +455,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
454
455
  - !ruby/object:Gem::Version
455
456
  version: '0'
456
457
  requirements: []
457
- rubygems_version: 3.2.17
458
+ rubygems_version: 3.2.21
458
459
  signing_key:
459
460
  specification_version: 4
460
461
  summary: Models used in the Duke Digital Repository