libis-services 0.1.0-java
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/aleph/search.rb +157 -0
- data/lib/libis/services/alma/web_service.rb +36 -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/collective_access.rb +1 -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/limo.rb +33 -0
- data/lib/libis/services/primo/search.rb +46 -0
- data/lib/libis/services/primo.rb +2 -0
- data/lib/libis/services/rest_client.rb +66 -0
- data/lib/libis/services/rosetta/client.rb +108 -0
- data/lib/libis/services/rosetta/collection_handler.rb +45 -0
- data/lib/libis/services/rosetta/collection_info.rb +44 -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/oai_pmh.rb +48 -0
- data/lib/libis/services/rosetta/oai_set.rb +21 -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 +403 -0
- data/lib/libis/services/rosetta/sip.rb +26 -0
- data/lib/libis/services/rosetta/sip_handler.rb +31 -0
- data/lib/libis/services/rosetta/user.rb +70 -0
- data/lib/libis/services/rosetta/user_manager.rb +28 -0
- data/lib/libis/services/rosetta.rb +2 -0
- data/lib/libis/services/scope/search.rb +46 -0
- data/lib/libis/services/search_factory.rb +40 -0
- data/lib/libis/services/service_error.rb +16 -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/lib/libis/services.rb +22 -0
- data/lib/libis-services.rb +1 -0
- data/libis-services.gemspec +40 -0
- data/spec/alma_service_spec.rb +104 -0
- data/spec/ie_data.rb +726 -0
- data/spec/primo_limo_spec.rb +363 -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 +54 -0
- data/spec/rosetta_oai_spec.rb +52 -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 +28 -0
- metadata +317 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'libis/services/rest_client'
|
5
|
+
require 'libis/services/generic_search'
|
6
|
+
|
7
|
+
module Libis
|
8
|
+
module Services
|
9
|
+
module Primo
|
10
|
+
|
11
|
+
class Search
|
12
|
+
include ::Libis::Services::RestClient
|
13
|
+
include ::Libis::Services::GenericSearch
|
14
|
+
|
15
|
+
def initialize(url = 'https://services.libis.be')
|
16
|
+
configure(url)
|
17
|
+
end
|
18
|
+
|
19
|
+
def query(query, options = {})
|
20
|
+
index = options.delete(:index) || 'any'
|
21
|
+
get 'search', {query: "#{index}:#{query}"}.merge(options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def find(term, options = {})
|
25
|
+
max_count = options.delete(:max_count) || 100
|
26
|
+
result = []
|
27
|
+
while result.size < max_count
|
28
|
+
reply = query(term, options.merge(from: result.size + 1))
|
29
|
+
max_count = [max_count, reply[:count]].min
|
30
|
+
reply[:data].each do |record|
|
31
|
+
next unless result.size < max_count
|
32
|
+
result << record[:display]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
result
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def result_parser(response)
|
41
|
+
JSON.parse(response, symbolize_names: true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'rest-client'
|
4
|
+
require 'nori'
|
5
|
+
require 'json'
|
6
|
+
require 'gyoku'
|
7
|
+
|
8
|
+
module Libis
|
9
|
+
module Services
|
10
|
+
|
11
|
+
module RestClient
|
12
|
+
attr_reader :client
|
13
|
+
|
14
|
+
def configure(url, options = {})
|
15
|
+
@client = ::RestClient::Resource.new(url, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(path, params = {}, headers = {}, &block)
|
19
|
+
response = client[path].get({params: params}.merge headers, &block)
|
20
|
+
parse_result response, &block
|
21
|
+
rescue ::RestClient::Exception => e
|
22
|
+
return {error_type: e.class.name, error_name: e.message, response: parse_result(e.response, &block)}
|
23
|
+
end
|
24
|
+
|
25
|
+
def post_url(path, params = {}, headers = {}, &block)
|
26
|
+
response = client[path].post({params: params}.merge headers, &block)
|
27
|
+
parse_result response, &block
|
28
|
+
rescue ::RestClient::Exception => e
|
29
|
+
return {error_type: e.class.name, error_name: e.message, response: parse_result(e.response, &block)}
|
30
|
+
end
|
31
|
+
|
32
|
+
def post_data(path, payload, headers = {}, &block)
|
33
|
+
response = client[path].post(payload, headers, &block)
|
34
|
+
parse_result response, &block
|
35
|
+
rescue ::RestClient::Exception => e
|
36
|
+
return {error_type: e.class.name, error_name: e.message, response: parse_result(e.response, &block)}
|
37
|
+
end
|
38
|
+
|
39
|
+
def put_url(path, params = {}, headers = {}, &block)
|
40
|
+
response = client[path].put({params: params}.merge headers, &block)
|
41
|
+
parse_result response, &block
|
42
|
+
rescue ::RestClient::Exception => e
|
43
|
+
return {error_type: e.class.name, error_name: e.message, response: parse_result(e.response, &block)}
|
44
|
+
end
|
45
|
+
|
46
|
+
def put_data(path, payload, headers = {}, &block)
|
47
|
+
response = client[path].put(payload, headers, &block)
|
48
|
+
parse_result response, &block
|
49
|
+
rescue ::RestClient::Exception => e
|
50
|
+
return {error_type: e.class.name, error_name: e.message, response: parse_result(e.response, &block)}
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def parse_result(response)
|
56
|
+
block_given? ? yield(response) : result_parser(response)
|
57
|
+
end
|
58
|
+
|
59
|
+
def result_parser(response)
|
60
|
+
response
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'awesome_print'
|
4
|
+
|
5
|
+
require 'libis/tools/extend/hash'
|
6
|
+
require 'libis/tools/config'
|
7
|
+
require 'libis/tools/logger'
|
8
|
+
|
9
|
+
require 'libis/services/soap_client'
|
10
|
+
require 'libis/services/service_error'
|
11
|
+
module Libis
|
12
|
+
module Services
|
13
|
+
module Rosetta
|
14
|
+
|
15
|
+
class Client
|
16
|
+
include ::Libis::Services::SoapClient
|
17
|
+
include ::Libis::Tools::Logger
|
18
|
+
|
19
|
+
def initialize(section, service, options = {})
|
20
|
+
opts = {strip_namespaces: true, logger: ::Libis::Tools::Config.logger}.merge options
|
21
|
+
base_url = opts.delete(:url) || 'http://depot.lias.be'
|
22
|
+
configure "#{base_url}/dpsws/#{section}/#{service}?wsdl", opts
|
23
|
+
end
|
24
|
+
|
25
|
+
def pds_handle=(handle)
|
26
|
+
@pds_handle = handle
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_heart_bit
|
30
|
+
request :get_heart_bit
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def call_raw(operation, args = {})
|
36
|
+
data = request operation.to_s.to_sym, args
|
37
|
+
|
38
|
+
# remove wrapper
|
39
|
+
data = data["#{operation}_response".to_sym]
|
40
|
+
data.delete(:'@xmlns:ns1')
|
41
|
+
|
42
|
+
# drill down the returned Hash
|
43
|
+
data = data.first.last while data.is_a?(Hash) && 1 == data.size
|
44
|
+
|
45
|
+
data
|
46
|
+
end
|
47
|
+
|
48
|
+
def call(operation, args = {})
|
49
|
+
# upstream call
|
50
|
+
data = call_raw(operation, args)
|
51
|
+
|
52
|
+
# try to parse as XML
|
53
|
+
if data.is_a?(String)
|
54
|
+
xml_data = Libis::Tools::XmlDocument.parse(data).to_hash(
|
55
|
+
empty_tag_value: nil,
|
56
|
+
delete_namespace_attributes: true,
|
57
|
+
strip_namespaces: true,
|
58
|
+
convert_tags_to: lambda { |tag| tag.to_sym }
|
59
|
+
)
|
60
|
+
data = xml_data unless xml_data.empty?
|
61
|
+
end
|
62
|
+
|
63
|
+
return data unless data.is_a?(Hash)
|
64
|
+
|
65
|
+
# drill down
|
66
|
+
data = data.first.last if 1 == data.size
|
67
|
+
|
68
|
+
return data unless data.is_a?(Hash)
|
69
|
+
|
70
|
+
# check for errors
|
71
|
+
if data.delete :is_error
|
72
|
+
msg = data.delete(:error_description) || data.delete(:message_desc)
|
73
|
+
raise Libis::Services::ServiceError.new(msg)
|
74
|
+
end
|
75
|
+
|
76
|
+
# only delete if there is other info. ProducerService isUserExists uses this field as return value.
|
77
|
+
data.delete :error_description if data.size > 1
|
78
|
+
|
79
|
+
# continue drilling down the Hash
|
80
|
+
data = data.first.last while data.is_a?(Hash) && 1 == data.size
|
81
|
+
|
82
|
+
# return
|
83
|
+
data
|
84
|
+
end
|
85
|
+
|
86
|
+
def request_object(method, klass, args = {})
|
87
|
+
data = call method, args
|
88
|
+
return nil unless data.is_a?(Hash)
|
89
|
+
klass.new(data)
|
90
|
+
end
|
91
|
+
|
92
|
+
def request_array(method, args = {})
|
93
|
+
data = call method, args
|
94
|
+
data = data.split(/[\s,]+/) if data.is_a?(String)
|
95
|
+
data = [data] if data.is_a?(Hash)
|
96
|
+
data.is_a?(Array) ? data : []
|
97
|
+
end
|
98
|
+
|
99
|
+
def request_object_array(method, klass, args = {})
|
100
|
+
data = request_array(method, args)
|
101
|
+
data.map { |x| klass.new(x) }
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'virtus'
|
3
|
+
|
4
|
+
require 'libis/tools/extend/hash'
|
5
|
+
require_relative 'collection_info'
|
6
|
+
require_relative 'client'
|
7
|
+
|
8
|
+
module Libis
|
9
|
+
module Services
|
10
|
+
module Rosetta
|
11
|
+
|
12
|
+
class CollectionHandler < Libis::Services::Rosetta::Client
|
13
|
+
|
14
|
+
|
15
|
+
def initialize(base_url = 'http://depot.lias.be', options = {})
|
16
|
+
super 'repository', 'CollectionWebServices', {url: base_url}.merge(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(id)
|
20
|
+
request_object :get_collection_by_id, Rosetta::CollectionInfo, pds_handle: @pds_handle, collection_id: id
|
21
|
+
end
|
22
|
+
|
23
|
+
def find(path)
|
24
|
+
request_object :get_collection_by_name, Rosetta::CollectionInfo, pds_handle: @pds_handle, collection_path: path
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(collection_info)
|
28
|
+
collection_info = collection_info.to_hash.cleanup if collection_info.is_a? CollectionInfo
|
29
|
+
call :create_collection, pds_handle: @pds_handle, collection: collection_info
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete(id)
|
33
|
+
call :delete_collection, pds_handle: @pds_handle, collection_id: id
|
34
|
+
end
|
35
|
+
|
36
|
+
def update(collection_info)
|
37
|
+
collection_info = collection_info.attributes if collection_info.is_a? CollectionInfo
|
38
|
+
call :update_collection, pds_handle: @pds_handle, collection: collection_info
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'virtus'
|
3
|
+
|
4
|
+
module Libis
|
5
|
+
module Services
|
6
|
+
module Rosetta
|
7
|
+
|
8
|
+
class CollectionInfo
|
9
|
+
# noinspection RubyResolve
|
10
|
+
include Virtus.model
|
11
|
+
|
12
|
+
class MetaData
|
13
|
+
# noinspection RubyResolve
|
14
|
+
include Virtus.model
|
15
|
+
|
16
|
+
attribute :mid, String
|
17
|
+
attribute :type, String
|
18
|
+
attribute :sub_type, String
|
19
|
+
attribute :content, String
|
20
|
+
end
|
21
|
+
|
22
|
+
attribute :id, String
|
23
|
+
attribute :name, String
|
24
|
+
attribute :parent_id, String
|
25
|
+
attribute :description, String
|
26
|
+
attribute :md_dc, MetaData
|
27
|
+
attribute :md_source, Array[MetaData]
|
28
|
+
attribute :navigate, Boolean
|
29
|
+
attribute :publish, Boolean
|
30
|
+
attribute :external_id, String
|
31
|
+
attribute :external_system, String
|
32
|
+
|
33
|
+
def to_hash
|
34
|
+
result = self.attributes
|
35
|
+
result[:md_dc] = result[:md_dc].attributes if result[:md_dc]
|
36
|
+
result[:md_source] = result[:md_source].map { |md| md.attributes }
|
37
|
+
result
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'oai'
|
3
|
+
require 'libis/tools/extend/hash'
|
4
|
+
|
5
|
+
module Libis
|
6
|
+
module Services
|
7
|
+
module Rosetta
|
8
|
+
class OaiPmh
|
9
|
+
include OAI::XPath
|
10
|
+
|
11
|
+
def initialize(base_url = 'http://depot.lias.be', options = {})
|
12
|
+
@oai_client = OAI::Client.new(base_url + '/oaiprovider/request', options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def sets
|
16
|
+
response = @oai_client.list_sets
|
17
|
+
response.map do |oai_set|
|
18
|
+
{name: oai_set.name, spec: oai_set.spec, description: oai_set.description}.cleanup
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def collections(institute, status = {})
|
23
|
+
result = records("#{institute}-collections", status)
|
24
|
+
result.map do |record|
|
25
|
+
record[:title] = xpath_first(record[:metadata], './/dc:title').text
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def records(spec, status = {})
|
30
|
+
options = { set: spec }
|
31
|
+
options[:resumption_token] = status[:token] if status[:token]
|
32
|
+
result = []
|
33
|
+
response = @oai_client.list_records(options)
|
34
|
+
response.each do |record|
|
35
|
+
next if record.deleted?
|
36
|
+
result << {
|
37
|
+
id: record.header.identifier,
|
38
|
+
date: record.header.datestamp,
|
39
|
+
metadata: record.metadata,
|
40
|
+
}
|
41
|
+
end
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
|
3
|
+
module Libis
|
4
|
+
module Services
|
5
|
+
module Rosetta
|
6
|
+
class OaiSet
|
7
|
+
# noinspection RubyResolve
|
8
|
+
include Virtus.model nullify_blank: true
|
9
|
+
|
10
|
+
attribute :description, String
|
11
|
+
attribute :name, String
|
12
|
+
attribute :spec, String
|
13
|
+
|
14
|
+
def to_hash
|
15
|
+
super.cleanup
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|