bplmodels 0.0.91 → 0.0.93
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 +4 -4
- data/app/models/bplmodels/characterization.rb +3 -1
- data/app/models/bplmodels/collection.rb +29 -5
- data/app/models/bplmodels/ereader_file.rb +14 -0
- data/app/models/bplmodels/file.rb +152 -12
- data/app/models/bplmodels/institution.rb +73 -1
- data/app/models/bplmodels/marc_file.rb +14 -0
- data/app/models/bplmodels/mods_desc_metadata.rb +124 -8
- data/app/models/bplmodels/object_base.rb +692 -252
- data/app/models/bplmodels/page_metadata.rb +56 -0
- data/app/models/bplmodels/transcription_file.rb +14 -0
- data/app/models/bplmodels/volume.rb +37 -0
- data/app/models/bplmodels/workflow_metadata.rb +6 -0
- data/lib/active_fedora/rdf/indexing_service.rb +88 -0
- data/lib/active_fedora/rdf/term.rb +189 -0
- data/lib/bplmodels/constants.rb +1 -0
- data/lib/bplmodels/datastream_input_funcs.rb +4 -1
- data/lib/bplmodels/finder.rb +104 -0
- data/lib/bplmodels/version.rb +1 -1
- metadata +25 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d0d4c255a889d52e7b90473c99af4462e38e539
|
4
|
+
data.tar.gz: 6421e9f724413858bab031e78c459f1c80c0ab09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d09b6154408234cbe5e06018b79fb98c7463716d4e335bdb563ee3d201475ae0a6644fd310fe0e1dcd688ec8dcd58b5c8bf37641d855c097172fe5a890f611ab
|
7
|
+
data.tar.gz: 09a2f2086cb22716f088c431caaa5d1de31e96757b4c34353ea4166b3c025ca0d369bccfa78d88f4751e9ee3c9eeb292fcfb5b217c4a850e3e50fa1761c832fd
|
@@ -24,7 +24,9 @@ module Bplmodels
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def fits_config_values
|
27
|
-
|
27
|
+
#This is to add that to the end metadata record from FITS...
|
28
|
+
#return {:file_title => :title, :file_author => :creator }
|
29
|
+
return {}
|
28
30
|
end
|
29
31
|
|
30
32
|
def width
|
@@ -8,7 +8,7 @@ module Bplmodels
|
|
8
8
|
|
9
9
|
belongs_to :institutions, :class_name => 'Bplmodels::Institution', :property => :is_member_of
|
10
10
|
|
11
|
-
has_many :exemplary_image, :class_name => "ActiveFedora::Base", :property=> :is_exemplary_image_of
|
11
|
+
#has_many :exemplary_image, :class_name => "ActiveFedora::Base", :property=> :is_exemplary_image_of
|
12
12
|
|
13
13
|
# Uses the Hydra modsCollection profile for collection list
|
14
14
|
#has_metadata :name => "members", :type => Hydra::ModsCollectionMembers
|
@@ -52,25 +52,45 @@ module Bplmodels
|
|
52
52
|
def to_solr(doc = {} )
|
53
53
|
doc = super(doc)
|
54
54
|
|
55
|
+
basic_genre_array = ['Collections']
|
56
|
+
Bplmodels::ObjectBase.find_in_batches('is_member_of_collection_ssim'=>"info:fedora/#{self.pid}") do |group|
|
57
|
+
group.each { |object_id|
|
58
|
+
#object_id_array << Bplmodels::ObjectBase.find(object_id['id']).adapt_to_cmodel
|
59
|
+
basic_genre_array += object_id['genre_basic_ssim'] if object_id['genre_basic_ssim'].present?
|
60
|
+
}
|
61
|
+
end
|
62
|
+
doc['genre_basic_ssim'] = basic_genre_array.uniq!
|
63
|
+
doc['genre_basic_tsim'] = basic_genre_array.uniq!
|
64
|
+
|
55
65
|
# description
|
56
66
|
doc['abstract_tsim'] = self.descMetadata.abstract
|
57
67
|
|
68
|
+
# basic genre
|
69
|
+
=begin
|
70
|
+
basic_genre = 'Collections'
|
71
|
+
doc['genre_basic_ssim'] = basic_genre
|
72
|
+
doc['genre_basic_tsim'] = basic_genre
|
73
|
+
=end
|
74
|
+
|
58
75
|
# institution
|
59
76
|
if self.institutions
|
60
77
|
collex_location = self.institutions.label.to_s
|
61
78
|
doc['physical_location_ssim'] = collex_location
|
62
79
|
doc['physical_location_tsim'] = collex_location
|
63
|
-
doc['institution_pid_si'] = self.institutions.pid
|
64
|
-
# TODO: need to remove the 3 above and refactor apps as necessary
|
65
|
-
# collections (AKA sets) have institutions, not locations
|
66
80
|
doc['institution_name_ssim'] = collex_location
|
67
81
|
doc['institution_name_tsim'] = collex_location
|
68
82
|
doc['institution_pid_ssi'] = self.institutions.pid
|
69
83
|
end
|
70
84
|
|
85
|
+
exemplary_check = Bplmodels::ImageFile.find_with_conditions({"is_exemplary_image_of_ssim"=>"info:fedora/#{self.pid}"}, rows: '1', fl: 'id' )
|
86
|
+
if exemplary_check.present?
|
87
|
+
doc['exemplary_image_ssi'] = exemplary_check.first["id"]
|
88
|
+
end
|
89
|
+
=begin
|
71
90
|
if self.exemplary_image.first != nil
|
72
91
|
doc['exemplary_image_ssi'] = self.exemplary_image.first.pid
|
73
92
|
end
|
93
|
+
=end
|
74
94
|
|
75
95
|
doc
|
76
96
|
|
@@ -88,7 +108,11 @@ module Bplmodels
|
|
88
108
|
args[:namespace_id] ||= ARK_CONFIG_GLOBAL['namespace_commonwealth_pid']
|
89
109
|
|
90
110
|
response = Typhoeus::Request.post(ARK_CONFIG_GLOBAL['url'] + "/arks.json", :params => {:ark=>{:parent_pid=>args[:parent_pid], :namespace_ark => ARK_CONFIG_GLOBAL['namespace_commonwealth_ark'], :namespace_id=>args[:namespace_id], :url_base => ARK_CONFIG_GLOBAL['ark_commonwealth_base'], :model_type => self.name, :local_original_identifier=>args[:local_id], :local_original_identifier_type=>args[:local_id_type]}})
|
91
|
-
|
111
|
+
begin
|
112
|
+
as_json = JSON.parse(response.body)
|
113
|
+
rescue => ex
|
114
|
+
raise('Error in JSON response for minting a collection pid.')
|
115
|
+
end
|
92
116
|
|
93
117
|
Bplmodels::Collection.find_in_batches('id'=>as_json["pid"]) do |group|
|
94
118
|
group.each { |solr_result|
|
@@ -18,6 +18,10 @@ module Bplmodels
|
|
18
18
|
|
19
19
|
has_file_datastream 'access800', versionable: false, label:'access800 datastream'
|
20
20
|
|
21
|
+
has_file_datastream 'ocrMaster', versionable: false, label:'OCR master datastream'
|
22
|
+
has_file_datastream 'djvuCoords', versionable: false, label:'djvu coordinate json datastream'
|
23
|
+
|
24
|
+
|
21
25
|
belongs_to :object, :class_name => "Bplmodels::ObjectBase", :property => :is_image_of
|
22
26
|
|
23
27
|
belongs_to :exemplary, :class_name => "Bplmodels::ObjectBase", :property => :is_exemplary_image_of
|
@@ -29,6 +33,16 @@ module Bplmodels
|
|
29
33
|
|
30
34
|
has_metadata :name => "workflowMetadata", :type => WorkflowMetadata
|
31
35
|
|
36
|
+
has_metadata :name => "pageMetadata", :type => PageMetadata
|
37
|
+
|
38
|
+
def delete
|
39
|
+
#FIXME: This should just not be hardcoded in AVI Processor
|
40
|
+
if ActiveFedora.config.credentials[:url].match('fedora.digitalcommonwealth.org/fedora')
|
41
|
+
#cache_invalidate
|
42
|
+
end
|
43
|
+
super()
|
44
|
+
end
|
45
|
+
|
32
46
|
def apply_default_permissions
|
33
47
|
self.datastreams["rightsMetadata"].update_permissions( "group"=>{"Repository Administrators"=>"edit"} )
|
34
48
|
self.save
|
@@ -46,6 +60,30 @@ module Bplmodels
|
|
46
60
|
doc['marked_for_deletion_reason_ssi'] = self.workflowMetadata.marked_for_deletion.reason.first
|
47
61
|
end
|
48
62
|
|
63
|
+
if ['image/tiff', 'image/png', 'image/jpg', 'image/jp2'].include?(self.productionMaster.mimeType) and self.accessMaster.blank?
|
64
|
+
doc['derivative_processsed_ssi'] = 'false'
|
65
|
+
else
|
66
|
+
doc['derivative_processsed_ssi'] = 'true'
|
67
|
+
end
|
68
|
+
|
69
|
+
if self.ocrMaster.present?
|
70
|
+
doc['ocr_tsiv'] = Bplmodels::DatastreamInputFuncs.strip_value(self.ocrMaster.content.squish)
|
71
|
+
doc['has_ocr_text_bsi'] = true
|
72
|
+
end
|
73
|
+
|
74
|
+
if self.pageMetadata.present?
|
75
|
+
doc['page_type_ssi'] = self.pageMetadata.pageData.page.page_type.first
|
76
|
+
doc['hand_side_ssi'] = self.pageMetadata.pageData.page.hand_side.first
|
77
|
+
doc['page_num_label_ssi'] = self.pageMetadata.pageData.page.page_number.first if self.pageMetadata.pageData.page.page_number.present?
|
78
|
+
doc['page_num_label_type_ssi'] = self.pageMetadata.pageData.page.page_number.sequence.first if self.pageMetadata.pageData.page.page_number.present?
|
79
|
+
#doc['has_ocr_master_ssi'] = self.bookMetadata.book.page_data.page.has_ocrMaster.first
|
80
|
+
#doc['has_djvu_json_ssi'] = self.bookMetadata.book.page_data.page.has_djvu.first
|
81
|
+
|
82
|
+
if self.djvuCoords.present?
|
83
|
+
doc['has_djvu_json_ssi'] = 'true'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
49
87
|
doc['checksum_file_md5_ssi'] = self.productionMaster.checksum
|
50
88
|
|
51
89
|
doc
|
@@ -53,23 +91,59 @@ module Bplmodels
|
|
53
91
|
end
|
54
92
|
|
55
93
|
def generate_derivatives
|
94
|
+
#Sample object on prod: https://fedora.digitalcommonwealth.org/fedora/objects/commonwealth:9w032896b/datastreams/productionMaster/content
|
95
|
+
#Sample object from test book object: https://fedoratest.bpl.org/fedora/objects/bpl-test:rf55zp77f/datastreams/productionMaster/content
|
56
96
|
case self.productionMaster.mimeType
|
57
97
|
when 'application/pdf'
|
58
98
|
#transform_datastream :productionMaster, { :thumb => "100x100>" }
|
99
|
+
|
100
|
+
pdffile = Tempfile.new(['derivative','.pdf'])
|
101
|
+
pdffile.binmode
|
102
|
+
pdffile.write(self.productionMaster.content) #ActiveFedora.config.credentials[:url] + '/objects/' + self.pid + '/datastreams/productionMaster/content'
|
103
|
+
pdffile.close
|
104
|
+
|
105
|
+
current_page = 0
|
106
|
+
total_colors = 0
|
107
|
+
until total_colors > 1 do
|
108
|
+
#Won't work... asks for login with the brackets...
|
109
|
+
img = Magick::Image.read(pdffile.path + '[' + current_page.to_s + ']'){
|
110
|
+
self.quality = 100
|
111
|
+
self.density = 200
|
112
|
+
}.first
|
113
|
+
total_colors = img.total_colors
|
114
|
+
current_page = current_page + 1
|
115
|
+
end
|
116
|
+
|
117
|
+
#This is horrible. But if you don't do this, some PDF files won't come out right at all.
|
118
|
+
#Multiple attempts have failed to fix this but perhaps the bug will be patched in ImageMagick.
|
119
|
+
#To duplicate, one can use the PDF files at: http://libspace.uml.edu/omeka/files/original/7ecb4dc9579b11e2b53ccc2040e58d36.pdf
|
120
|
+
img = Magick::Image.from_blob( img.to_blob { self.format = "jpg" } ).first
|
121
|
+
|
122
|
+
thumb = img.resize_to_fit(300,300)
|
123
|
+
|
124
|
+
self.thumbnail300.content = thumb.to_blob { self.format = "jpg" }
|
125
|
+
self.thumbnail300.mimeType = 'image/jpeg'
|
126
|
+
self.thumbnail300.dsLabel = self.productionMaster.label
|
127
|
+
|
128
|
+
pdffile.delete
|
59
129
|
when 'audio/wav'
|
60
130
|
#transform_datastream :productionMaster, { :mp3 => {format: 'mp3'}, :ogg => {format: 'ogg'} }, processor: :audio
|
61
131
|
when 'video/avi'
|
62
132
|
#transform_datastream :productionMaster, { :mp4 => {format: 'mp4'}, :webm => {format: 'webm'} }, processor: :video
|
63
|
-
when 'image/tiff', 'image/png', 'image/jpg'
|
133
|
+
when 'image/tiff', 'image/png', 'image/jpg', 'image/png'
|
64
134
|
begin
|
65
135
|
transform_datastream :productionMaster, { :testJP2k => { recipe: :default, datastream: 'accessMaster' } }, processor: 'jpeg2k_image'
|
66
136
|
rescue => error
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
137
|
+
# First one is from Blue Books collection. Second one is from commonwealth:xd07m887b
|
138
|
+
if error.message.include?('compressed TIFF files') || error.message.include?("The number of colours associated with the colour space specified using")
|
139
|
+
=begin
|
140
|
+
jp2_img = MiniMagick::Image.read(self.productionMaster.content) do |b|
|
141
|
+
b.format "jp2"
|
142
|
+
end
|
143
|
+
=end
|
144
|
+
jp2_img = MiniMagick::Image.read(self.productionMaster.content)
|
145
|
+
jp2_img.format 'jp2'
|
146
|
+
self.accessMaster.content = jp2_img.to_blob
|
73
147
|
self.accessMaster.mimeType = 'image/jp2'
|
74
148
|
jp2_img.destroy!
|
75
149
|
else
|
@@ -82,13 +156,62 @@ module Bplmodels
|
|
82
156
|
self.thumbnail300.dsLabel = self.productionMaster.label
|
83
157
|
self.access800.dsLabel = self.productionMaster.label
|
84
158
|
when 'image/jpeg' #FIXME
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
159
|
+
=begin
|
160
|
+
jp2_img = MiniMagick::Image.read(self.productionMaster.content) do |b|
|
161
|
+
b.format "jp2"
|
162
|
+
end
|
163
|
+
=end
|
164
|
+
jp2_img = MiniMagick::Image.read(self.productionMaster.content)
|
165
|
+
jp2_img.format 'jp2'
|
166
|
+
|
167
|
+
self.accessMaster.content = jp2_img.to_blob
|
89
168
|
self.accessMaster.mimeType = 'image/jp2'
|
90
169
|
jp2_img.destroy!
|
170
|
+
|
171
|
+
transform_datastream :productionMaster, { :thumb => {size: "300x300>", datastream: 'thumbnail300', format: 'jpg'} }
|
172
|
+
transform_datastream :productionMaster, { :thumb => {size: "x800>", datastream: 'access800', format: 'jpg'} }
|
173
|
+
self.accessMaster.dsLabel = self.productionMaster.label
|
174
|
+
self.thumbnail300.dsLabel = self.productionMaster.label
|
175
|
+
self.access800.dsLabel = self.productionMaster.label
|
176
|
+
when 'image/jp2'
|
177
|
+
self.accessMaster.content = self.productionMaster.content
|
178
|
+
self.accessMaster.mimeType = 'image/jp2'
|
179
|
+
|
180
|
+
|
181
|
+
=begin
|
182
|
+
source_path = "#{ActiveFedora.config.credentials[:url]}/#{self.productionMaster.url}"
|
183
|
+
image = MiniMagick::Image.open(source_path)
|
184
|
+
quality = image['%[channels]'] == 'gray' ? 'gray' : 'color'
|
185
|
+
long_dim = Hydra::Derivatives::Jpeg2kImage.long_dim(image)
|
186
|
+
directives = { recipe: :default, datastream: 'accessMaster' }
|
187
|
+
recipe = Hydra::Derivatives::Jpeg2kImage.kdu_compress_recipe(directives, quality, long_dim)
|
188
|
+
|
189
|
+
file_path = Hydra::Derivatives::Jpeg2kImage.tmp_file('.jp2')
|
190
|
+
image.write file_path
|
191
|
+
|
192
|
+
|
193
|
+
output_file = Hydra::Derivatives::Jpeg2kImage.tmp_file('.jp2')
|
194
|
+
Hydra::Derivatives::Jpeg2kImage.encode(file_path, recipe, output_file)
|
195
|
+
self.accessMaster.content = ::File.open(output_file)
|
196
|
+
self.accessMaster.mimeType = 'image/jp2'
|
197
|
+
#End wonky code
|
198
|
+
|
199
|
+
#TODO: Move this to a function in Hydra Derivatives...
|
200
|
+
self.save
|
201
|
+
image.destroy!
|
202
|
+
File.unlink(output_file)
|
203
|
+
File.unlink(file_path)
|
204
|
+
=end
|
205
|
+
|
206
|
+
transform_datastream :productionMaster, { :thumb => {size: "300x300>", datastream: 'thumbnail300', format: 'jpg'} }
|
207
|
+
transform_datastream :productionMaster, { :thumb => {size: "x800>", datastream: 'access800', format: 'jpg'} }
|
208
|
+
self.accessMaster.dsLabel = self.productionMaster.label
|
209
|
+
self.thumbnail300.dsLabel = self.productionMaster.label
|
210
|
+
self.access800.dsLabel = self.productionMaster.label
|
211
|
+
|
212
|
+
|
91
213
|
end
|
214
|
+
|
92
215
|
end
|
93
216
|
|
94
217
|
def derivative_service(is_new)
|
@@ -117,7 +240,11 @@ module Bplmodels
|
|
117
240
|
args[:namespace_id] ||= ARK_CONFIG_GLOBAL['namespace_commonwealth_pid']
|
118
241
|
|
119
242
|
response = Typhoeus::Request.post(ARK_CONFIG_GLOBAL['url'] + "/arks.json", :params => {:ark=>{:parent_pid=>args[:parent_pid], :namespace_ark => ARK_CONFIG_GLOBAL['namespace_commonwealth_ark'], :namespace_id=>args[:namespace_id], :url_base => ARK_CONFIG_GLOBAL['ark_commonwealth_base'], :model_type => self.name, :local_original_identifier=>args[:local_id], :local_original_identifier_type=>args[:local_id_type]}})
|
120
|
-
|
243
|
+
begin
|
244
|
+
as_json = JSON.parse(response.body)
|
245
|
+
rescue => ex
|
246
|
+
raise('Error in JSON response for minting a file pid.')
|
247
|
+
end
|
121
248
|
|
122
249
|
#Below stopped working suddenly?
|
123
250
|
=begin
|
@@ -147,5 +274,18 @@ module Bplmodels
|
|
147
274
|
return object
|
148
275
|
end
|
149
276
|
|
277
|
+
|
278
|
+
def cache_invalidate
|
279
|
+
response = Typhoeus::Request.post(DERIVATIVE_CONFIG_GLOBAL['url'] + "/processor/objectcacheinvalidation.json", :params => {:file_pid=>self.pid, :environment=>Bplmodels.environment})
|
280
|
+
as_json = JSON.parse(response.body)
|
281
|
+
|
282
|
+
if as_json['result'] == "false"
|
283
|
+
raise "Error Deleting the Cache! Server error!"
|
284
|
+
end
|
285
|
+
|
286
|
+
return true
|
287
|
+
end
|
288
|
+
|
289
|
+
|
150
290
|
end
|
151
291
|
end
|
@@ -5,6 +5,8 @@ module Bplmodels
|
|
5
5
|
|
6
6
|
has_metadata :name => "workflowMetadata", :type => WorkflowMetadata
|
7
7
|
|
8
|
+
has_many :exemplary_image, :class_name => "Bplmodels::File", :property=> :is_exemplary_image_of
|
9
|
+
|
8
10
|
#A collection can have another collection as a member, or an image
|
9
11
|
def insert_member(fedora_object)
|
10
12
|
if (fedora_object.instance_of?(Bplmodels::Collection))
|
@@ -27,9 +29,59 @@ module Bplmodels
|
|
27
29
|
'institution'
|
28
30
|
end
|
29
31
|
|
32
|
+
def new_examplary_image(file_path, file_name)
|
33
|
+
|
34
|
+
#Delete any old images
|
35
|
+
ActiveFedora::Base.find_in_batches('is_exemplary_image_of_ssim'=>"info:fedora/#{self.pid}") do |group|
|
36
|
+
group.each { |image_solr|
|
37
|
+
current_image_file = ActiveFedora::Base.find(image_solr['id']).adapt_to_cmodel
|
38
|
+
current_image_file.delete
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
image_file = Bplmodels::ImageFile.mint(:parent_pid=>self.pid, :local_id=>file_name, :local_id_type=>'File Name', :label=>file_name, :institution_pid=>self.pid)
|
44
|
+
|
45
|
+
datastream = 'productionMaster'
|
46
|
+
image_file.send(datastream).content = ::File.open(file_path)
|
47
|
+
|
48
|
+
if file_name.split('.').last.downcase == 'tif'
|
49
|
+
image_file.send(datastream).mimeType = 'image/tiff'
|
50
|
+
elsif file_name.split('.').last.downcase == 'jpg'
|
51
|
+
image_file.send(datastream).mimeType = 'image/jpeg'
|
52
|
+
elsif file_name.split('.').last.downcase == 'jp2'
|
53
|
+
image_file.send(datastream).mimeType = 'image/jp2'
|
54
|
+
elsif file_name.split('.').last.downcase == 'png'
|
55
|
+
image_file.send(datastream).mimeType = 'image/png'
|
56
|
+
elsif file_name.split('.').last.downcase == 'txt'
|
57
|
+
image_file.send(datastream).mimeType = 'text/plain'
|
58
|
+
else
|
59
|
+
#image_file.send(datastream).mimeType = 'image/jpeg'
|
60
|
+
raise "Could not find a mimeType for #{file_name.split('.').last.downcase}"
|
61
|
+
end
|
62
|
+
|
63
|
+
image_file.send(datastream).dsLabel = file_name.gsub(/\.(tif|TIF|jpg|JPG|jpeg|JPEG|jp2|JP2|png|PNG|txt|TXT)$/, '')
|
64
|
+
|
65
|
+
#FIXME!!!
|
66
|
+
original_file_location = "Uploaded file of #{file_path}"
|
67
|
+
image_file.workflowMetadata.insert_file_source(original_file_location,file_name,datastream)
|
68
|
+
image_file.workflowMetadata.item_status.state = "published"
|
69
|
+
image_file.workflowMetadata.item_status.state_comment = "Added via the institution admin form using Bplmodels new_exemplary_image method on " + Time.new.year.to_s + "/" + Time.new.month.to_s + "/" + Time.new.day.to_s
|
70
|
+
|
71
|
+
image_file.add_relationship(:is_image_of, "info:fedora/" + self.pid)
|
72
|
+
image_file.add_relationship(:is_file_of, "info:fedora/" + self.pid)
|
73
|
+
image_file.add_relationship(:is_exemplary_image_of, "info:fedora/" + self.pid)
|
74
|
+
|
75
|
+
|
76
|
+
image_file.save
|
77
|
+
image_file
|
78
|
+
end
|
79
|
+
|
30
80
|
def to_solr(doc = {} )
|
31
81
|
doc = super(doc)
|
32
82
|
|
83
|
+
|
84
|
+
|
33
85
|
# description
|
34
86
|
doc['abstract_tsim'] = self.descMetadata.abstract
|
35
87
|
|
@@ -118,6 +170,22 @@ module Bplmodels
|
|
118
170
|
doc['institution_pid_si'] = self.pid
|
119
171
|
doc['institution_pid_ssi'] = self.pid
|
120
172
|
|
173
|
+
# basic genre
|
174
|
+
basic_genre = 'Institutions'
|
175
|
+
doc['genre_basic_ssim'] = basic_genre
|
176
|
+
doc['genre_basic_tsim'] = basic_genre
|
177
|
+
|
178
|
+
# physical location
|
179
|
+
# slightly redundant, but needed for faceting and A-Z filtering
|
180
|
+
institution_name = self.descMetadata.mods(0).title.first
|
181
|
+
doc['physical_location_ssim'] = institution_name
|
182
|
+
doc['physical_location_tsim'] = institution_name
|
183
|
+
|
184
|
+
exemplary_check = Bplmodels::ImageFile.find_with_conditions({"is_exemplary_image_of_ssim"=>"info:fedora/#{self.pid}"}, rows: '1', fl: 'id' )
|
185
|
+
if exemplary_check.present?
|
186
|
+
doc['exemplary_image_ssi'] = exemplary_check.first["id"]
|
187
|
+
end
|
188
|
+
|
121
189
|
|
122
190
|
doc
|
123
191
|
|
@@ -135,7 +203,11 @@ module Bplmodels
|
|
135
203
|
#TODO: Duplication check here to prevent over-writes?
|
136
204
|
|
137
205
|
response = Typhoeus::Request.post(ARK_CONFIG_GLOBAL['url'] + "/arks.json", :params => {:ark=>{:namespace_ark => ARK_CONFIG_GLOBAL['namespace_commonwealth_ark'], :namespace_id=>ARK_CONFIG_GLOBAL['namespace_commonwealth_pid'], :url_base => ARK_CONFIG_GLOBAL['ark_commonwealth_base'], :model_type => self.name, :local_original_identifier=>args[:local_id], :local_original_identifier_type=>args[:local_id_type]}})
|
138
|
-
|
206
|
+
begin
|
207
|
+
as_json = JSON.parse(response.body)
|
208
|
+
rescue => ex
|
209
|
+
raise('Error in JSON response for minting an institution pid.')
|
210
|
+
end
|
139
211
|
|
140
212
|
Bplmodels::Institution.find_in_batches('id'=>as_json["pid"]) do |group|
|
141
213
|
group.each { |solr_result|
|