libis-services 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/lib/libis-services.rb +1 -0
- data/lib/libis/services.rb +21 -0
- data/lib/libis/services/aleph/search.rb +157 -0
- data/lib/libis/services/collective_access.rb +1 -0
- data/lib/libis/services/collective_access/cataloguing.rb +48 -0
- data/lib/libis/services/collective_access/connector.rb +151 -0
- data/lib/libis/services/collective_access/item_info.rb +36 -0
- data/lib/libis/services/collective_access/search.rb +26 -0
- data/lib/libis/services/collective_access/service.rb +80 -0
- data/lib/libis/services/digitool/digital_entity_manager.rb +223 -0
- data/lib/libis/services/digitool/digitool_connector.rb +46 -0
- data/lib/libis/services/digitool/meta_data_manager.rb +193 -0
- data/lib/libis/services/extend/http_fetch.rb +63 -0
- data/lib/libis/services/generic_search.rb +38 -0
- data/lib/libis/services/http_error.rb +21 -0
- data/lib/libis/services/oracle_client.rb +47 -0
- data/lib/libis/services/primo.rb +2 -0
- data/lib/libis/services/primo/limo.rb +33 -0
- data/lib/libis/services/primo/search.rb +46 -0
- data/lib/libis/services/rest_client.rb +66 -0
- data/lib/libis/services/rosetta.rb +1 -0
- data/lib/libis/services/rosetta/client.rb +107 -0
- data/lib/libis/services/rosetta/collection_handler.rb +45 -0
- data/lib/libis/services/rosetta/collection_info.rb +35 -0
- data/lib/libis/services/rosetta/deposit_activity.rb +48 -0
- data/lib/libis/services/rosetta/deposit_handler.rb +187 -0
- data/lib/libis/services/rosetta/ie.rb +19 -0
- data/lib/libis/services/rosetta/ie_handler.rb +29 -0
- data/lib/libis/services/rosetta/pds_handler.rb +60 -0
- data/lib/libis/services/rosetta/producer.rb +71 -0
- data/lib/libis/services/rosetta/producer_handler.rb +125 -0
- data/lib/libis/services/rosetta/service.rb +399 -0
- data/lib/libis/services/rosetta/sip.rb +26 -0
- data/lib/libis/services/rosetta/sip_handler.rb +30 -0
- data/lib/libis/services/rosetta/user.rb +70 -0
- data/lib/libis/services/rosetta/user_manager.rb +28 -0
- data/lib/libis/services/scope/search.rb +46 -0
- data/lib/libis/services/search_factory.rb +40 -0
- data/lib/libis/services/sharepoint/connector.rb +236 -0
- data/lib/libis/services/sharepoint/search.rb +19 -0
- data/lib/libis/services/soap_client.rb +57 -0
- data/lib/libis/services/soap_error.rb +22 -0
- data/lib/libis/services/version.rb +5 -0
- data/libis-services.gemspec +38 -0
- data/spec/primo_limo_spec.rb +394 -0
- data/spec/primo_search_spec.rb +39 -0
- data/spec/rosetta_collection_spec.rb +206 -0
- data/spec/rosetta_deposit_spec.rb +82 -0
- data/spec/rosetta_ie_spec.rb +345 -0
- data/spec/rosetta_pds_spec.rb +79 -0
- data/spec/rosetta_producer_spec.rb +270 -0
- data/spec/rosetta_sip_spec.rb +39 -0
- data/spec/spec_helper.rb +12 -0
- metadata +307 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'libis/tools/extend/hash'
|
3
|
+
require 'libis/tools/xml_document'
|
4
|
+
require_relative 'producer'
|
5
|
+
require_relative 'user'
|
6
|
+
|
7
|
+
require_relative 'client'
|
8
|
+
module Libis
|
9
|
+
module Services
|
10
|
+
module Rosetta
|
11
|
+
|
12
|
+
class ProducerHandler < Libis::Services::Rosetta::Client
|
13
|
+
|
14
|
+
|
15
|
+
def initialize(base_url = 'http://depot.lias.be', options = {})
|
16
|
+
super 'backoffice', 'ProducerWebServices', {url: base_url}.merge(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def user_id(external_id)
|
20
|
+
call :get_internal_user_id_by_external_id, arg0: external_id
|
21
|
+
end
|
22
|
+
|
23
|
+
def is_user?(user_id)
|
24
|
+
call :is_user_exists, arg0: @pds_handle, arg1: user_id
|
25
|
+
end
|
26
|
+
|
27
|
+
def producer(producer_id, producer_info = nil)
|
28
|
+
if producer_info
|
29
|
+
info = producer(producer_id)
|
30
|
+
return nil if info.nil?
|
31
|
+
(producer_info.is_a?(Rosetta::Producer) ? producer_info.attributes : producer_info).each do |name, value|
|
32
|
+
info[name] = value
|
33
|
+
end
|
34
|
+
call :update_producer, arg0: @pds_handle, arg1: producer_id, arg2: info.to_xml
|
35
|
+
else
|
36
|
+
request_object :get_producer_details, Rosetta::Producer, arg0: @pds_handle, arg1: producer_id
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def new_producer(producer_info)
|
41
|
+
producer_info = Rosetta::Producer.new(producer_info) unless producer_info.is_a?(Rosetta::Producer)
|
42
|
+
call :create_producer, arg0: @pds_handle, arg1: producer_info.to_xml
|
43
|
+
end
|
44
|
+
|
45
|
+
def delete_producer(producer_id)
|
46
|
+
call :remove_producer, arg0: @pds_handle, arg1: producer_id
|
47
|
+
end
|
48
|
+
|
49
|
+
def agent(agent_id, agent_info = nil)
|
50
|
+
if agent_info
|
51
|
+
info = agent(agent_id)
|
52
|
+
return nil if info.nil?
|
53
|
+
(agent_info.is_a?(Rosetta::User) ? agent_info.attributes : agent_info).each do |name, value|
|
54
|
+
info[name] = value
|
55
|
+
end
|
56
|
+
call :update_producer_agent, arg0: @pds_handle, arg1: agent_id, arg2: info.to_xml
|
57
|
+
else
|
58
|
+
request_object :get_producer_agent, Rosetta::User, arg0: @pds_handle, arg1: agent_id
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def new_agent(agent_info)
|
63
|
+
agent_info = Rosetta::User.new(agent_info) unless agent_info.is_a?(Rosetta::User)
|
64
|
+
call :create_producer_agent, arg0: @pds_handle, arg1: agent_info.to_xml
|
65
|
+
end
|
66
|
+
|
67
|
+
def delete_agent(agent_id)
|
68
|
+
call :remove_producer_agent, arg0: @pds_handle, arg1: agent_id
|
69
|
+
end
|
70
|
+
|
71
|
+
def link_agent(agent_id, producer_id)
|
72
|
+
call :link_producer_agent_to_producer, arg0: @pds_handle, arg1: producer_id, arg2: agent_id
|
73
|
+
end
|
74
|
+
|
75
|
+
def unlink_agent(agent_id, producer_id)
|
76
|
+
call :unlink_producer_agent_from_producer, arg0: @pds_handle, arg1: producer_id, arg2: agent_id
|
77
|
+
end
|
78
|
+
|
79
|
+
def agent_producers(agent_id, institution = nil)
|
80
|
+
if institution
|
81
|
+
request_array :get_producers_of_producer_agent_with_ins, arg0: agent_id, arg1: institution
|
82
|
+
else
|
83
|
+
request_array :get_producers_of_producer_agent, arg0: agent_id
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def contact(contact_id, contact_info = nil)
|
88
|
+
if contact_info
|
89
|
+
info = contact(contact_id)
|
90
|
+
return nil if info.nil?
|
91
|
+
(contact_info.is_a?(Rosetta::User) ? contact_info.attributes : contact_info).each do |name, value|
|
92
|
+
info[name] = value
|
93
|
+
end
|
94
|
+
call :update_contact, arg0: @pds_handle, arg1: contact_id, arg2: info.to_xml
|
95
|
+
else
|
96
|
+
request_object :get_contact, Rosetta::User, arg0: @pds_handle, arg1: contact_id
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def new_contact(contact_info)
|
101
|
+
contact_info = Rosetta::User.new(contact_info) unless contact_info.is_a?(Rosetta::User)
|
102
|
+
call :create_contact, arg0: @pds_handle, arg1: contact_info.to_xml
|
103
|
+
end
|
104
|
+
|
105
|
+
def delete_contact(contact_id)
|
106
|
+
call :remove_contact, arg0: @pds_handle, arg1: contact_id
|
107
|
+
end
|
108
|
+
|
109
|
+
def link_contact(contact_id, producer_id, primary = true)
|
110
|
+
call :link_contact_to_producer, arg0: @pds_handle, arg1: producer_id, arg2: contact_id, arg3: (!!primary).to_s.upcase
|
111
|
+
end
|
112
|
+
|
113
|
+
def unlink_contact(contact_id, producer_id)
|
114
|
+
call :unlink_contact_from_producer, arg0: @pds_handle, arg1: producer_id, arg2: contact_id
|
115
|
+
end
|
116
|
+
|
117
|
+
def material_flows(producer_id)
|
118
|
+
request_array :get_material_flows_of_producer, arg0: producer_id
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,399 @@
|
|
1
|
+
require_relative 'pds_handler'
|
2
|
+
require_relative 'producer_handler'
|
3
|
+
require_relative 'deposit_handler'
|
4
|
+
require_relative 'sip_handler'
|
5
|
+
require_relative 'ie_handler'
|
6
|
+
require_relative 'collection_handler'
|
7
|
+
|
8
|
+
require 'libis/tools/mets_file'
|
9
|
+
|
10
|
+
require 'csv'
|
11
|
+
require 'write_xlsx'
|
12
|
+
require 'backports'
|
13
|
+
require 'awesome_print'
|
14
|
+
|
15
|
+
module Libis
|
16
|
+
module Services
|
17
|
+
module Rosetta
|
18
|
+
|
19
|
+
class Service
|
20
|
+
|
21
|
+
attr_reader :pds_service, :producer_service, :deposit_service, :sip_service, :ie_service, :collection_service
|
22
|
+
|
23
|
+
# @param [String] base_url
|
24
|
+
def initialize(base_url = 'http://depot.lias.be', pds_url = 'https://pds.libis.be')
|
25
|
+
@pds_service = Libis::Services::Rosetta::PdsHandler.new pds_url
|
26
|
+
@producer_service = Libis::Services::Rosetta::ProducerHandler.new base_url
|
27
|
+
@deposit_service = Libis::Services::Rosetta::DepositHandler.new base_url
|
28
|
+
@sip_service = Libis::Services::Rosetta::SipHandler.new base_url
|
29
|
+
@ie_service = Libis::Services::Rosetta::IeHandler.new base_url
|
30
|
+
@collection_service = Libis::Services::Rosetta::CollectionHandler.new base_url
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param [String] name
|
34
|
+
# @param [String] passwd
|
35
|
+
# @param [String] institute
|
36
|
+
# @return [String] PDS handle
|
37
|
+
def login(name, passwd, institute)
|
38
|
+
handle = @pds_service.login(name, passwd, institute)
|
39
|
+
@producer_service.pds_handle = handle
|
40
|
+
@deposit_service.pds_handle = handle
|
41
|
+
@sip_service.pds_handle = handle
|
42
|
+
@ie_service.pds_handle = handle
|
43
|
+
handle
|
44
|
+
end
|
45
|
+
|
46
|
+
# Searches for all deposits in the date range and for the given flow id. The method returns a list of all
|
47
|
+
# deposits, including information about the sip, the related IEs and a breakdown of the IE's METS file.
|
48
|
+
#
|
49
|
+
# @param [String] from_date
|
50
|
+
# @param [String] to_date
|
51
|
+
# @param [String] flow_id
|
52
|
+
# @param [String] options
|
53
|
+
# @return [Hash] detailed deposit information
|
54
|
+
def get_deposits(from_date, to_date, flow_id, options = {})
|
55
|
+
deposits = @deposit_service.get_by_submit_flow(from_date, to_date, flow_id, {status: 'Approved'}.merge(options))
|
56
|
+
deposits.each do |deposit|
|
57
|
+
ies = @sip_service.get_ies(deposit[:sip])
|
58
|
+
ies_info = ies.map do |ie|
|
59
|
+
title = nil
|
60
|
+
id = nil
|
61
|
+
begin
|
62
|
+
md = @ie_service.get_metadata(ie).to_hash['mets:mets']
|
63
|
+
dc = md['mets:dmdSec']['mets:mdWrap']['mets:xmlData']['dc:record']
|
64
|
+
title = dc['dc:title']
|
65
|
+
id = dc['dc:identifier']
|
66
|
+
rescue
|
67
|
+
# ignore
|
68
|
+
end
|
69
|
+
# retrieve ie mets file
|
70
|
+
ie_info = @ie_service.get_mets(ie)
|
71
|
+
{
|
72
|
+
ie: ie,
|
73
|
+
title: title,
|
74
|
+
id: id,
|
75
|
+
content: ie_info
|
76
|
+
}.cleanup
|
77
|
+
end
|
78
|
+
deposit[:ies] = ies_info
|
79
|
+
end
|
80
|
+
deposits.sort! { |x, y| x[:ies][0][:id] <=> y[:ies][0][:id] }
|
81
|
+
# deposits.each { |dep| dep[:ies].each { |ie| puts "DEP ##{dep[:deposit]} - SIP ##{dep[:sip]} - IE ##{ie[:ie]} - #{ie[:id]} - #{ie[:title]}" } }
|
82
|
+
deposits
|
83
|
+
end
|
84
|
+
|
85
|
+
# @param [String] report_file
|
86
|
+
# @param [Array] deposits
|
87
|
+
def get_deposit_report(report_file, deposits)
|
88
|
+
# create and open Workbook
|
89
|
+
workbook = WriteXLSX.new(report_file)
|
90
|
+
|
91
|
+
# set up some formatting
|
92
|
+
ie_data_header_format = workbook.add_format(bold: 1)
|
93
|
+
rep_name_format = workbook.add_format(bold: 1)
|
94
|
+
file_header_format = workbook.add_format(bold: 1)
|
95
|
+
|
96
|
+
# First Sheet is an overview of all dossiers
|
97
|
+
overview = workbook.add_worksheet('IE overview')
|
98
|
+
ie_data_keys = Set.new %w[id dossier link disposition]
|
99
|
+
ie_list = [] # ie info will be collected in this array to be printed later
|
100
|
+
|
101
|
+
# iterate over all deposits
|
102
|
+
deposits.each do |deposit|
|
103
|
+
# iterate over all IEs
|
104
|
+
deposit[:ies].sort { |x, y| x[:id] <=> y[:id] }.each do |ie|
|
105
|
+
@ie = ie
|
106
|
+
id = (ie[:id] || ie[:ie])
|
107
|
+
# noinspection RubyStringKeysInHashInspection
|
108
|
+
ie_data = {
|
109
|
+
'id' => "#{id}",
|
110
|
+
'dossier' => ie[:title],
|
111
|
+
'disposition' => (ie[:content][:dmd]['date'] rescue nil),
|
112
|
+
'link' => "http://depot.lias.be/delivery/DeliveryManagerServlet?dps_pid=#{ie[:ie]}",
|
113
|
+
}.cleanup
|
114
|
+
[
|
115
|
+
# (ie[:content][:dmd] rescue nil),
|
116
|
+
(ie[:content][:amd][:tech]['generalIECharacteristics'] rescue nil),
|
117
|
+
(ie[:content][:amd][:rights]['accessRightsPolicy'] rescue nil)
|
118
|
+
].each do |data|
|
119
|
+
ie_data.merge! data if data
|
120
|
+
end
|
121
|
+
dossier_sheet = workbook.add_worksheet(id.gsub(/[\\\/*?]+/, '.'))
|
122
|
+
dossier_row = 0
|
123
|
+
|
124
|
+
ie[:content].each do |rep_name, rep|
|
125
|
+
next unless rep_name.is_a?(String)
|
126
|
+
@rep = rep
|
127
|
+
file_data_keys = Set.new %w(folder naam link mimetype puid formaat versie)
|
128
|
+
file_list = []
|
129
|
+
|
130
|
+
dossier_sheet.write_row(dossier_row, 0, [rep_name], rep_name_format)
|
131
|
+
%w(preservationType usageType).each do |key|
|
132
|
+
dossier_row += 1
|
133
|
+
dossier_sheet.write_row(
|
134
|
+
dossier_row, 0,
|
135
|
+
[
|
136
|
+
key.underscore.gsub('_', ' '),
|
137
|
+
rep[:amd][:tech]['generalRepCharacteristics'][key]
|
138
|
+
]
|
139
|
+
)
|
140
|
+
end
|
141
|
+
dossier_row += 2
|
142
|
+
|
143
|
+
file_proc = lambda do |file|
|
144
|
+
@file = file
|
145
|
+
if file[:id]
|
146
|
+
tech = file[:amd][:tech]
|
147
|
+
# noinspection RubyStringKeysInHashInspection
|
148
|
+
file_data = {
|
149
|
+
'folder' => (tech['generalFileCharacteristics']['fileOriginalPath'] rescue '').split('/')[1..-1].join('\\'),
|
150
|
+
'naam' => (tech['generalFileCharacteristics']['fileOriginalName'] rescue nil),
|
151
|
+
'link' => ("http://depot.lias.be/delivery/DeliveryManagerServlet?dps_pid=#{file[:id]}" rescue nil),
|
152
|
+
'mimetype' => (tech['fileFormat']['mimeType'] rescue nil),
|
153
|
+
'puid' => (tech['fileFormat']['formatRegistryId'] rescue nil),
|
154
|
+
'formaat' => (tech['fileFormat']['formatDescription'] rescue nil),
|
155
|
+
'versie' => (tech['fileFormat']['formatVersion'] rescue nil),
|
156
|
+
'viruscheck' => (tech['fileVirusCheck']['status'] rescue nil),
|
157
|
+
'file_type' => (tech['generalFileCharacteristics']['FileEntityType']),
|
158
|
+
'groep' => file[:group],
|
159
|
+
}
|
160
|
+
data = tech['fileValidation']
|
161
|
+
if data
|
162
|
+
valid = (data['isValid'] == 'true') rescue nil
|
163
|
+
well_formed = (data['isWellFormed'] == 'true') rescue nil
|
164
|
+
file_data['validatie'] = if valid && well_formed
|
165
|
+
'OK'
|
166
|
+
else
|
167
|
+
'niet OK'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
data = tech['significantProperties']
|
171
|
+
if data
|
172
|
+
file_data[data['significantPropertiesType']] = data['significantPropertiesValue']
|
173
|
+
end
|
174
|
+
data = file[:dmd]
|
175
|
+
if data
|
176
|
+
data.each { |key, value| file_data[key] = value }
|
177
|
+
end
|
178
|
+
file_list << file_data
|
179
|
+
file_data_keys.merge file_data.keys
|
180
|
+
else
|
181
|
+
file.each do |_, value|
|
182
|
+
next unless value.is_a? Hash
|
183
|
+
# noinspection RubyScope
|
184
|
+
file_proc.call(value)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
rep.keys.each do |key|
|
190
|
+
file_proc.call(rep[key]) if key.is_a?(String)
|
191
|
+
end
|
192
|
+
|
193
|
+
table_start = dossier_row
|
194
|
+
dossier_sheet.write_row(dossier_row, 0, file_data_keys.to_a, file_header_format)
|
195
|
+
file_list.each do |file_info|
|
196
|
+
dossier_row += 1
|
197
|
+
file_data = []
|
198
|
+
file_data_keys.each { |key| file_data << file_info[key] }
|
199
|
+
dossier_sheet.write_row(dossier_row, 0, file_data)
|
200
|
+
end
|
201
|
+
table_end = dossier_row
|
202
|
+
|
203
|
+
dossier_sheet.add_table(
|
204
|
+
table_start, 0, table_end, file_data_keys.size - 1,
|
205
|
+
style: 'Table Style Medium 16', name: rep[:id],
|
206
|
+
columns: file_data_keys.map { |key| {header: key} }
|
207
|
+
)
|
208
|
+
|
209
|
+
dossier_row += 2
|
210
|
+
end
|
211
|
+
ie_data_keys.merge ie_data.keys
|
212
|
+
ie_list << ie_data
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# write ie data to overview worksheet
|
217
|
+
overview.write_row(0, 0, ie_data_keys.to_a, ie_data_header_format)
|
218
|
+
overview_row = 1
|
219
|
+
ie_list.each do |ie_info|
|
220
|
+
ie_data = []
|
221
|
+
ie_data_keys.each { |key| ie_data << ie_info[key] }
|
222
|
+
overview.write_row(overview_row, 0, ie_data)
|
223
|
+
overview_row += 1
|
224
|
+
end
|
225
|
+
|
226
|
+
rescue Exception => e
|
227
|
+
puts e.message
|
228
|
+
puts e.backtrace
|
229
|
+
# close and save workbook
|
230
|
+
ensure
|
231
|
+
workbook.close
|
232
|
+
end
|
233
|
+
|
234
|
+
# @param [String] report_file
|
235
|
+
# @param [Array] deposits
|
236
|
+
def get_dav_deposit_report(report_file, deposits)
|
237
|
+
# create and open Workbook
|
238
|
+
workbook = WriteXLSX.new(report_file)
|
239
|
+
|
240
|
+
# set up some formatting
|
241
|
+
ie_data_header_format = workbook.add_format(bold: 1)
|
242
|
+
rep_name_format = workbook.add_format(bold: 1)
|
243
|
+
file_header_format = workbook.add_format(bold: 1)
|
244
|
+
|
245
|
+
# First Sheet is an overview of all dossiers
|
246
|
+
overview = workbook.add_worksheet('dossier overzicht')
|
247
|
+
ie_data_keys = Set.new %w[id dossier link disposition]
|
248
|
+
ie_list = [] # ie info will be collected in this array to be printed later
|
249
|
+
|
250
|
+
# iterate over all deposits
|
251
|
+
deposits.each do |deposit|
|
252
|
+
# iterate over all IEs
|
253
|
+
deposit[:ies].sort { |x, y| x[:id] <=> y[:id] }.each do |ie|
|
254
|
+
@ie = ie
|
255
|
+
id = (ie[:id] || ie[:ie])
|
256
|
+
# noinspection RubyStringKeysInHashInspection
|
257
|
+
ie_data = {
|
258
|
+
'id' => "#{id}",
|
259
|
+
'dossier' => ie[:title],
|
260
|
+
'disposition' => (ie[:content][:dmd]['date'] rescue nil),
|
261
|
+
'link' => "http://depot.lias.be/delivery/DeliveryManagerServlet?dps_pid=#{ie[:ie]}",
|
262
|
+
}.cleanup
|
263
|
+
[
|
264
|
+
# (ie[:content][:dmd] rescue nil),
|
265
|
+
(ie[:content][:amd][:tech]['generalIECharacteristics'] rescue nil),
|
266
|
+
(ie[:content][:amd][:rights]['accessRightsPolicy'] rescue nil)
|
267
|
+
].each do |data|
|
268
|
+
ie_data.merge! data if data
|
269
|
+
end
|
270
|
+
dossier_sheet = workbook.add_worksheet(id.gsub(/[\\\/*?]+/, '.'))
|
271
|
+
dossier_row = 0
|
272
|
+
|
273
|
+
ie[:content].each do |rep_name, rep|
|
274
|
+
next unless rep_name.is_a?(String)
|
275
|
+
@rep = rep
|
276
|
+
file_data_keys = Set.new %w(folder naam link mimetype puid formaat versie)
|
277
|
+
file_list = []
|
278
|
+
|
279
|
+
dossier_sheet.write_row(dossier_row, 0, [rep_name], rep_name_format)
|
280
|
+
%w(preservationType usageType).each do |key|
|
281
|
+
dossier_row += 1
|
282
|
+
dossier_sheet.write_row(
|
283
|
+
dossier_row, 0,
|
284
|
+
[
|
285
|
+
key.underscore.gsub('_', ' '),
|
286
|
+
rep[:amd][:tech]['generalRepCharacteristics'][key]
|
287
|
+
]
|
288
|
+
)
|
289
|
+
end
|
290
|
+
dossier_row += 2
|
291
|
+
|
292
|
+
file_proc = lambda do |file|
|
293
|
+
@file = file
|
294
|
+
if file[:id]
|
295
|
+
tech = file[:amd][:tech]
|
296
|
+
# noinspection RubyStringKeysInHashInspection
|
297
|
+
file_data = {
|
298
|
+
'folder' => (tech['generalFileCharacteristics']['fileOriginalPath'] rescue '').split('/')[1..-1].join('\\'),
|
299
|
+
'naam' => (tech['generalFileCharacteristics']['fileOriginalName'] rescue nil),
|
300
|
+
'link' => ("http://depot.lias.be/delivery/DeliveryManagerServlet?dps_pid=#{file[:id]}" rescue nil),
|
301
|
+
'mimetype' => (tech['fileFormat']['mimeType'] rescue nil),
|
302
|
+
'puid' => (tech['fileFormat']['formatRegistryId'] rescue nil),
|
303
|
+
'formaat' => (tech['fileFormat']['formatDescription'] rescue nil),
|
304
|
+
'versie' => (tech['fileFormat']['formatVersion'] rescue nil),
|
305
|
+
'viruscheck' => (tech['fileVirusCheck']['status'] rescue nil),
|
306
|
+
'file_type' => (tech['generalFileCharacteristics']['FileEntityType']),
|
307
|
+
'groep' => file[:group],
|
308
|
+
}
|
309
|
+
data = tech['fileValidation']
|
310
|
+
if data
|
311
|
+
valid = (data['isValid'] == 'true') rescue nil
|
312
|
+
well_formed = (data['isWellFormed'] == 'true') rescue nil
|
313
|
+
file_data['validatie'] = if valid && well_formed
|
314
|
+
'OK'
|
315
|
+
else
|
316
|
+
'niet OK'
|
317
|
+
end
|
318
|
+
end
|
319
|
+
data = tech['significantProperties']
|
320
|
+
if data
|
321
|
+
file_data[data['significantPropertiesType']] = data['significantPropertiesValue']
|
322
|
+
end
|
323
|
+
data = file[:dmd]
|
324
|
+
if data
|
325
|
+
data.each { |key, value| file_data[key] = value }
|
326
|
+
end
|
327
|
+
file_list << file_data
|
328
|
+
file_data_keys.merge file_data.keys
|
329
|
+
else
|
330
|
+
file.each do |_, value|
|
331
|
+
next unless value.is_a? Hash
|
332
|
+
# noinspection RubyScope
|
333
|
+
file_proc.call(value)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
rep.keys.each do |key|
|
339
|
+
file_proc.call(rep[key]) if key.is_a?(String)
|
340
|
+
end
|
341
|
+
|
342
|
+
table_start = dossier_row
|
343
|
+
dossier_sheet.write_row(dossier_row, 0, file_data_keys.to_a, file_header_format)
|
344
|
+
file_list.each do |file_info|
|
345
|
+
dossier_row += 1
|
346
|
+
file_data = []
|
347
|
+
file_data_keys.each { |key| file_data << file_info[key] }
|
348
|
+
dossier_sheet.write_row(dossier_row, 0, file_data)
|
349
|
+
end
|
350
|
+
table_end = dossier_row
|
351
|
+
|
352
|
+
dossier_sheet.add_table(
|
353
|
+
table_start, 0, table_end, file_data_keys.size - 1,
|
354
|
+
style: 'Table Style Medium 16', name: rep[:id],
|
355
|
+
columns: file_data_keys.map { |key| {header: key} }
|
356
|
+
)
|
357
|
+
|
358
|
+
dossier_row += 2
|
359
|
+
end
|
360
|
+
ie_data_keys.merge ie_data.keys
|
361
|
+
ie_list << ie_data
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
# write ie data to overview worksheet
|
366
|
+
overview.write_row(0, 0, ie_data_keys.to_a, ie_data_header_format)
|
367
|
+
overview_row = 1
|
368
|
+
ie_list.each do |ie_info|
|
369
|
+
ie_data = []
|
370
|
+
ie_data_keys.each { |key| ie_data << ie_info[key] }
|
371
|
+
overview.write_row(overview_row, 0, ie_data)
|
372
|
+
overview_row += 1
|
373
|
+
end
|
374
|
+
|
375
|
+
rescue Exception => e
|
376
|
+
puts e.message
|
377
|
+
puts e.backtrace
|
378
|
+
# close and save workbook
|
379
|
+
ensure
|
380
|
+
workbook.close
|
381
|
+
end
|
382
|
+
|
383
|
+
def file
|
384
|
+
@file
|
385
|
+
end
|
386
|
+
|
387
|
+
def ie
|
388
|
+
@ie
|
389
|
+
end
|
390
|
+
|
391
|
+
def rep
|
392
|
+
@rep
|
393
|
+
end
|
394
|
+
|
395
|
+
end
|
396
|
+
|
397
|
+
end
|
398
|
+
end
|
399
|
+
end
|