to_spotlight 0.1 → 0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 723cfc28349b5d450764bd91b70871ea4b2b326245a26b54ce84473263fb6ee3
|
4
|
+
data.tar.gz: 3f8170875f2b4fc728ea963d505ead581cc9270d2e14f358b102df1780016994
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: babde70f0e14fc18baacaa81069ca4ae66b4dda99eb5840f2ce7e9746f1a4f614548a78056641fb4be5d08371c76accef48ebdb4a47d4858cc56d728c97ce32a
|
7
|
+
data.tar.gz: b7a3a177ed371b5393008b8cf9d1b2c4a5e5508fd6085c0e349ea3af9aece78931d7363b34246c1971fa6ee2563f73a6afa5f1e43b8a317656a199a141b8fd5d
|
@@ -21,14 +21,8 @@ module ToSpotlight
|
|
21
21
|
|
22
22
|
def receive
|
23
23
|
return unless params[:token]
|
24
|
-
|
25
|
-
mappings = params
|
26
|
-
collection_id = params.permit!.to_h[:collection_id]
|
27
|
-
exhibit_id = params.permit!.to_h[:exhibit_id]
|
28
|
-
@transfer = ToSpotlight::SpotlightTransfer.new user: user,
|
29
|
-
mappings: mappings,
|
30
|
-
collection_id: collection_id,
|
31
|
-
exhibit_id: exhibit_id
|
24
|
+
@transfer = ToSpotlight::SpotlightTransfer.new get_transfer_attributes
|
25
|
+
@transfer.mappings = params[:mappings]
|
32
26
|
if @transfer.save
|
33
27
|
render plain: 'Transfer Request Received'
|
34
28
|
else
|
@@ -45,13 +39,12 @@ module ToSpotlight
|
|
45
39
|
transfer = ToSpotlight::SpotlightTransfer.find params[:transfer_id]
|
46
40
|
works = ::ActiveFedora::Base.where member_of_collection_ids_ssim: transfer.collection_id
|
47
41
|
mappings = mapping_invert transfer.mappings
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
# 'Content-Type' => 'application/json'
|
42
|
+
if now
|
43
|
+
SpotlightTransferJob.perform_later(works.to_a, mappings, transfer)
|
44
|
+
else
|
45
|
+
SpotlightTransferJob.set(wait_until: Date.today.end_of_day)
|
46
|
+
.perform_later(works.to_a, mappings, transfer)
|
47
|
+
end
|
55
48
|
|
56
49
|
end
|
57
50
|
|
@@ -118,5 +111,12 @@ module ToSpotlight
|
|
118
111
|
eval a_of_a.map{|a| a.inspect}.join(' & ')
|
119
112
|
end
|
120
113
|
|
114
|
+
def get_transfer_attributes
|
115
|
+
params.require(:transfer).permit(:user,
|
116
|
+
:exhibit_id,
|
117
|
+
:collection_id,
|
118
|
+
:spotlight_url)
|
119
|
+
end
|
120
|
+
|
121
121
|
end
|
122
122
|
end
|
@@ -2,7 +2,7 @@ module ToSpotlight
|
|
2
2
|
class SpotlightTransferJob < ActiveJob::Base
|
3
3
|
queue_as :default
|
4
4
|
|
5
|
-
def perform(works, mappings)
|
5
|
+
def perform(works, mappings, transfer)
|
6
6
|
base_url = ::Account.where(tenant: Apartment::Tenant.current).first.cname
|
7
7
|
csv_headers = %w[url full_title_tesim] + mappings.keys + %w[children]
|
8
8
|
csv_array = [csv_headers.join(',')]
|
@@ -16,21 +16,21 @@ module ToSpotlight
|
|
16
16
|
# next if wk.file_set_ids.length>1
|
17
17
|
#end
|
18
18
|
#index += 1
|
19
|
-
comp = wk.file_set_ids.
|
19
|
+
comp = false #wk.file_set_ids.length > 1
|
20
20
|
children = []
|
21
21
|
if comp
|
22
22
|
index = wk.ordered_file_set_ids.length * -1
|
23
23
|
wk.ordered_file_set_ids.each do |f_id|
|
24
|
-
csv_array << empty_fs_line(f_id, csv_headers.length-1)
|
24
|
+
csv_array << empty_fs_line(f_id, csv_headers.length - 1)
|
25
25
|
children << index
|
26
26
|
index += 1
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
doc = ::SolrDocument.find wk.id
|
31
|
-
|
31
|
+
|
32
32
|
line_hash = {}
|
33
|
-
line_hash['url'] = "http://#{base_url}/
|
33
|
+
line_hash['url'] = "http://#{base_url}/concern/#{underscore_name(wk)}/#{wk.id}/manifest.json" #url
|
34
34
|
line_hash['full_title_tesim'] = (doc.title.length > 1 ? doc.title.join('; ') : doc.title.first) #full_title_tesim
|
35
35
|
|
36
36
|
mappings.each do |skey, field|
|
@@ -50,6 +50,13 @@ module ToSpotlight
|
|
50
50
|
File.open(dir.join(filename), 'wb') do |file|
|
51
51
|
file.write(csv_array.join("\n"))
|
52
52
|
end
|
53
|
+
byebug
|
54
|
+
res = ::Net::HTTP.post URI("#{transfer.spotlight_url}/from_hyrax/receive"),
|
55
|
+
{ csv_url: "https://#{base_url}/uploads/csvs/#{filename}",
|
56
|
+
transfer: transfer.attributes.except(:mappings), #only allow user+exhibit ??
|
57
|
+
token: 'secret_token' }.to_json,
|
58
|
+
'Content-Type' => 'application/json'
|
59
|
+
|
53
60
|
end
|
54
61
|
|
55
62
|
def base_url
|
@@ -57,7 +64,7 @@ module ToSpotlight
|
|
57
64
|
end
|
58
65
|
|
59
66
|
def empty_fs_line fs_id, commas
|
60
|
-
"http://#{base_url}downloads/#{fs_id}?locale=en" + (',' * commas)
|
67
|
+
"http://#{base_url}/downloads/#{fs_id}?locale=en" + (',' * commas)
|
61
68
|
end
|
62
69
|
|
63
70
|
def create_cell w, field
|
@@ -72,6 +79,10 @@ module ToSpotlight
|
|
72
79
|
end
|
73
80
|
end
|
74
81
|
|
82
|
+
def underscore_name work
|
83
|
+
work.class.to_s.underscore + 's'
|
84
|
+
end
|
85
|
+
|
75
86
|
def get_location list
|
76
87
|
output = []
|
77
88
|
list.each do |loc|
|
@@ -83,11 +94,11 @@ module ToSpotlight
|
|
83
94
|
def get_resource list
|
84
95
|
output = []
|
85
96
|
list.each do |url|
|
86
|
-
if url.include? 'http'
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
97
|
+
output << if url.include? 'http'
|
98
|
+
Hyrax::ResourceTypesService.label(url)
|
99
|
+
else
|
100
|
+
url
|
101
|
+
end
|
91
102
|
end
|
92
103
|
output.join('; ')
|
93
104
|
end
|
@@ -95,11 +106,11 @@ module ToSpotlight
|
|
95
106
|
def get_rights list
|
96
107
|
output = []
|
97
108
|
list.each do |url|
|
98
|
-
if url.include? 'http'
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
109
|
+
output << if url.include? 'http'
|
110
|
+
::VaultRightsStatementsService.label(url)
|
111
|
+
else
|
112
|
+
url
|
113
|
+
end
|
103
114
|
end
|
104
115
|
#output = list.map { |url| url.include? "http" ? IaffRightsStatementService.label(url) : url }
|
105
116
|
output.join('; ')
|
data/lib/to_spotlight/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sephirothkod
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|