libis-services 0.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +36 -0
  6. data/Rakefile +6 -0
  7. data/lib/libis/services/aleph/search.rb +157 -0
  8. data/lib/libis/services/alma/web_service.rb +36 -0
  9. data/lib/libis/services/collective_access/cataloguing.rb +48 -0
  10. data/lib/libis/services/collective_access/connector.rb +151 -0
  11. data/lib/libis/services/collective_access/item_info.rb +36 -0
  12. data/lib/libis/services/collective_access/search.rb +26 -0
  13. data/lib/libis/services/collective_access/service.rb +80 -0
  14. data/lib/libis/services/collective_access.rb +1 -0
  15. data/lib/libis/services/digitool/digital_entity_manager.rb +223 -0
  16. data/lib/libis/services/digitool/digitool_connector.rb +46 -0
  17. data/lib/libis/services/digitool/meta_data_manager.rb +193 -0
  18. data/lib/libis/services/extend/http_fetch.rb +63 -0
  19. data/lib/libis/services/generic_search.rb +38 -0
  20. data/lib/libis/services/http_error.rb +21 -0
  21. data/lib/libis/services/oracle_client.rb +47 -0
  22. data/lib/libis/services/primo/limo.rb +33 -0
  23. data/lib/libis/services/primo/search.rb +46 -0
  24. data/lib/libis/services/primo.rb +2 -0
  25. data/lib/libis/services/rest_client.rb +66 -0
  26. data/lib/libis/services/rosetta/client.rb +108 -0
  27. data/lib/libis/services/rosetta/collection_handler.rb +45 -0
  28. data/lib/libis/services/rosetta/collection_info.rb +44 -0
  29. data/lib/libis/services/rosetta/deposit_activity.rb +48 -0
  30. data/lib/libis/services/rosetta/deposit_handler.rb +187 -0
  31. data/lib/libis/services/rosetta/ie.rb +19 -0
  32. data/lib/libis/services/rosetta/ie_handler.rb +29 -0
  33. data/lib/libis/services/rosetta/oai_pmh.rb +48 -0
  34. data/lib/libis/services/rosetta/oai_set.rb +21 -0
  35. data/lib/libis/services/rosetta/pds_handler.rb +60 -0
  36. data/lib/libis/services/rosetta/producer.rb +71 -0
  37. data/lib/libis/services/rosetta/producer_handler.rb +125 -0
  38. data/lib/libis/services/rosetta/service.rb +403 -0
  39. data/lib/libis/services/rosetta/sip.rb +26 -0
  40. data/lib/libis/services/rosetta/sip_handler.rb +31 -0
  41. data/lib/libis/services/rosetta/user.rb +70 -0
  42. data/lib/libis/services/rosetta/user_manager.rb +28 -0
  43. data/lib/libis/services/rosetta.rb +2 -0
  44. data/lib/libis/services/scope/search.rb +46 -0
  45. data/lib/libis/services/search_factory.rb +40 -0
  46. data/lib/libis/services/service_error.rb +16 -0
  47. data/lib/libis/services/sharepoint/connector.rb +236 -0
  48. data/lib/libis/services/sharepoint/search.rb +19 -0
  49. data/lib/libis/services/soap_client.rb +57 -0
  50. data/lib/libis/services/soap_error.rb +22 -0
  51. data/lib/libis/services/version.rb +5 -0
  52. data/lib/libis/services.rb +22 -0
  53. data/lib/libis-services.rb +1 -0
  54. data/libis-services.gemspec +40 -0
  55. data/spec/alma_service_spec.rb +104 -0
  56. data/spec/ie_data.rb +726 -0
  57. data/spec/primo_limo_spec.rb +363 -0
  58. data/spec/primo_search_spec.rb +39 -0
  59. data/spec/rosetta_collection_spec.rb +206 -0
  60. data/spec/rosetta_deposit_spec.rb +82 -0
  61. data/spec/rosetta_ie_spec.rb +54 -0
  62. data/spec/rosetta_oai_spec.rb +52 -0
  63. data/spec/rosetta_pds_spec.rb +79 -0
  64. data/spec/rosetta_producer_spec.rb +270 -0
  65. data/spec/rosetta_sip_spec.rb +39 -0
  66. data/spec/spec_helper.rb +28 -0
  67. metadata +317 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b0b41e0119e9529ccc88327344d01ce72ff3a8b
4
+ data.tar.gz: c2dd250a1cd6013b3a7cbd7c9bdf115ce72601f0
5
+ SHA512:
6
+ metadata.gz: c9549385d9cc8e3d5623b1eaa5538940856e58345725ed8fa4889868e17aacc54866167a38d7e8ce925ae4b34fac6a12c9637c09727d240dddf5fbeb5a44ae82
7
+ data.tar.gz: 4ca74e43543e1d2ac4608c3e29c33d7fbcda1f00ac0f39cbeafda0acfd94baafb55875898d27a22881bd275cfc3962eb8e7bcde80ac13bba8a9509b57920f0ed
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ /.idea/
16
+
17
+ spec/credentials*
18
+ lib/jar
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in libis-services.gemspec
4
+ gemspec name: 'libis-services', development_group: :test
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Kris Dekeyser
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ [![Gem Version](https://badge.fury.io/rb/libis-services.svg)](http://badge.fury.io/rb/libis-services)
2
+ [![Build Status](https://travis-ci.org/Kris-LIBIS/LIBIS_Services.svg?branch=master)](https://travis-ci.org/Kris-LIBIS/LIBIS_Services)
3
+ [![Coverage Status](https://img.shields.io/coveralls/Kris-LIBIS/LIBIS_Services.svg)](https://coveralls.io/r/Kris-LIBIS/LIBIS_Services)
4
+ [![Dependency Status](https://gemnasium.com/Kris-LIBIS/LIBIS_Services.svg)](https://gemnasium.com/Kris-LIBIS/LIBIS_Services)
5
+
6
+ # Services
7
+
8
+ TODO: Write a gem description
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'Services'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install Services
25
+
26
+ ## Usage
27
+
28
+ TODO: Write usage instructions here
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( https://github.com/[my-github-username]/Services/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
@@ -0,0 +1,157 @@
1
+ # coding: utf-8
2
+
3
+ require 'backports/rails/hash'
4
+ require 'libis/tools/xml_document'
5
+
6
+ require 'libis/services/generic_search'
7
+
8
+ module Libis
9
+ module Services
10
+ module Aleph
11
+
12
+ class Search
13
+ include ::Libis::Services::GenericSearch
14
+
15
+ attr_accessor :host
16
+
17
+ def find(term, options = {})
18
+ super
19
+
20
+ response = execute_http_query("op=find&code=#{options[:index]}&request=#{options[:term]}&base=#{options[:dbase]}")
21
+ if response
22
+ set_number = response['//find/set_number'].to_s
23
+ num_records = response['//find/no_records'].to_i
24
+ session_id = response['//find/session-id'].to_s
25
+ return options.merge id: set_number, num_records: num_records, session_id: session_id, record_pointer: 1
26
+ end
27
+ {}
28
+
29
+ end
30
+
31
+ def each(options)
32
+
33
+ return unless ([:record_pointer, :num_records] & options.keys).size == 2
34
+
35
+ while options[:record_pointer] <= options[:num_records]
36
+ next_record(options) { |r| yield r }
37
+ end
38
+
39
+ options
40
+ end
41
+
42
+ def next_record(options = {}, &block)
43
+
44
+ return nil unless ([:record_pointer, :num_records, :set_number, :dbase] & options.keys).size == 4
45
+
46
+ if options[:record_pointer] <= options[:num_records]
47
+ response = execute_http_query(
48
+ 'op=present' +
49
+ "&set_entry=#{options[:record_pointer]}" +
50
+ "&set_number=#{options[:set_number]}" +
51
+ "&base=#{options[:dbase]}"
52
+ )
53
+
54
+ if response
55
+ response.add_node 'search', type: 'opac', host: host, base: options[:dbase]
56
+ set_entry = response['//set_entry'].to_i
57
+ if set_entry == options[:record_pointer]
58
+ add_item_data(response, options[:dbase])
59
+ block_given? ? yield response : return response
60
+ end
61
+ end
62
+ else
63
+ puts 'no record found'
64
+ end
65
+
66
+ ensure
67
+ options[:record_pointer] += 1
68
+
69
+ end
70
+
71
+ private
72
+
73
+ def add_item_data(xml_document, options)
74
+
75
+ doc_number = xml_document['//doc_number']
76
+ response = execute_http_query("op=item-data&base=#{options[:dbase]}&doc-number=#{doc_number}")
77
+
78
+ if response
79
+
80
+ oai_marc = xml_document.get_node(:oai_marc)
81
+
82
+ #noinspection RubyResolve
83
+ response.get_nodes(:item).each do |r|
84
+ collection = response.value(:collection, r)
85
+ location = response.value(:sub-library, r)
86
+ classification = response.value('call-no-1', r)
87
+
88
+ varfield = xml_document.add_node 'varfield', nil, oai_marc, id: '852', i1: ' ', i2: ' '
89
+
90
+ xml_document.add_node 'subfield', collection, varfield, label: 'b'
91
+ xml_document.add_node 'subfield', location, varfield, label: 'c'
92
+ xml_document.add_node 'subfield', classification.gsub('$$h', ''), varfield, label: 'h'
93
+
94
+ end
95
+ end
96
+ end
97
+
98
+
99
+ def execute_http_query(data)
100
+ raise Exception, 'No host set' if host.nil? || host.size == 0
101
+
102
+ redo_count = 10
103
+ xml_document = nil
104
+
105
+ redo_search = false
106
+
107
+ begin
108
+ redo_search = false
109
+
110
+ begin
111
+ redo_count = redo_count - 1
112
+ sleep_time = 0.1 # in minutes
113
+
114
+ response = Net::HTTP.fetch(host, :data => data, :action => :post)
115
+
116
+ if response.is_a?(Net::HTTPOK)
117
+ xml_document = Libis::Tools::XmlDocument.parse(response.body)
118
+ error = xml_document['//error']
119
+
120
+ unless xml_document && error.nil?
121
+ unless error == 'empty set'
122
+ puts
123
+ puts "----------> Error searching for #{data} --> '#{error}'"
124
+ puts
125
+ end
126
+ if error =~ /license/
127
+ redo_search = true
128
+ end
129
+ end
130
+ else
131
+ puts response.error!
132
+ end
133
+ rescue Exception => ex
134
+ sleep_time = 0.5
135
+ if ex.message =~ /503 "Service Temporarily Unavailable"/
136
+ sleep_time = 30
137
+ Libis::Tools::Config.logger.warn "OPAC Service temporarily unavailable - retrying after #{sleep_time} minutes"
138
+ else
139
+ Libis::Tools::Config.logger.error "Problem with OPAC: '#{ex.message}' - retrying after #{sleep_time} minutes"
140
+ ex.backtrace.each { |x| Libis::Tools::Config.error "#{x}" }
141
+ end
142
+ redo_search = true
143
+ end
144
+
145
+ sleep sleep_time * 60 if redo_search
146
+
147
+ end until redo_search == false or redo_count < 0
148
+
149
+ xml_document
150
+
151
+ end
152
+
153
+ end
154
+
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ require 'libis-tools'
3
+ require 'libis/services/service_error'
4
+ require 'libis/services/rest_client'
5
+
6
+ module Libis
7
+ module Services
8
+ module Alma
9
+
10
+ class WebService
11
+ include ::Libis::Services::RestClient
12
+
13
+ def initialize(url = 'https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs')
14
+ configure(url)
15
+ end
16
+
17
+ def get_marc(alma_id, apikey = nil)
18
+ apikey ||= case alma_id
19
+ when /1480$/
20
+ 'l7xx8879c82a7d7b453a887a6e6dca8300fd'
21
+ else
22
+ raise Libis::Services::ServiceError, "No Alma API key available for '#{alma_id}'"
23
+ end
24
+ get alma_id, apikey: apikey
25
+ end
26
+
27
+ protected
28
+
29
+ def result_parser(response)
30
+ Libis::Tools::XmlDocument.parse(response)
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,48 @@
1
+ # coding: utf-8
2
+
3
+ require_relative 'connector'
4
+
5
+ module Libis
6
+ module Services
7
+ module CollectiveAccess
8
+
9
+ class Cataloguing < Connector
10
+
11
+ def initialize(host = nil)
12
+ super 'Cataloguing', host
13
+ end
14
+
15
+ def add_item(fields, type = nil)
16
+ type ||= 'ca_objects'
17
+ r, a = soap_encode fields
18
+ request :add, type: type, fieldInfo: r, :attributes! => {fieldInfo: a}
19
+ end
20
+
21
+ def add_attributes(item, data, type = nil)
22
+ type ||= 'ca_objects'
23
+ r, a = soap_encode data
24
+ request :getAttributesByElement, type: type, item_id: item, attribute_code_or_id: attribute.to_s, attribute_list_array: r, :attributes! => {attribute_list_array: a}
25
+
26
+ end
27
+
28
+ def add_attribute(item, attribute, data, type = nil)
29
+ type ||= 'ca_objects'
30
+ r, a = soap_encode data
31
+ request :addAttribute, type: type, item_id: item, attribute_code_or_id: attribute.to_s, attribute_data_array: r, :attributes! => {attribute_data_array: a}
32
+ end
33
+
34
+ def remove(item, type = nil)
35
+ type ||= 'ca_objects'
36
+ request :remove, type: type, item_id: item
37
+ end
38
+
39
+ def remove_attributes(item, type = nil)
40
+ type ||= 'ca_objects'
41
+ request :removeAllAttributes, type: type, item_id: item
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,151 @@
1
+ # coding: utf-8
2
+
3
+ require 'libis/services/soap_client'
4
+
5
+ module Libis
6
+ module Services
7
+ module CollectiveAccess
8
+
9
+ #noinspection RubyStringKeysInHashInspection
10
+ class Connector
11
+ include Libis::Services::SoapClient
12
+
13
+ attr_accessor :type_cast
14
+
15
+ def initialize(service, host = nil)
16
+ @type_cast = true
17
+ @host = host || 'http://crkc.be.halotest.cc.kuleuven.be/ca_crkc'
18
+ @service = service
19
+ configure "#{@host}/service.php/#{@service.downcase}/#{@service}/soapWSDL?wsdl",
20
+ convert_request_keys_to: :none,
21
+ # convert_response_tags_to: lambda {
22
+ # |tag| %w(Envelope Body).include?(tag) ? tag.snakecase.to_sym : tag.to_sym
23
+ # },
24
+ strip_namespaces: true
25
+ end
26
+
27
+ def authenticate(name = nil, password = nil)
28
+ name ||= 'administrator'
29
+ password ||= 'administrator'
30
+ result = request :auth, username: name, password: password
31
+ result.to_i == 1
32
+ end
33
+
34
+ def deauthenticate
35
+ request :deauthenticate
36
+ end
37
+
38
+ protected
39
+
40
+ def result_parser(response)
41
+ result = response.hash
42
+ type_caster(result.first[1][result.first[1][:result].snakecase.to_sym])
43
+ end
44
+
45
+ def type_caster(result)
46
+ return result unless @type_cast
47
+ return result unless result.is_a? Hash
48
+
49
+ r = result
50
+
51
+ case r[:'@xsi:type']
52
+ when 'enc:Array'
53
+ elements = result[:item]
54
+ if elements.is_a? Array
55
+ r = Array.new
56
+ elements.each { |i| r << type_caster(i) }
57
+ else
58
+ r = type_caster(result[:item])
59
+ end
60
+
61
+ when 'ns2:Map'
62
+ r = {}
63
+ elements = result[:item]
64
+ unless elements.is_a? Array
65
+ elements = Array.new
66
+ elements << result[:item]
67
+ end
68
+
69
+ elements.each { |i|
70
+ key = i[:key]
71
+ value = i[:value]
72
+ value = type_caster(value)
73
+ r[key] = value
74
+ }
75
+ else
76
+ #do nothing
77
+ end
78
+ r
79
+ end
80
+
81
+ NS_ATTR_ENC = {'xmlns:enc' => 'http://schemas.xmlsoap.org/soap/encoding/'}
82
+ NS_ATTR_NS2 = {'xmlns:ns2' => 'http://xml.apache.org/xml-soap'}
83
+
84
+ def soap_encode(data)
85
+ result = data
86
+ attributes = nil
87
+ case data
88
+ when Array
89
+ i = data.size
90
+ t = type_string data[0]
91
+ attributes = {'xsi:type' => 'enc:Array'}
92
+ if t
93
+ attributes['enc:arrayType'] = "#{t}[#{i}]"
94
+ else
95
+ attributes['enc:arraySize'] = i
96
+ end
97
+ attributes.merge! NS_ATTR_ENC
98
+ if t =~ /^ns2:/
99
+ attributes.merge! NS_ATTR_NS2
100
+ end
101
+ result = Array.new
102
+ data.each { |x|
103
+ r, a = soap_encode x
104
+ i = {item: r}
105
+ i[:attributes!] = {item: a} if a
106
+ result << i
107
+ }
108
+ when Hash
109
+ attributes = {'xsi:type' => 'ns2:Map'}.merge NS_ATTR_NS2
110
+ result = {item: Array.new}
111
+ data.each { |k, v|
112
+ rk, ak = soap_encode k.to_s
113
+ rv, av = soap_encode v
114
+ i = {key: rk, value: rv}
115
+ i[:attributes!] = {}
116
+ i[:attributes!][:key] = ak if ak
117
+ i[:attributes!][:value] = av if av
118
+ result[:item] << i
119
+ }
120
+ else
121
+ t = type_string data
122
+ if t
123
+ attributes = {'xsi:type' => t}
124
+ attributes.merge! NS_ATTR_ENC if t =~ /^enc:/
125
+ attributes.merge! NS_ATTR_NS2 if t =~ /^ns2:/
126
+ end
127
+ end
128
+ return result, attributes
129
+ end
130
+
131
+ def type_string(data)
132
+ return nil if data.nil?
133
+ case data
134
+ when Array
135
+ 'enc:Array'
136
+ when Hash
137
+ 'ns2:Map'
138
+ when String
139
+ 'xsd:string'
140
+ when Integer
141
+ 'xsd:int'
142
+ else
143
+ 'xsd:string'
144
+ end
145
+ end
146
+
147
+ end
148
+
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+
3
+ require_relative 'connector'
4
+
5
+ module Libis
6
+ module Services
7
+ module CollectiveAccess
8
+
9
+ class ItemInfo < Connector
10
+
11
+ def initialize(host = nil)
12
+ super 'ItemInfo', host
13
+ end
14
+
15
+ def get_attributes(item, type = nil)
16
+ type ||= 'ca_objects'
17
+ request :getAttributes, type: type, item_id: item.to_s
18
+ end
19
+
20
+ def get_attribute(item, attribute, type = nil)
21
+ type ||= 'ca_objects'
22
+ request :getAttributesByElement, type: type, item_id: item.to_s, attribute_code_or_id: attribute.to_s
23
+ end
24
+
25
+ def get_items(item_list, bundle, type = nil)
26
+ type ||= 'ca_objects'
27
+ r1, a1 = soap_encode item_list
28
+ r2, a2 = soap_encode bundle
29
+ request :get, type: type, item_ids: r1, bundles: r2, :attributes! => {item_ids: a1, bundles: a2}
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+
3
+ require 'libis/services/generic_search'
4
+
5
+ require_relative 'connector'
6
+
7
+ module Libis
8
+ module Services
9
+ module CollectiveAccess
10
+
11
+ class Search < Connector
12
+ include ::Libis::Services::GenericSearch
13
+
14
+ def initialize(host = nil)
15
+ super 'Search', host
16
+ end
17
+
18
+ def query(query, options = {})
19
+ request :querySoap, type: (options[:index] || 'ca_objects'), query: query
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,80 @@
1
+ # coding: utf-8
2
+
3
+ require_relative 'search'
4
+ require_relative 'item_info'
5
+ require_relative 'cataloguing'
6
+
7
+ module Libis
8
+ module Services
9
+ module CollectiveAccess
10
+
11
+ class Service
12
+
13
+ attr_reader :search, :info, :cata
14
+
15
+ def initialize(host = nil)
16
+ @search = ::Libis::Services::CollectiveAccess::Search.new host
17
+ @info = ::Libis::Services::CollectiveAccess::ItemInfo.new host
18
+ @cata = ::Libis::Services::CollectiveAccess::Cataloguing.new host
19
+ end
20
+
21
+ def authenticate(name = nil, password = nil)
22
+ result = @search.authenticate name, password
23
+ result &&= @info.authenticate name, password
24
+ result && @cata.authenticate(name, password)
25
+ end
26
+
27
+ def deauthenticate
28
+ @search.deauthenticate
29
+ @info.deauthenticate
30
+ @cata.deauthenticate
31
+ end
32
+
33
+ def add_object(label)
34
+ @cata.add_item idno: label, type_id: 21
35
+ end
36
+
37
+ def search_object(attributes = {})
38
+ query = attributes.delete :query || ''
39
+ query = attributes.inject(query) { |q, (k, v)|
40
+ q << ' AND ' unless q.empty?
41
+ q << k << ':' if k
42
+ v = "\"#{v}\"" if v.is_a?(String) and !v.include? '"'
43
+ q << v
44
+ }
45
+ result = @search.query query
46
+ return nil unless result && result.is_a?(Hash) && !result.empty?
47
+ result.first[0]
48
+ end
49
+
50
+ def get_object(label)
51
+ search_object query: "\"#{label}\""
52
+ end
53
+
54
+ def delete_object(object)
55
+ @cata.remove object
56
+ end
57
+
58
+ def add_attribute(object, attribute, value)
59
+ @cata.add_attribute object, attribute.to_s, {attribute.to_sym => value}
60
+ end
61
+
62
+ def get_attribute(object, attribute)
63
+ result = @info.get_attribute object, attribute
64
+ result = [result] unless result.is_a? Array
65
+ result
66
+ end
67
+
68
+ def delete_attribute(_, _) #object, attribute)
69
+
70
+ end
71
+
72
+ def delete_attributes(object)
73
+ @cata.remove_attributes object
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1 @@
1
+ require 'libis/services/collective_access/service'