Class: SoarSr::Search
- Inherits:
-
Handler
show all
- Includes:
- Jsender
- Defined in:
- lib/soar_sr/search.rb
Instance Attribute Summary
Attributes inherited from Handler
#registry
Instance Method Summary
collapse
Methods inherited from Handler
#authorize, #initialize
Methods inherited from Validator
#authorized?, #contact?, #credentials?, #identifier?, #key_provided?, #length_at_least?, #meta?, #one_of, #present?, #provided?, #type?, #uri?, #wadl?
Instance Method Details
#query_service_by_pattern(pattern) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/soar_sr/search.rb', line 8
def query_service_by_pattern(pattern)_{
provided?(pattern, 'pattern')
result = @uddi.find_services
list = {}
if has_data?(result, 'services')
result['data']['services'].each do |service, name|
detail = @uddi.get_service(service)
if has_data?(detail, 'description')
found = false
dss = nil
detail['data']['description'].each do |description|
found = true if (description and description.include?(pattern))
dss = description.gsub("dss:", "").strip if (description and description.include?('dss:'))
end
list[service] = detail if ((dss and (@dss and check_dss(service))) or (not dss)) and found
end
end
end
success_data({ 'services' => list })
}end
|
#search_access_points(pattern) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/soar_sr/search.rb', line 87
def search_access_points(pattern)
found = []
result = @registry.services.list_services['data']['services']
result ||= {}
result.each do |service, detail|
uris = detail['uris']
uris ||= {}
uris.each do |id, access_details|
access_details ||= {}
access_point = access_details['access_point']
access_point ||= ""
included = (not((access_point =~ /#{pattern}/i).nil?))
found << service if (included and (not found.include?(service)))
end
end
success_data({'services' => found})
end
|
#search_domain_perspective(domain_perspective, pattern) ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/soar_sr/search.rb', line 105
def search_domain_perspective(domain_perspective, pattern)_{
domain_perspective = standardize(domain_perspective)
provided?(domain_perspective, 'domain perspective') and registered?(domain_perspective, 'domains')
found = {}
data = @registry.associations.domain_perspective_associations(domain_perspective)['data']['associations']
services = {}
service_components = {}
services_list = data['services']
service_components_list = data['service_components']
services_list.each do |service, detail|
data = @uddi.get_service(service)['data']
services[extract_domain_name('services', service)] = data if search_for_pattern_in_hash_values(data, pattern)
end
service_components_list.each do |service_component, detail|
data = @uddi.get_service_component(service_component)['data']
service_components[extract_domain_name('services-components', service_component)] = data if search_for_pattern_in_hash_values(data, pattern)
end
found = services.merge!(service_components)
success_data({'services' => found})
}end
|
#search_for_service(pattern, include_service_components = true, full_text = true) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/soar_sr/search.rb', line 49
def search_for_service(pattern, include_service_components = true, full_text = true)_{
provided?(pattern, 'pattern') and length_at_least?(pattern, 4, 'pattern')
services = {}
service_components = {}
services_list = @uddi.find_services(pattern)['data']['services'] if not include_service_components
services_list, service_components_list = @registry.services.find_services_and_service_components(nil) if include_service_components
services_list.each do |service, detail|
service_name = extract_domain_name('services', service)
if full_text
data = @uddi.get_service(service)['data'] if full_text
if search_for_pattern_in_hash_values(data, pattern)
services[service_name] = data
services[service_name]['uris'] = @registry.services.service_uris(service_name)['data']['bindings']
end
else
if service_name == service
services[service_name] = detail
services[service_name]['uris'] = @registry.services.service_uris(service_name)['data']['bindings']
end
end
end
if (include_service_components)
service_components_list.each do |service_component, detail|
service_name = extract_domain_name('services-components', service_component)
if full_text
data = @uddi.get_service_component(service_component)['data']
service_components[service_name] = data if search_for_pattern_in_hash_values(data, pattern)
else
service_components[service_name] = detail if service_name == service_component
end
end
end
found = services.merge!(service_components)
success_data({'services' => found})
}end
|
#search_for_service_component(pattern, full_text = true) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/soar_sr/search.rb', line 37
def search_for_service_component(pattern, full_text = true)
services = search_for_service(pattern, true, full_text)
service_components = {}
if services['status'] == 'success'
services['data']['services'].each do |service, detail|
service_components[service] = detail if detail['key'].include?('service-components')
end
result = success_data({'services' => service_components})
end
result
end
|
#search_services_for_uri(pattern) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/soar_sr/search.rb', line 30
def search_services_for_uri(pattern)_{
provided?(pattern, 'pattern') and length_at_least?(pattern, 4, 'pattern')
result = @registry.services.list_services
found = (result, pattern)
success_data({'services' => found})
}end
|