libis-services 0.0.2
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 +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,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'virtus'
|
3
|
+
|
4
|
+
class Libis::Services::Rosetta::CollectionInfo
|
5
|
+
# noinspection RubyResolve
|
6
|
+
include Virtus.model
|
7
|
+
|
8
|
+
class MetaData
|
9
|
+
# noinspection RubyResolve
|
10
|
+
include Virtus.model
|
11
|
+
|
12
|
+
attribute :mid, String
|
13
|
+
attribute :type, String
|
14
|
+
attribute :sub_type, String
|
15
|
+
attribute :content, String
|
16
|
+
end
|
17
|
+
|
18
|
+
attribute :id, String
|
19
|
+
attribute :name, String
|
20
|
+
attribute :parent_id, String
|
21
|
+
attribute :md_dc, MetaData
|
22
|
+
attribute :md_source, Array[MetaData]
|
23
|
+
attribute :navigate, Boolean
|
24
|
+
attribute :publish, Boolean
|
25
|
+
attribute :external_id, String
|
26
|
+
attribute :external_system, String
|
27
|
+
|
28
|
+
def to_hash
|
29
|
+
result = self.attributes
|
30
|
+
result[:md_dc] = result[:md_dc].attributes if result[:md_dc]
|
31
|
+
result[:md_source] = result[:md_source].map { |md| md.attributes }
|
32
|
+
result
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
require 'libis/tools/extend/hash'
|
3
|
+
|
4
|
+
module Libis
|
5
|
+
module Services
|
6
|
+
module Rosetta
|
7
|
+
class DepositActivity
|
8
|
+
# noinspection RubyResolve
|
9
|
+
include Virtus.model nullify_blank: true
|
10
|
+
|
11
|
+
STATUS = %w'Inprocess Incomplete Rejected Draft Approved Declined'
|
12
|
+
|
13
|
+
attribute :deposit_activity_id, Integer
|
14
|
+
attribute :creation_date, String
|
15
|
+
attribute :status, String
|
16
|
+
attribute :title, String
|
17
|
+
attribute :producer_agent_id, Integer
|
18
|
+
attribute :submit_date, String
|
19
|
+
attribute :update_date, String
|
20
|
+
attribute :sip_id, Integer
|
21
|
+
attribute :producer_id, Integer
|
22
|
+
attribute :sip_reason, String
|
23
|
+
|
24
|
+
def to_hash
|
25
|
+
super.cleanup
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
class DepositActivityList
|
31
|
+
# noinspection RubyResolve
|
32
|
+
include Virtus.model nullify_blank: true
|
33
|
+
|
34
|
+
attribute :total_records, String
|
35
|
+
attribute :records, Array(DepositActivity)
|
36
|
+
|
37
|
+
def to_hash
|
38
|
+
{
|
39
|
+
total_records: total_records,
|
40
|
+
records: records.map {|record| record.to_hash}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative 'deposit_activity'
|
4
|
+
require_relative 'client'
|
5
|
+
|
6
|
+
module Libis
|
7
|
+
module Services
|
8
|
+
module Rosetta
|
9
|
+
|
10
|
+
class DepositHandler < ::Libis::Services::Rosetta::Client
|
11
|
+
|
12
|
+
def initialize(base_url = 'http://depot.lias.be', options = {})
|
13
|
+
super 'deposit', 'DepositWebServices', {url: base_url}.merge(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param [Object] flow_id ID of the material flow used
|
17
|
+
# @param [Object] subdir name of the load directory
|
18
|
+
# @param [Object] producer_id ID of the Producer
|
19
|
+
# @param [Object] deposit_set_id ID of the set of deposits
|
20
|
+
def submit(flow_id, subdir, producer_id, deposit_set_id = '1')
|
21
|
+
call :submit_deposit_activity,
|
22
|
+
arg0: @pds_handle,
|
23
|
+
arg1: flow_id,
|
24
|
+
arg2: subdir,
|
25
|
+
arg3: producer_id,
|
26
|
+
arg4: deposit_set_id
|
27
|
+
end
|
28
|
+
|
29
|
+
def deposits(opts = {})
|
30
|
+
options = opts.dup
|
31
|
+
flow_id = options.delete :flow_id
|
32
|
+
submit_date_from, submit_date_to = options.delete :submit_date
|
33
|
+
submit_date_to ||= submit_date_from if submit_date_from
|
34
|
+
update_date_from, update_date_to = options.delete :update_date
|
35
|
+
update_date_to ||= update_date_from if update_date_from
|
36
|
+
if submit_date_from
|
37
|
+
if flow_id
|
38
|
+
get_by_submit_flow submit_date_from, submit_date_to, flow_id, options
|
39
|
+
else
|
40
|
+
get_by_submit_date submit_date_from, submit_date_to, options
|
41
|
+
end
|
42
|
+
elsif update_date_from
|
43
|
+
if flow_id
|
44
|
+
get_by_update_flow update_date_from, update_date_to, flow_id, options
|
45
|
+
else
|
46
|
+
get_by_update_date update_date_from, update_date_to, options
|
47
|
+
end
|
48
|
+
else
|
49
|
+
error "unsupported deposit query: #{opts}."
|
50
|
+
[]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param [String] date_from Start date for lookup range
|
55
|
+
# @param [String] date_to End date for lookup range
|
56
|
+
# @param [Hash] options optional string parameters limiting the search with:
|
57
|
+
# - status: Status of the deposit [All (default), In process, Rejected, Draft, Approved, Declined]
|
58
|
+
# - producer_id: optional, limits by producer_id
|
59
|
+
# - agent_id: optional, limits by agent_id
|
60
|
+
# - start_record: optional, pagination start
|
61
|
+
# - end_record: optional, pagination end
|
62
|
+
def get_by_submit_date(date_from, date_to, options = {})
|
63
|
+
options = {
|
64
|
+
status: 'All',
|
65
|
+
producer_id: nil,
|
66
|
+
agent_id: nil,
|
67
|
+
start_record: nil,
|
68
|
+
end_record: nil
|
69
|
+
}.merge options
|
70
|
+
params = {
|
71
|
+
arg0: @pds_handle,
|
72
|
+
arg1: options[:status],
|
73
|
+
arg2: options[:producer_id],
|
74
|
+
arg3: options[:agent_id],
|
75
|
+
arg4: date_from,
|
76
|
+
arg5: date_to,
|
77
|
+
arg6: options[:start_record],
|
78
|
+
arg7: options[:end_record]
|
79
|
+
}.cleanup
|
80
|
+
request_activities :get_deposit_activity_by_submit_date, params
|
81
|
+
end
|
82
|
+
|
83
|
+
# @param [String] date_from Start date for lookup range
|
84
|
+
# @param [String] date_to End date for lookup range
|
85
|
+
# @param [Object] flow_id ID of the material flow used
|
86
|
+
# @param [Hash] options optional string parameters limiting the search with:
|
87
|
+
# - status: Status of the deposit [All (default), In process, Rejected, Draft, Approved, Declined]
|
88
|
+
# - producer_id: optional, limits by producer_id
|
89
|
+
# - agent_id: optional, limits by agent_id
|
90
|
+
# - start_record: optional, pagination start
|
91
|
+
# - end_record: optional, pagination end
|
92
|
+
def get_by_submit_flow(date_from, date_to, flow_id, options = {})
|
93
|
+
options = {
|
94
|
+
status: 'All',
|
95
|
+
producer_id: nil,
|
96
|
+
agent_id: nil,
|
97
|
+
start_record: nil,
|
98
|
+
end_record: nil
|
99
|
+
}.merge options
|
100
|
+
params = {
|
101
|
+
arg0: @pds_handle,
|
102
|
+
arg1: options[:status],
|
103
|
+
arg2: flow_id,
|
104
|
+
arg3: options[:producer_id],
|
105
|
+
arg4: options[:agent_id],
|
106
|
+
arg5: date_from,
|
107
|
+
arg6: date_to,
|
108
|
+
arg7: options[:start_record],
|
109
|
+
arg8: options[:end_record]
|
110
|
+
}.cleanup
|
111
|
+
request_activities :get_deposit_activity_by_submit_date_by_material_flow, params
|
112
|
+
end
|
113
|
+
|
114
|
+
# @param [String] date_from Start date for lookup range
|
115
|
+
# @param [String] date_to End date for lookup range
|
116
|
+
# @param [Hash] options optional string parameters limiting the search with:
|
117
|
+
# - status: Status of the deposit [All (default), In process, Rejected, Draft, Approved, Declined]
|
118
|
+
# - producer_id: optional, limits by producer_id
|
119
|
+
# - agent_id: optional, limits by agent_id
|
120
|
+
# - start_record: optional, pagination start
|
121
|
+
# - end_record: optional, pagination end
|
122
|
+
def get_by_update_date(date_from, date_to, options = {})
|
123
|
+
options = {
|
124
|
+
status: 'All',
|
125
|
+
producer_id: nil,
|
126
|
+
agent_id: nil,
|
127
|
+
start_record: nil,
|
128
|
+
end_record: nil
|
129
|
+
}.merge options
|
130
|
+
params = {
|
131
|
+
arg0: @pds_handle,
|
132
|
+
arg1: options[:status],
|
133
|
+
arg2: options[:producer_id],
|
134
|
+
arg3: options[:agent_id],
|
135
|
+
arg4: date_from,
|
136
|
+
arg5: date_to,
|
137
|
+
arg6: options[:start_record],
|
138
|
+
arg7: options[:end_record]
|
139
|
+
}.cleanup
|
140
|
+
request_activities :get_deposit_activity_by_update_date, params
|
141
|
+
end
|
142
|
+
|
143
|
+
# @param [String] date_from Start date for lookup range
|
144
|
+
# @param [String] date_to End date for lookup range
|
145
|
+
# @param [Object] flow_id ID of the material flow used
|
146
|
+
# @param [Hash] options optional string parameters limiting the search with:
|
147
|
+
# - status: Status of the deposit [All (default), In process, Rejected, Draft, Approved, Declined]
|
148
|
+
# - producer_id: optional, limits by producer_id
|
149
|
+
# - agent_id: optional, limits by agent_id
|
150
|
+
# - start_record: optional, pagination start
|
151
|
+
# - end_record: optional, pagination end
|
152
|
+
def get_by_update_flow(date_from, date_to, flow_id, options = {})
|
153
|
+
options = {
|
154
|
+
status: 'All',
|
155
|
+
producer_id: nil,
|
156
|
+
agent_id: nil,
|
157
|
+
start_record: nil,
|
158
|
+
end_record: nil
|
159
|
+
}.merge options
|
160
|
+
params = {
|
161
|
+
arg0: @pds_handle,
|
162
|
+
arg1: options[:status],
|
163
|
+
arg2: flow_id,
|
164
|
+
arg3: options[:producer_id],
|
165
|
+
arg4: options[:agent_id],
|
166
|
+
arg5: date_from,
|
167
|
+
arg6: date_to,
|
168
|
+
arg7: options[:start_record],
|
169
|
+
arg8: options[:end_record]
|
170
|
+
}.cleanup
|
171
|
+
request_activities :get_deposit_activity_by_update_date_by_material_flow, params
|
172
|
+
end
|
173
|
+
|
174
|
+
protected
|
175
|
+
|
176
|
+
def request_activities(method, args = {})
|
177
|
+
data = call method, args
|
178
|
+
list = Rosetta::DepositActivityList.new(total_records: data[:total_records])
|
179
|
+
records = data[:records][:record]
|
180
|
+
list.records = (records.is_a?(Array) ? records : [records]).map { |record| Rosetta::DepositActivity.new(record)}
|
181
|
+
list
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
|
3
|
+
module Libis
|
4
|
+
module Services
|
5
|
+
module Rosetta
|
6
|
+
class Ie
|
7
|
+
# noinspection RubyResolve
|
8
|
+
include Virtus.model nullify_blank: true
|
9
|
+
|
10
|
+
attribute :pid, String
|
11
|
+
|
12
|
+
def to_hash
|
13
|
+
super.cleanup
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'libis/tools/xml_document'
|
4
|
+
require_relative 'client'
|
5
|
+
|
6
|
+
module Libis
|
7
|
+
module Services
|
8
|
+
module Rosetta
|
9
|
+
|
10
|
+
class IeHandler < Libis::Services::Rosetta::Client
|
11
|
+
|
12
|
+
def initialize(base_url = 'http://depot.lias.be', options = {})
|
13
|
+
super 'repository', 'IEWebServices', {url: base_url}.merge(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_mets(ie, flags = 0)
|
17
|
+
result = call_raw :get_ie, pds_handle: @pds_handle, ie_pid: ie, flags: flags
|
18
|
+
Libis::Tools::MetsFile.parse(result)
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_metadata(ie)
|
22
|
+
result = call_raw :get_md, pds_handle: @pds_handle, 'PID' => ie
|
23
|
+
Libis::Tools::MetsFile.parse(result)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'libis/services/rest_client'
|
4
|
+
|
5
|
+
module Libis
|
6
|
+
module Services
|
7
|
+
module Rosetta
|
8
|
+
|
9
|
+
class PdsHandler
|
10
|
+
include Libis::Services::RestClient
|
11
|
+
|
12
|
+
# @param [String] base_url
|
13
|
+
def initialize(base_url = 'https://pds.libis.be')
|
14
|
+
configure base_url
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param [String] user
|
18
|
+
# @param [String] password
|
19
|
+
# @param [String] institute
|
20
|
+
# @return [String] PDS handle, nil if could not login
|
21
|
+
def login(user, password, institute)
|
22
|
+
params = {
|
23
|
+
func: 'login-url',
|
24
|
+
bor_id: user,
|
25
|
+
bor_verification: password,
|
26
|
+
institute: institute
|
27
|
+
}
|
28
|
+
response = get 'pds', params
|
29
|
+
return nil unless response.code == 200 and response.body.match /pds_handle=(\d+)[^\d]/
|
30
|
+
$1
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param [String] pds_handle
|
34
|
+
# @return [Boolean] true if success
|
35
|
+
def logout(pds_handle)
|
36
|
+
params = {
|
37
|
+
func: 'logout',
|
38
|
+
pds_handle: pds_handle
|
39
|
+
}
|
40
|
+
response = get 'pds', params
|
41
|
+
response.code == 200
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param [String] pds_handle
|
45
|
+
# @return [Hash] with user information. At least containing: 'id', 'name', 'institute' and 'group'
|
46
|
+
def user_info(pds_handle)
|
47
|
+
params = {
|
48
|
+
func: 'get-attribute',
|
49
|
+
attribute: 'BOR_INFO',
|
50
|
+
pds_handle: pds_handle
|
51
|
+
}
|
52
|
+
response = get 'pds', params
|
53
|
+
return nil unless response.code == 200
|
54
|
+
Nori.new(convert_tags_to: lambda {|tag| tag.to_sym}).parse(response.body)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
|
3
|
+
module Libis
|
4
|
+
module Services
|
5
|
+
module Rosetta
|
6
|
+
class Producer
|
7
|
+
# noinspection RubyResolve
|
8
|
+
include Virtus.model(nullify_blank: true)
|
9
|
+
|
10
|
+
attribute :authoritative_name, String, default: 'producer'
|
11
|
+
attribute :account_type, String, default: 'GROUP'
|
12
|
+
attribute :status, String, default: 'ACTIVE'
|
13
|
+
attribute :expiry_date, String
|
14
|
+
attribute :first_name, String
|
15
|
+
attribute :last_name, String
|
16
|
+
attribute :institution, String, default: 'institution'
|
17
|
+
attribute :department, String, default: 'department'
|
18
|
+
attribute :user_name, String
|
19
|
+
attribute :producer_group, String, default: 'Published'
|
20
|
+
attribute :negotiator_id, String
|
21
|
+
attribute :producerProfile_id, String
|
22
|
+
attribute :telephone_1, String
|
23
|
+
attribute :telephone_2, String
|
24
|
+
attribute :fax, String
|
25
|
+
attribute :email, String
|
26
|
+
attribute :email_notify, String
|
27
|
+
attribute :web_site, String
|
28
|
+
attribute :street, String
|
29
|
+
attribute :suburb, String
|
30
|
+
attribute :city, String
|
31
|
+
attribute :zip_code, String
|
32
|
+
attribute :country, String
|
33
|
+
attribute :notes, String
|
34
|
+
attribute :local_field_1, String
|
35
|
+
attribute :local_field_2, String
|
36
|
+
attribute :contactUser_id_1, String
|
37
|
+
attribute :contactUser_id_2, String
|
38
|
+
attribute :contactUser_id_3, String
|
39
|
+
attribute :contactUser_id_4, String
|
40
|
+
attribute :contactUser_id_5, String
|
41
|
+
|
42
|
+
def to_hash
|
43
|
+
attributes.cleanup
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_xml
|
47
|
+
Libis::Tools::XmlDocument.build do |xml|
|
48
|
+
# noinspection RubyResolve
|
49
|
+
xml.producer_info {
|
50
|
+
xml.parent.default_namespace = 'http://www.exlibrisgroup.com/xsd/dps/backoffice/service'
|
51
|
+
self.attributes.each do |name, value|
|
52
|
+
xml.send(name, xmlns: '').text(value) if value
|
53
|
+
end
|
54
|
+
}
|
55
|
+
end.to_xml
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.from_xml(xml)
|
59
|
+
xml_doc = Libis::Tools::XmlDocument.parse(xml)
|
60
|
+
hash = xml_doc.to_hash(
|
61
|
+
strip_namespaces: true,
|
62
|
+
delete_namespace_attributes: true,
|
63
|
+
empty_tag_value: nil,
|
64
|
+
convert_tags_to: lambda { |tag| tag.to_sym }
|
65
|
+
)
|
66
|
+
self.new(hash[:producer_info])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|